Add Hover gallery component (#3246)

This commit is contained in:
Paweł Kuna authored and GitHub committed 2026-10-02 13:07:05 +02:00
1 parent ace9a4f123
commit f7c848a938
21 files changed
+374

No files matched your search

+4
View File
@@ -222,6 +222,10 @@
"title": "Empty state",
"url": "/ui/components/empty"
},
{
"title": "Hover gallery",
"url": "/ui/components/hover-gallery"
},
{
"title": "Icon",
"url": "/ui/components/icon"
+5
View File
@@ -168,6 +168,11 @@
}
}
},
"hover-gallery": {
"url": "hover-gallery.html",
"title": "Hover gallery",
"badge": "New"
},
"legend": {
"url": "legend.html",
"title": "Legend"
Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

+32
View File
@@ -0,0 +1,32 @@
---
// Hover gallery (.hover-gallery): one image on display, the others show as the pointer moves across.
export interface HoverGalleryImage {
src: string
alt?: string
}
interface Props {
/** one `.hover-gallery-item` per image; the first one shows by default */
images: HoverGalleryImage[]
/** core/scss/ui/_hover-gallery.scss `.hover-gallery-indicators` */
showIndicators?: boolean
/** sets `--tblr-hover-gallery-aspect-ratio`, e.g. "16 / 9" */
aspectRatio?: string | undefined
class?: string
/** remaining attributes (id, data-*, aria-*, …) are forwarded to the root element */
[key: string]: unknown
}
const { images, showIndicators = false, aspectRatio, class: className, ...rest } = Astro.props
---
<div class:list={['hover-gallery', showIndicators && 'hover-gallery-indicators', className]} style={aspectRatio ? `--tblr-hover-gallery-aspect-ratio: ${aspectRatio}` : undefined} {...rest}>
{
images.map((image) => (
<div class="hover-gallery-item">
<img src={image.src} alt={image.alt ?? ''} />
</div>
))
}
</div>