'use client' import { useRef, useState } from 'react' /** While a dot click animates the track, the scroll listener must not fight it. */ const PROGRAMMATIC_SCROLL_LOCK_MS = 700 import { CardModelTile } from '@/components/cards/CardModelTile' import { CARD_MODELS, type CardModel, type CardModelId } from '@/lib/cardModels' type CardModelGalleryProps = { ariaLabel: string fontFamily: string selectedId?: CardModelId | null onSelect: (id: CardModelId) => void } const tileClassName = 'group flex h-full w-full flex-col rounded-xl text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--pt-red) focus-visible:ring-offset-2 focus-visible:ring-offset-(--campaign-cream)' /** * S14/S15/S30/S31 — the six models side by side on desktop (a single row) and a * one-item-with-peek snap track on mobile, as buttons for the studio island: * selecting a tile opens the single composer in place (home or `/cards`). Both * tracks come from the same catalog (S13); the mobile track carries the six * page dots of the design gate (scene 2), following the scroll position. */ export const CardModelGallery = ({ ariaLabel, fontFamily, selectedId = null, onSelect, }: CardModelGalleryProps) => { const trackRef = useRef(null) const isProgrammaticScrollRef = useRef(false) const [activeIndex, setActiveIndex] = useState(0) const syncActiveItem = () => { const track = trackRef.current if (!track || isProgrammaticScrollRef.current) return const items = Array.from(track.querySelectorAll('li')) const center = track.scrollLeft + track.clientWidth / 2 let nearestIndex = activeIndex let nearestDistance = Number.POSITIVE_INFINITY items.forEach((item, index) => { const distance = Math.abs(item.offsetLeft - track.offsetLeft + item.offsetWidth / 2 - center) if (distance < nearestDistance) { nearestDistance = distance nearestIndex = index } }) if (nearestIndex !== activeIndex) setActiveIndex(nearestIndex) } const scrollToModel = (index: number) => { const track = trackRef.current const target = track?.querySelector(`li:nth-child(${index + 1})`) if (!track || !target) return isProgrammaticScrollRef.current = true setActiveIndex(index) track.scrollTo({ left: target.offsetLeft - track.offsetLeft, behavior: 'smooth' }) window.setTimeout(() => { isProgrammaticScrollRef.current = false }, PROGRAMMATIC_SCROLL_LOCK_MS) } const renderItem = (model: CardModel) => { const selected = selectedId === model.id return ( ) } return (
    {CARD_MODELS.map((model) => (
  • {renderItem(model)}
  • ))}
    {CARD_MODELS.map((model) => (
  • {renderItem(model)}
  • ))}

Deslize para ver os seis modelos

{/* The visual dot of the gate sits inside a 24px target (WCAG 2.5.8 AA). */}
{CARD_MODELS.map((model, index) => ( ))}
) }