import { ArrowUpRight } from 'lucide-react'; import { cn } from '@/lib/utils'; import { useStorefront } from '../context'; import type { BentoSection, BentoTile } from '../types'; import { Container, SectionHeading, SfLink } from '../ui'; /** * Tile sizes for the mosaic layout on wide screens (4 columns), by how many tiles there are. * The first tile is always the big one. On phones the big and wide tiles take the full width. */ const mosaic: Record = { 3: ['big', 'wide', 'wide'], 4: ['big', 'wide', 'small', 'small'], 5: ['big', 'small', 'small', 'small', 'small'], 6: ['big', 'small', 'small', 'small', 'small', 'full'], }; const sizeClass: Record = { big: 'col-span-2 row-span-2', wide: 'col-span-2', small: 'col-span-1', full: 'col-span-2 md:col-span-4', }; const toneClass: Record = { primary: 'bg-(--sf-primary) text-(--sf-primary-fg)', accent: 'bg-(--sf-accent) text-(--sf-fg)', dark: 'bg-(--sf-fg) text-(--sf-bg)', surface: 'bg-(--sf-surface) text-(--sf-fg)', }; /** Tiles of different sizes for products, collections, offers and stories, like a bento box. */ export function Bento({ section }: { section: BentoSection }) { const { heading, tiles } = section.content; const even = section.variant === 'even'; const sizes = mosaic[tiles.length] ?? []; return (
{heading && }
    {tiles.map((tile, index) => (
  • ))}
); } function Tile({ tile, big }: { tile: BentoTile; big: boolean }) { const { heroImages } = useStorefront(); const photo = tile.image ? heroImages.refs[tile.image] : undefined; return ( {photo && ( <> )} ); }