Thumbnails Hero
The Thumbnail Hero lets the user scroll through a carousel of large images by clicking on one of a series of inset thumbnail images. A content box is overlaid on top of the hero to provide additional text or controls.
Because it uses the Carousel component, it is only available in React Visage, and not in the vanilla API.
Playground
ThumbnailsHero
is only available as a React component and is not available in the vanilla JS API.
On the technical side, it consists of four children:
ThumbnailsHeroThumbnailsContainer
, which holds a set ofCarouselSlide
components. Each slide should hold a square thumbnail image that is aFluidImage
.ThumbnailsHeroImagesContainer
, a second set ofCarouselSlide
components. Each slide should hold a large image that is aFluidImage
.ThumbnailsHeroBackgroundContainer
, which holds a single large placeholder image that will be shown while the image carousels load. Typical usage is to have this match the first large image, so that the loading is visually seamless.ThumbnailsHeroContentContainer
, a wrapper forThumbnailsHeroContent
, which can be any content you'd like.
<ThumbnailsHero><ThumbnailsHeroThumbnailsSlidesContainer><CarouselSlide>/* Fluid Image goes here */</CarouselSlide><CarouselSlide>/* Fluid Image goes here */</CarouselSlide><CarouselSlide>/* Fluid Image goes here */</CarouselSlide></ThumbnailsHeroThumbnailsSlidesContainer><ThumbnailsHeroImagesSlidesContainer><CarouselSlide>/* Fluid Image goes here */</CarouselSlide><CarouselSlide>/* Fluid Image goes here */</CarouselSlide><CarouselSlide>/* Fluid Image goes here */</CarouselSlide></ThumbnailsHeroImagesSlidesContainer><ThumbnailsHeroBackgroundContainer>/* Fluid Image goes here */</ThumbnailsHeroBackgroundContainer><ThumbnailsHeroContentContainer><ThumbnailsHeroContent>Hero content goes here</ThumbnailsHeroContent></ThumbnailsHeroContentContainer></ThumbnailsHero>
Content Width
You can change the width of the content area via the contentWidth
prop:
<ThumbnailsHero contentWidth="wide"></ThumbnailsHero>
Skins
Besides the default look, there is one skin, "under
", that places the thumbnails under the hero rather than on top of it. This skin also sets a fixed height for the hero images, and allows the content box to grow taller than the hero image.
Showing the "under" skin
This skin sets a specific height for the hero images.
With this skin, the content box is allowed to grow taller than the hero image. It will then spill outside of the boundary of the hero image, pushing down the content below the hero.
<ThumbnailsHero skin="under"><ThumbnailsHeroThumbnailsSlidesContainer><CarouselSlide><FluidImage src="https://picsum.photos/800/400?id=1" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?id=2" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?id=3" /></CarouselSlide></ThumbnailsHeroThumbnailsSlidesContainer><ThumbnailsHeroImagesSlidesContainer><CarouselSlide><FluidImage src="https://picsum.photos/800/400?id=4" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?id=5" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?id=6" /></CarouselSlide></ThumbnailsHeroImagesSlidesContainer><ThumbnailsHeroBackgroundContainer><FluidImage src="https://picsum.photos/800/400?id=7" alt="Placeholder" /></ThumbnailsHeroBackgroundContainer><ThumbnailsHeroContentContainer><ThumbnailsHeroContent><h1>Showing the "under" skin</h1><p>This skin sets a specific height for the hero images.</p><p>With this skin, the content box is allowed to grow taller than the heroimage. It will then spill outside of the boundary of the hero image,pushing down the content below the hero.</p></ThumbnailsHeroContent></ThumbnailsHeroContentContainer></ThumbnailsHero>
Current Slide
ThumbnailsHero
uses the react-slick library under the hood, which doesn't allow us to control the state of the carousel.The implications of this is that we can't have a piece of React state be the single source of truth for the selected slide in the carousel, we can programmatically change the slide with the
currentSlide
prop, but users can also interact with the carousel (via clicking or swiping) which would also change the slide.Bear in mind then, that the
onSlideChange
prop is intended to be notified when a slide is changed, but you can't override the change.
You can programmatically change which slide is selected via the currentSlide
prop. It accepts the index of the slide to select.
On first render, the ThumbnailsHero
will render with the chosen slide already selected. On re-renders triggered by changing the currentSlide
prop, the carousels will animate towards the newly selected slide.
Since the selected slide can also be changed by clicking on a thumbnail or by swiping, you can subscribe to the state of the currently selected slide via the onSlideChange
prop.
Specifying current slide
This content box can contain any content you'd like.
() => {const [slideIndex, setSlideIndex] = React.useState(2)return (<><label>Change slide to:</label><Dropdownvalue={slideIndex}onChange={event => setSlideIndex(event.target.value)}><DropdownOption value={0}>t1</DropdownOption><DropdownOption value={1}>t2</DropdownOption><DropdownOption value={2}>t3</DropdownOption></Dropdown><ThumbnailsHerocurrentSlide={slideIndex}onSlideChange={(currentIndex, targetIndex) =>setSlideIndex(targetIndex)}><ThumbnailsHeroThumbnailsSlidesContainer><CarouselSlide><FluidImage src="https://picsum.photos/800/400" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?q=2" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?q=3" /></CarouselSlide></ThumbnailsHeroThumbnailsSlidesContainer><ThumbnailsHeroImagesSlidesContainer><CarouselSlide><FluidImage src="https://picsum.photos/800/400?q=4" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?q=5" /></CarouselSlide><CarouselSlide><FluidImage src="https://picsum.photos/800/400?q=6" /></CarouselSlide></ThumbnailsHeroImagesSlidesContainer><ThumbnailsHeroBackgroundContainer><FluidImagesrc="https://picsum.photos/800/400?q=7"alt="Placeholder"/></ThumbnailsHeroBackgroundContainer><ThumbnailsHeroContentContainer><ThumbnailsHeroContent><h1>Specifying current slide</h1><p>This content box can contain any content you'd like.</p></ThumbnailsHeroContent></ThumbnailsHeroContentContainer></ThumbnailsHero></>)}
Design
The thumbnails must be square, and will be displayed at a pre-set height and width of 64px. The thumbnail will be scaled down as needed.
The overall height of the Hero will be determined by the height of the
ThumbnailsHeroContentContainer
. The large images may get zoomed, clipped, or scaled to match.The content box has no styling of its own, and no padding. The consuming page can style the contents as it sees fit.
Components
ThumbnailsHero
Prop | Type | Default | Description |
---|---|---|---|
skin | "standard" | "under" | standard | The visual style of the thumbnails hero |
contentWidth | "standard" | "wide" | standard | The width of the content area |
currentSlide | number | The index of the slide to select | |
onSlideChange | (currentIndex: number, targetIndex: number) => void | A callback fired when the ThumbnailsHero changes the selected slide It is passed the index of the currently selected slide and the index of the slide it will change to |
All other props are forwarded to the element specified in thecomponent
prop(default: <div/>
)
ThumbnailsHeroThumbnailsSlidesContainer
ThumbnailsHeroThumbnailsSlidesContainer
has no props of its own
All props are forwarded to the element specified in thecomponent
prop(default: <div/>
)
ThumbnailsHeroImagesSlidesContainer
ThumbnailsHeroImagesSlidesContainer
has no props of its own
All props are forwarded to the element specified in thecomponent
prop(default: <div/>
)
ThumbnailsHeroBackgroundContainer
ThumbnailsHeroBackgroundContainer
has no props of its own
All props are forwarded to the element specified in thecomponent
prop(default: <div/>
)
ThumbnailsHeroContentContainer
ThumbnailsHeroContentContainer
has no props of its own
All props are forwarded to the element specified in thecomponent
prop(default: <div/>
)
ThumbnailsHeroContent
ThumbnailsHeroContent
has no props of its own
All props are forwarded to the element specified in thecomponent
prop(default: <div/>
)