src/bento/components/bento-inline-gallery/1.0/README.md
Displays slides, with optional pagination dots and thumbnails. Its implementation uses a Bento Base Carousel. Both components must be properly installed for the environment (Web Component vs Preact).
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.
npm install @bentoproject/inline-gallery
import {defineElement as defineBentoInlineGallery} from '@bentoproject/inline-gallery';
defineBentoInlineGallery();
<script><script type="module" src="https://cdn.ampproject.org/bento.mjs" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.ampproject.org/bento.js" crossorigin="anonymous"></script>
<script type="module" src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.mjs" crossorigin="anonymous"></script>
<script nomodule src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.css" crossorigin="anonymous">
<!DOCTYPE html>
<html>
<head>
<script
type="module"
async
src="https://cdn.ampproject.org/bento.mjs"
></script>
<script nomodule src="https://cdn.ampproject.org/bento.js"></script>
<script
type="module"
async
src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.mjs"
></script>
<script
nomodule
async
src="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.js"
></script>
<link
rel="stylesheet"
href="https://cdn.ampproject.org/v0/bento-inline-gallery-1.0.css"
/>
<script
type="module"
async
src="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.mjs"
></script>
<script
nomodule
async
src="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.js"
></script>
<link
rel="stylesheet"
href="https://cdn.ampproject.org/v0/bento-base-carousel-1.0.css"
/>
</head>
<body>
<bento-inline-gallery id="inline-gallery">
<bento-inline-gallery-thumbnails
style="height: 100px"
loop
></bento-inline-gallery-thumbnails>
<bento-base-carousel
style="height: 200px"
snap-align="center"
visible-count="3"
loop
>
</bento-base-carousel>
<bento-inline-gallery-pagination
style="height: 20px"
></bento-inline-gallery-pagination>
</bento-inline-gallery>
</body>
</html>
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/bento-inline-gallery-1.0.css"
/>
Alternatively, you may also make the light-weight pre-upgrade styles available inline:
<style>
bento-inline-gallery,
bento-inline-gallery-pagination,
bento-inline-gallery-thumbnails {
display: block;
}
bento-inline-gallery {
contain: layout;
}
bento-inline-gallery-pagination,
bento-inline-gallery-thumbnails {
overflow: hidden;
position: relative;
}
</style>
<bento-inline-gallery-pagination>insetBoolean attribute indicating whether to display the pagination indicator as inset (overlaying the carousel itself). Default is false.
<bento-inline-gallery-thumbnails>aspect-ratioA Number defining the ratio of width to height that slides should be displayed in. This value is optional.
loopBoolean attribute indicating whether thumbnails should loop. The default is false.
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.
npm install @bentoproject/inline-gallery
import React from 'react';
import {BentoInlineGallery} from '@bentoproject/inline-gallery/react';
import '@bentoproject/inline-gallery/styles.css';
function App() {
return (
<BentoInlineGallery id="inline-gallery">
<BentoInlineGalleryThumbnails aspect-ratio="1.5" loop />
<BentoBaseCarousel snap-align="center" visible-count="1.2" loop>
</BentoBaseCarousel>
<BentoInlineGalleryPagination inset />
</BentoInlineGallery>
);
}
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: 300}}>...</BentoInlineGallery>
Or via className:
<BentoInlineGallery className="custom-styles">...</BentoInlineGallery>
.custom-styles {
background-color: red;
}
BentoInlineGalleryPaginationIn addition to the common props, BentoInlineGalleryPagination supports the props below:
insetBoolean attribute indicating whether to display the pagination indicator as inset (overlaying the carousel itself). Default is false.
BentoInlineGalleryThumbnailsIn addition to the common props, BentoInlineGalleryThumbnails supports the props below:
aspectRatioA Number defining the ratio of width to height that slides should be displayed in (this is optional).
loopBoolean attribute indicating whether thumbnails should loop. Default is false.