import { useEffect, useRef } from "react" import { useVersionsContext } from "@/components/canvas/versions-context" import { useDictionary } from "@/hooks/use-dictionary" import { cn } from "@/lib/utils" import { useUiStore } from "@/stores/ui-store" /** Row of version thumbnails under the panel header; click to compare */ export function VersionStrip({ minVersions = 2, }: { /** Hidden below this many versions: one version alone adds nothing to * its card, unless the caller knows there is no card for it */ minVersions?: number }) { const dict = useDictionary() const { versions, onCanvasId } = useVersionsContext() const openCompare = useUiStore((s) => s.openCompare) const scrollRef = useRef(null) // Keep the newest version in view useEffect(() => { const el = scrollRef.current if (el) el.scrollTo({ left: el.scrollWidth, behavior: "smooth" }) }, [versions.length]) if (versions.length < minVersions) return null return (
{dict.versions.strip}
{versions.map((version) => { const isCurrent = version.id === onCanvasId return ( ) })}
) }