{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scroll-snap-sections",
  "title": "Scroll Snap Sections",
  "description": "Full-height sections that snap into place one at a time as you scroll, each sliding its eyebrow, title and text up while its photo unclips and settles, with a counter, a progress line and dot navigation.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/scroll-snap-sections/scroll-snap-sections.tsx",
      "content": "\"use client\";\n/* eslint-disable @next/next/no-img-element -- Registry components work in any React app. */\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport interface SnapSection {\n  id: string;\n  eyebrow?: string;\n  title: string;\n  text?: string;\n  image?: string;\n  imageAlt?: string;\n}\n\nexport interface ScrollSnapSectionsProps extends Omit<React.ComponentPropsWithoutRef<\"div\">, \"children\" | \"onChange\"> {\n  sections?: SnapSection[];\n  /** Height of the scroll area; every section fills it. */\n  height?: number | string;\n  showDots?: boolean;\n  theme?: \"dark\" | \"light\";\n  label?: string;\n  onChange?: (index: number, section: SnapSection) => void;\n}\n\nconst SECTIONS: SnapSection[] = [\n  { id: \"arrive\", eyebrow: \"01 — Arrive\", title: \"Leave the city at the door\", text: \"Stone floors, low light and nothing that asks for your attention.\", image: \"/demo/19.webp\" },\n  { id: \"rest\", eyebrow: \"02 — Rest\", title: \"Rooms built around a long sleep\", text: \"Linen, timber and windows that face the morning.\", image: \"/demo/2.webp\" },\n  { id: \"move\", eyebrow: \"03 — Move\", title: \"Mornings on the open road\", text: \"Bikes at reception, routes drawn by people who ride them.\", image: \"/demo/108.webp\" },\n  { id: \"meet\", eyebrow: \"04 — Meet\", title: \"A table for everyone you like\", text: \"One long dinner, every Friday, for guests and neighbours.\", image: \"/demo/38.webp\" },\n];\n\nfunction useReducedMotion() {\n  return React.useSyncExternalStore(\n    (callback) => {\n      const query = window.matchMedia(\"(prefers-reduced-motion: reduce)\");\n      query.addEventListener(\"change\", callback);\n      return () => query.removeEventListener(\"change\", callback);\n    },\n    () => window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches,\n    () => false,\n  );\n}\n\nexport function ScrollSnapSections({ sections = SECTIONS, height = 520, showDots = true, theme = \"dark\", label = \"Sections\", onChange, className, style, ...props }: ScrollSnapSectionsProps) {\n  const reduce = useReducedMotion();\n  const scrollerRef = React.useRef<HTMLDivElement>(null);\n  const [active, setActive] = React.useState(0);\n  const light = theme === \"light\";\n  const ink = light ? \"#141414\" : \"#f4f4f2\";\n  const muted = light ? \"#6b6b6b\" : \"#8f8f8f\";\n  const line = light ? \"#dcdcd8\" : \"#2a2a2a\";\n\n  // The section most in view is the active one.\n  React.useEffect(() => {\n    const root = scrollerRef.current;\n    if (!root) return;\n    const observer = new IntersectionObserver(\n      (entries) => {\n        for (const entry of entries) {\n          if (entry.isIntersecting && entry.intersectionRatio >= 0.55) {\n            const i = Number((entry.target as HTMLElement).dataset.index);\n            setActive(i);\n          }\n        }\n      },\n      { root, threshold: [0.55] },\n    );\n    root.querySelectorAll(\"[data-index]\").forEach((el) => observer.observe(el));\n    return () => observer.disconnect();\n  }, [sections.length]);\n\n  const prevActive = React.useRef(active);\n  React.useEffect(() => {\n    if (prevActive.current !== active && sections[active]) onChange?.(active, sections[active]);\n    prevActive.current = active;\n  }, [active, sections, onChange]);\n\n  const go = (i: number) => {\n    const root = scrollerRef.current;\n    const target = root?.querySelectorAll<HTMLElement>(\"[data-index]\")[Math.max(0, Math.min(sections.length - 1, i))];\n    if (root && target) root.scrollTo({ top: target.offsetTop, behavior: reduce ? \"auto\" : \"smooth\" });\n  };\n\n  const ease = \"cubic-bezier(.2,.8,.2,1)\";\n\n  return (\n    <div className={cn(\"relative w-full overflow-hidden\", className)} style={{ height, color: ink, background: light ? \"#f1f0ec\" : \"#0a0a0a\", ...style }} {...props}>\n      <div\n        ref={scrollerRef}\n        tabIndex={0}\n        role=\"region\"\n        aria-roledescription=\"scroll sections\"\n        aria-label={label}\n        className=\"h-full snap-y snap-mandatory overflow-y-auto overscroll-contain outline-none [scrollbar-width:none] focus-visible:ring-2 focus-visible:ring-inset [&::-webkit-scrollbar]:hidden\"\n        style={{ [\"--tw-ring-color\" as string]: ink }}\n        onKeyDown={(event) => {\n          const keys: Record<string, number> = { ArrowDown: 1, PageDown: 1, \" \": 1, ArrowUp: -1, PageUp: -1 };\n          if (event.key in keys) {\n            event.preventDefault();\n            go(active + (event.shiftKey && event.key === \" \" ? -1 : keys[event.key]));\n          } else if (event.key === \"Home\" || event.key === \"End\") {\n            event.preventDefault();\n            go(event.key === \"Home\" ? 0 : sections.length - 1);\n          }\n        }}\n      >\n        {sections.map((section, i) => {\n          const on = i === active;\n          const t = (delay: number) => (reduce ? \"none\" : `opacity 700ms ${ease} ${delay}ms, transform 900ms ${ease} ${delay}ms, clip-path 1000ms ${ease} ${delay}ms`);\n          return (\n            <section\n              key={section.id}\n              data-index={i}\n              aria-label={section.title}\n              className=\"relative grid h-full snap-start snap-always grid-cols-1 items-center gap-6 px-6 py-10 sm:grid-cols-[1.05fr_1fr] sm:gap-10 sm:px-12\"\n            >\n              <div className=\"relative z-10 min-w-0 sm:pr-4\">\n                {section.eyebrow && (\n                  <p className=\"font-mono text-[10.5px] tracking-[0.2em] uppercase\" style={{ color: muted, opacity: on ? 1 : 0, transform: on ? \"none\" : \"translateY(14px)\", transition: t(80) }}>\n                    {section.eyebrow}\n                  </p>\n                )}\n                <h2\n                  className=\"mt-4 max-w-[13ch] text-[34px] leading-[1.02] font-semibold tracking-[-0.035em] sm:text-[50px]\"\n                  style={{ opacity: on ? 1 : 0, transform: on ? \"none\" : \"translateY(28px)\", transition: t(160) }}\n                >\n                  {section.title}\n                </h2>\n                {section.text && (\n                  <p className=\"mt-4 max-w-[34ch] text-[14.5px] leading-relaxed\" style={{ color: muted, opacity: on ? 1 : 0, transform: on ? \"none\" : \"translateY(20px)\", transition: t(260) }}>\n                    {section.text}\n                  </p>\n                )}\n              </div>\n              {section.image && (\n                <div\n                  className=\"absolute inset-0 -z-0 overflow-hidden sm:relative sm:inset-auto sm:h-[78%] sm:rounded-[18px]\"\n                  style={{ clipPath: on ? \"inset(0% 0% 0% 0% round 18px)\" : \"inset(18% 12% 18% 12% round 18px)\", transition: t(0) }}\n                >\n                  <img\n                    src={section.image}\n                    alt={section.imageAlt ?? \"\"}\n                    draggable={false}\n                    className=\"h-full w-full object-cover opacity-35 sm:opacity-100\"\n                    style={{ transform: on ? \"scale(1)\" : \"scale(1.18)\", transition: t(0) }}\n                  />\n                </div>\n              )}\n            </section>\n          );\n        })}\n      </div>\n\n      {/* Counter and progress, top left. */}\n      <div aria-hidden=\"true\" className=\"pointer-events-none absolute top-5 left-6 flex items-center gap-3 font-mono text-[11px] tabular-nums sm:left-12\" style={{ color: muted }}>\n        <span style={{ color: ink }}>{String(active + 1).padStart(2, \"0\")}</span>\n        <span className=\"relative h-px w-14\" style={{ background: line }}>\n          <span className=\"absolute inset-y-0 left-0\" style={{ background: ink, width: `${((active + 1) / sections.length) * 100}%`, transition: reduce ? \"none\" : `width 600ms ${ease}` }} />\n        </span>\n        <span>{String(sections.length).padStart(2, \"0\")}</span>\n      </div>\n\n      {showDots && sections.length > 1 && (\n        <nav aria-label={`${label} navigation`} className=\"absolute top-1/2 right-3 flex -translate-y-1/2 flex-col gap-1 sm:right-5\">\n          {sections.map((section, i) => (\n            <button\n              key={section.id}\n              type=\"button\"\n              aria-label={`Go to ${section.title}`}\n              aria-current={i === active ? \"true\" : undefined}\n              onClick={() => go(i)}\n              className=\"flex size-6 cursor-pointer items-center justify-center rounded-full outline-none focus-visible:ring-2\"\n              style={{ [\"--tw-ring-color\" as string]: ink }}\n            >\n              <span className=\"block w-[3px] rounded-full\" style={{ height: i === active ? 18 : 6, background: i === active ? ink : muted, opacity: i === active ? 1 : 0.6, transition: reduce ? \"none\" : `height 400ms ${ease}` }} />\n            </button>\n          ))}\n        </nav>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}