{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "expand-gallery",
  "title": "Expand Gallery",
  "description": "A row of small thumbnails where each one grows large in turn as you scroll.",
  "dependencies": [
    "gsap",
    "@gsap/react"
  ],
  "registryDependencies": [
    "https://trytweenly.vercel.app/r/use-reduced-motion.json",
    "utils"
  ],
  "files": [
    {
      "path": "registry/new-york/expand-gallery/expand-gallery.tsx",
      "content": "\"use client\"\n\nimport { useEffect, useRef, useState } from \"react\"\nimport gsap from \"gsap\"\nimport { ScrollTrigger } from \"gsap/ScrollTrigger\"\nimport { useGSAP } from \"@gsap/react\"\nimport { useReducedMotion } from \"@/registry/new-york/hooks/use-reduced-motion\"\nimport { cn } from \"@/lib/utils\"\n\ngsap.registerPlugin(useGSAP, ScrollTrigger)\n\nexport interface ExpandGalleryItem {\n  src: string\n  alt: string\n}\n\nexport interface ExpandGalleryProps {\n  images: ExpandGalleryItem[]\n  /** Thumbnail width, as % of the section width. Default: 9 */\n  smallWidth?: number\n  /** Thumbnail aspect ratio. Default: \"3 / 4\" */\n  smallAspect?: string\n  /** Expanded width, as % of the section width. Default: 20 */\n  largeWidth?: number\n  /** Expanded height, as % of the section height. Default: 72 */\n  largeHeight?: number\n  /** Gap between images in px. Default: 12 */\n  gap?: number\n  /** Row alignment. Default: \"start\" */\n  align?: \"start\" | \"center\"\n  /** Section heights of scrolling per image. Default: 0.6 */\n  scrollPerImage?: number\n  /** Scroll smoothing in seconds. Default: 0.8 */\n  scrub?: number\n  /** Show an \"03 / 06\" counter. Default: true */\n  counter?: boolean\n  /** Scroll container to track instead of the window (selector or element). */\n  scroller?: string | HTMLElement\n  /** Height of the pinned section (any CSS length). Default: \"100vh\" */\n  height?: string\n  className?: string\n}\n\nconst tint = (i: number) =>\n  `hsl(${(i * 47) % 360} 42% 52% / 0.4)`\nconst hideBroken = (e: React.SyntheticEvent<HTMLImageElement>) => (e.currentTarget.style.visibility = \"hidden\")\n\nfunction ratio(aspect: string) {\n  const [w, h] = aspect.split(\"/\").map((v) => parseFloat(v))\n  return w && h ? w / h : 0.75\n}\n\nexport function ExpandGallery({\n  images,\n  smallWidth = 9,\n  smallAspect = \"3 / 4\",\n  largeWidth = 20,\n  largeHeight = 72,\n  gap = 12,\n  align = \"start\",\n  scrollPerImage = 0.6,\n  scrub = 0.8,\n  counter = true,\n  scroller,\n  height = \"100vh\",\n  className,\n}: ExpandGalleryProps) {\n  const sectionRef = useRef<HTMLElement>(null)\n  const reduced = useReducedMotion()\n  const [active, setActive] = useState(0)\n  const n = images.length\n\n  useEffect(() => {\n    sectionRef.current?.querySelectorAll(\"img\").forEach((img) => {\n      if (img.complete && img.naturalWidth === 0) img.style.visibility = \"hidden\"\n    })\n  }, [images])\n\n  useGSAP(\n    () => {\n      const section = sectionRef.current\n      if (!section || !n) return\n      const items = gsap.utils.toArray<HTMLElement>(\"[data-expand-item]\", section)\n\n      const small = { width: () => (section.clientWidth * smallWidth) / 100, height: () => (section.clientWidth * smallWidth) / 100 / ratio(smallAspect) }\n      const large = { width: () => (section.clientWidth * largeWidth) / 100, height: () => (section.clientHeight * largeHeight) / 100 }\n\n      items.forEach((el, i) => gsap.set(el, i === 0 ? large : small))\n      if (reduced || n < 2) return\n\n      const tl = gsap.timeline({\n        defaults: { ease: \"power2.inOut\", duration: 1 },\n        scrollTrigger: {\n          trigger: section,\n          scroller,\n          start: \"top top\",\n          end: () => `+=${section.offsetHeight * scrollPerImage * (n - 1)}`,\n          pin: true,\n          scrub: scrub || true,\n          invalidateOnRefresh: true,\n          onUpdate: (self) => setActive(Math.round(self.progress * (n - 1))),\n        },\n      })\n\n      // Each step: the current image shrinks back while the next one grows\n      for (let i = 0; i < n - 1; i++) {\n        tl.to(items[i], small, i).to(items[i + 1], large, i)\n      }\n    },\n    {\n      scope: sectionRef,\n      dependencies: [images, smallWidth, smallAspect, largeWidth, largeHeight, scrollPerImage, scrub, scroller, reduced],\n      revertOnUpdate: true,\n    }\n  )\n\n  return (\n    <section\n      ref={sectionRef}\n      className={cn(\"relative flex w-full items-end overflow-hidden px-[6%] pb-[8%]\", className)}\n      style={{ height }}\n    >\n      {counter && n > 0 && (\n        <p className=\"absolute left-[6%] top-[10%] font-mono text-[11px] tabular-nums tracking-wider opacity-70\">\n          {String(active + 1).padStart(2, \"0\")} / {String(n).padStart(2, \"0\")}\n        </p>\n      )}\n      <div\n        className={cn(\"flex w-full items-end\", align === \"center\" ? \"justify-center\" : \"justify-start\")}\n        style={{ gap }}\n      >\n        {images.map((img, i) => (\n          <div\n            key={i}\n            data-expand-item\n            className=\"shrink-0 overflow-hidden\"\n            style={{ background: tint(i), width: `${smallWidth}%`, aspectRatio: smallAspect }}\n          >\n            <img src={img.src} alt={img.alt} onError={hideBroken} draggable={false} className=\"size-full object-cover\" />\n          </div>\n        ))}\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "docs": "Docs, live playground and every prop: https://trytweenly.vercel.app/docs/components/expand-gallery",
  "type": "registry:component"
}