/** * DTGallery — Image gallery with beveled media frame and thumbnails. * * CSS reference: bevels.css .dt-bevel-media */ import { useState, type CSSProperties } from 'react'; import type { DTVariant } from '@dangerousthings/tokens'; import { cx } from '../utils/cx'; import { getVariantClass } from '../utils/variantClasses'; export interface DTGalleryItem { key: string; src: string; alt?: string; thumbnail?: string; } interface DTGalleryProps { items: DTGalleryItem[]; /** Color variant @default 'normal' */ variant?: DTVariant; className?: string; style?: CSSProperties; } export function DTGallery({ items, variant = 'normal', className, style, }: DTGalleryProps) { const [activeIndex, setActiveIndex] = useState(0); if (items.length === 0) return null; const current = items[activeIndex]; return (
{/* Main image */}
{current.alt
{/* Thumbnails */} {items.length > 1 && (
{items.map((item, i) => ( ))}
)}
); }