Files
dt-design-system/packages/react/src/components/DTGallery.tsx
michael e74c285b70 Add storefront component migration: cards, badges, progress bars, animations, and React wrapper package
Major feature migration from dt-shopify-storefront into the design system:

- Card system: per-card color modes (normal/emphasis/warning/success/other),
  progress bars, full-bleed card body (card-body-flush), image bevel clip-paths,
  and visible structural borders at bevel corners
- Badge system: dt-card-badge with position-aware offsets for cards vs media frames
- Media frames: dt-bevel-media with inner surface fill, image clipping, and
  "MISSING MEDIA" placeholder for empty containers
- Interactive bevel buttons: dt-btn with hover/selected states and pulse animation
- Menu items: dt-menu-item with active states and level indentation
- Animations: scale-in, fade-in, slide-up, pulse, ping, spin keyframes
- Feature legend: CSS grid for product feature icons with state colors
- Scrollbar styling for DT brand
- New @dangerousthings/react package wrapping web CSS components
- New @dangerousthings/tailwind-preset package
- New @dangerousthings/hex-background package
- Desktop showcase rewritten in React with Tailwind CSS
- Mobile showcase updated with new screens (animations, filters, advanced cards)
- Tokens: added mode color tokens, RGB variants, and selected-state tokens

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 10:18:39 -08:00

92 lines
2.3 KiB
TypeScript

/**
* 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 (
<div className={cx(getVariantClass(variant), className)} style={style}>
{/* Main image */}
<div className="dt-bevel-media" style={{ overflow: 'hidden' }}>
<img
src={current.src}
alt={current.alt || ''}
style={{
width: '100%',
height: 'auto',
display: 'block',
transition: 'opacity 300ms ease-in-out',
}}
/>
</div>
{/* Thumbnails */}
{items.length > 1 && (
<div
style={{
display: 'flex',
gap: '8px',
marginTop: '8px',
overflowX: 'auto',
}}>
{items.map((item, i) => (
<button
key={item.key}
onClick={() => setActiveIndex(i)}
type="button"
style={{
flexShrink: 0,
width: '64px',
height: '64px',
padding: 0,
border: i === activeIndex
? '2px solid var(--dt-card-color, var(--color-primary))'
: '2px solid transparent',
background: 'none',
cursor: 'pointer',
overflow: 'hidden',
}}>
<img
src={item.thumbnail || item.src}
alt={item.alt || ''}
style={{ width: '100%', height: '100%', objectFit: 'cover' }}
/>
</button>
))}
</div>
)}
</div>
);
}