{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "film-strip",
  "title": "Film Strip",
  "author": "VenusUI",
  "description": "A strip of 35mm negatives; picking a frame develops it into a print above the strip.",
  "files": [
    {
      "path": "registry/default/ui/film-strip.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nexport interface FilmFrame {\n  src: string\n  alt: string\n  caption?: string\n}\n\ninterface FilmStripProps extends Omit<React.ComponentProps<\"div\">, \"onSelect\"> {\n  frames: FilmFrame[]\n  defaultIndex?: number\n  /** Printed along the film edge. */\n  stock?: string\n  onSelect?: (index: number) => void\n}\n\nconst SPROCKETS =\n  \"repeating-linear-gradient(90deg, transparent 0 7px, #efe9dc 7px 17px, transparent 17px 24px)\"\n\n/**\n * A strip of 35mm negatives. Frames stay negative until you pick one, which\n * develops it into the print above. Drag or scroll along the strip, or use\n * the arrow keys.\n */\nfunction FilmStrip({ frames, defaultIndex = 0, stock = \"SAFETY FILM 400\", onSelect, className, ...props }: FilmStripProps) {\n  const [index, setIndex] = React.useState(defaultIndex)\n  const scroller = React.useRef<HTMLDivElement>(null)\n  const drag = React.useRef<{ x: number; left: number; moved: boolean } | null>(null)\n  const suppressClick = React.useRef(false)\n  const current = frames[index]\n\n  const select = (next: number, focus = false) => {\n    const box = scroller.current\n    const button = box?.querySelectorAll<HTMLButtonElement>(\"button\")[next]\n    setIndex(next)\n    onSelect?.(next)\n    if (!box || !button) return\n    if (focus) button.focus({ preventScroll: true })\n    const reduced = window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n    box.scrollTo({ left: button.offsetLeft - (box.clientWidth - button.offsetWidth) / 2, behavior: reduced ? \"auto\" : \"smooth\" })\n  }\n\n  return (\n    <div data-slot=\"film-strip\" className={cn(\"w-full max-w-2xl\", className)} {...props}>\n      <figure className=\"mx-auto mb-5 w-full max-w-md bg-white p-2.5 pb-3 text-neutral-700 shadow-[0_14px_34px_-14px_rgb(0_0_0/0.5)] ring-1 ring-black/5\">\n        <img key={current.src} src={current.src} alt={current.alt} draggable={false} className=\"aspect-[3/2] w-full bg-neutral-200 object-cover\" />\n        <figcaption aria-live=\"polite\" className=\"mt-2.5 flex items-baseline justify-between gap-3 font-mono text-[11px]\">\n          <span className=\"truncate\">{current.caption ?? current.alt}</span>\n          <span className=\"shrink-0 text-neutral-500 tabular-nums\">\n            {index + 1}/{frames.length}\n          </span>\n        </figcaption>\n      </figure>\n\n      <div\n        ref={scroller}\n        role=\"group\"\n        aria-label=\"Film frames\"\n        onPointerDown={(event) => {\n          if (event.pointerType !== \"mouse\" || !scroller.current) return\n          drag.current = { x: event.clientX, left: scroller.current.scrollLeft, moved: false }\n        }}\n        onPointerMove={(event) => {\n          const state = drag.current\n          const box = scroller.current\n          if (!state || !box) return\n          const distance = event.clientX - state.x\n          if (Math.abs(distance) > 4) state.moved = true\n          box.scrollLeft = state.left - distance\n        }}\n        onPointerUp={() => {\n          suppressClick.current = drag.current?.moved ?? false\n          drag.current = null\n        }}\n        onPointerLeave={() => {\n          drag.current = null\n        }}\n        onKeyDown={(event) => {\n          const step = event.key === \"ArrowRight\" ? 1 : event.key === \"ArrowLeft\" ? -1 : 0\n          if (!step) return\n          event.preventDefault()\n          select((index + step + frames.length) % frames.length, true)\n        }}\n        className=\"relative cursor-grab overflow-x-auto rounded-sm bg-[#1b1512] [scrollbar-width:none] select-none active:cursor-grabbing [&::-webkit-scrollbar]:hidden\"\n      >\n        <div className=\"w-max\">\n          <div aria-hidden=\"true\" className=\"h-2.5 w-full\" style={{ backgroundImage: SPROCKETS, backgroundClip: \"content-box\", paddingBlock: 2 }} />\n          <div aria-hidden=\"true\" className=\"flex gap-28 px-3 font-mono text-[8px] tracking-widest whitespace-nowrap text-amber-500/80\">\n            {frames.map((frame, i) => (\n              <span key={frame.src}>\n                {stock} {i + 1}A\n              </span>\n            ))}\n          </div>\n          <div className=\"flex gap-1.5 px-1.5 py-1\">\n            {frames.map((frame, i) => {\n              const active = i === index\n              return (\n                <button\n                  key={frame.src}\n                  type=\"button\"\n                  tabIndex={active ? 0 : -1}\n                  aria-pressed={active}\n                  aria-label={`Frame ${i + 1}: ${frame.alt}`}\n                  onClick={() => {\n                    if (suppressClick.current) suppressClick.current = false\n                    else select(i)\n                  }}\n                  className=\"group relative h-20 w-28 shrink-0 overflow-hidden rounded-[3px] outline-none focus-visible:ring-2 focus-visible:ring-amber-400 sm:h-24 sm:w-36\"\n                >\n                  <img\n                    src={frame.src}\n                    alt=\"\"\n                    draggable={false}\n                    loading=\"lazy\"\n                    className={cn(\n                      \"size-full object-cover transition-[filter] duration-500 motion-reduce:transition-none\",\n                      active ? \"\" : \"[filter:invert(1)_hue-rotate(180deg)_sepia(0.45)_contrast(0.8)] group-hover:[filter:invert(0.75)_hue-rotate(180deg)_sepia(0.2)]\"\n                    )}\n                  />\n                </button>\n              )\n            })}\n          </div>\n          <div aria-hidden=\"true\" className=\"h-2.5 w-full\" style={{ backgroundImage: SPROCKETS, backgroundClip: \"content-box\", paddingBlock: 2 }} />\n        </div>\n      </div>\n    </div>\n  )\n}\n\nexport { FilmStrip }\n",
      "type": "registry:ui"
    }
  ],
  "meta": {
    "version": "0.1.0"
  },
  "categories": [
    "interactive",
    "cards"
  ],
  "type": "registry:ui"
}