Socket
Socket
Sign inDemoInstall

@ampproject/amp-inline-gallery

Package Overview
Dependencies
2
Maintainers
16
Versions
91
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ampproject/amp-inline-gallery

AMP HTML amp-inline-gallery Component


Version published
Weekly downloads
1
decreased by-88.89%
Maintainers
16
Created
Weekly downloads
 

Readme

Source

Usage

The Bento Inline Gallery component uses a Bento Carousel component to display slides, with optional pagination dots and thumbnails. Both components must be properly installed for the environment (Web Component vs Preact).

Web Component

You must include each Bento component's required CSS library to guarantee proper loading and before adding custom styles. Or use the light-weight pre-upgrade styles available inline. See Layout and style.

The examples below demonstrate use of the <bento-inline-gallery> web component.

Example: Import via npm

[example preview="top-frame" playground="false"]

Install via npm:

npm install @ampproject/bento-inline-gallery
import '@ampproject/bento-inline-gallery';

[/example]

Example: Include via <script>

The example below contains a bento-inline-gallery consisting of three slides with thumbnails and a pagination indicator.

[example preview="top-frame" playground="false"]

<head>
  <script src="https://cdn.ampproject.org/custom-elements-polyfill.js"></script>
  <script async src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.js"></script>
  <link rel="stylesheet" type="text/css" href="https://cdn.ampproject.org/v0/amp-inline-gallery-1.0.css">
</head>
<body>

  <bento-inline-gallery id="inline-gallery">
    <bento-inline-gallery-thumbnails aspect-ratio="1.5" loop></bento-inline-gallery-thumbnails>
    <bento-base-carousel snap-align="center" visible-count="1.2" loop>
      <img src="server.com/static/inline-examples/images/image1.jpg">
      <img src="server.com/static/inline-examples/images/image2.jpg">
      <img src="server.com/static/inline-examples/images/image3.jpg">
    </bento-base-carousel>
    <bento-inline-gallery-pagination inset></bento-inline-gallery-pagination>
  </bento-inline-gallery>

</body>

[/example]

Layout and style

Each Bento component has a small CSS library you must include to guarantee proper loading without content shifts. Because of order-based specificity, you must manually ensure that stylesheets are included before any custom styles.

<link rel="stylesheet" type="text/css" href="https://cdn.ampproject.org/v0/amp-inline-gallery-1.0.css">

Alternatively, you may also make the light-weight pre-upgrade styles available inline:

<style data-bento-boilerplate>
  amp-inline-gallery,
  amp-inline-gallery-pagination,
  amp-inline-gallery-thumbnails {
    display: block;
  }
  amp-inline-gallery {
    contain: layout;
  }
  amp-inline-gallery-pagination,
  amp-inline-gallery-thumbnails {
    overflow: hidden;
    position: relative;
  }
</style>
Attributes
inset

Default: false

Boolean attribute indicating whether to display the pagination indicator as inset (overlaying the carousel itself)

aspect-ratio

Optional

Number: ratio of width to height that slides should be displayed in.

loop

Default: false

Boolean attribute indicating whether thumbnails should loop.

Styling

You may use the bento-inline-gallery, bento-inline-gallery-pagination, bento-inline-gallery-thumbnails, and bento-base-carousel element selectors to style the pagination indicator, thumbnails, and carousel freely.

Preact/React Component

The examples below demonstrates use of the <BentoInlineGallery> as a functional component usable with the Preact or React libraries.

Example: Import via npm

[example preview="top-frame" playground="false"]

Install via npm:

npm install @ampproject/bento-inline-gallery
import React from 'react';
import { BentoInlineGallery } from '@ampproject/bento-inline-gallery/react';
import '@ampproject/bento-inline-gallery/styles.css';

function App() {
  return (
    <BentoInlineGallery id="inline-gallery">
      <BentoInlineGalleryThumbnails aspect-ratio="1.5" loop></BentoInlineGalleryThumbnails>
      <BentoBaseCarousel snap-align="center" visible-count="1.2" loop>
        <img src="server.com/static/inline-examples/images/image1.jpg">
        <img src="server.com/static/inline-examples/images/image2.jpg">
        <img src="server.com/static/inline-examples/images/image3.jpg">
      </BentoBaseCarousel>
      <BentoInlineGallery-pagination inset></BentoInlineGallery-pagination>
    </BentoInlineGallery>
  }

[/example]

Layout and style

Container type

The BentoInlineGallery component has a defined layout size type. To ensure the component renders correctly, be sure to apply a size to the component and its immediate children via a desired CSS layout (such as one defined with width). These can be applied inline:

<BentoInlineGallery style={{width: '300px'}}>
  ...
</BentoInlineGallery>

Or via className:

<BentoInlineGallery className='custom-styles'>
  ...
</BentoInlineGallery>
.custom-styles {
  background-color: red;
}
Props
BentoInlineGallery
BentoInlineGalleryPagination

In addition to the common props, BentoInlineGalleryPagination supports the props below:

inset

Default: false

Boolean attribute indicating whether to display the pagination indicator as inset (overlaying the carousel itself)

BentoInlineGalleryThumbnails

In addition to the common props, BentoInlineGalleryThumbnails supports the props below:

aspectRatio

Optional

Number: ratio of width to height that slides should be displayed in.

loop

Default: false

Boolean attribute indicating whether thumbnails should loop.

FAQs

Package last updated on 14 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc