{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sticky-scroll-story",
  "type": "registry:ui",
  "title": "Sticky Scroll Storytelling",
  "author": "Rishabh Bose <https://theb0se.vercel.app/>",
  "description": "Pinned split-screen storytelling layout where scrolling through text chapters on the left animates the sticky media stage on the right in real time.",
  "dependencies": [
    "framer-motion",
    "lucide-react",
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "components/ui/sticky-scroll-story.tsx",
      "content": "\"use client\";\n\nimport React, { useState, useRef } from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"framer-motion\";\nimport { Layers, Shield, Zap, Sparkles } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface StorySection {\n  id: string;\n  badge: string;\n  title: string;\n  description: string;\n  metricLabel: string;\n  metricValue: string;\n}\n\nexport interface StickyScrollStoryProps {\n  /** Array of storytelling chapters */\n  sections?: StorySection[];\n  /** Optional header title above the storytelling container */\n  heading?: string;\n  className?: string;\n}\n\nconst DEFAULT_SECTIONS: StorySection[] = [\n  {\n    id: \"design\",\n    badge: \"01 · Design System\",\n    title: \"Machined from a single block of tokens.\",\n    description:\n      \"Every border, surface, and shadow shares a unified monochrome scale that adapts seamlessly between daylight and OLED dark mode.\",\n    metricLabel: \"Contrast Ratio\",\n    metricValue: \"18.4 : 1 AAA\",\n  },\n  {\n    id: \"motion\",\n    badge: \"02 · Spring Physics\",\n    title: \"Interruptible motion that respects momentum.\",\n    description:\n      \"Unlike fixed-duration CSS curves, spring animations preserve velocity when redirected mid-flight for natural tactile feedback.\",\n    metricLabel: \"Response Latency\",\n    metricValue: \"< 1.2 ms\",\n  },\n  {\n    id: \"shipping\",\n    badge: \"03 · Zero Lock-In\",\n    title: \"Own every line of code in your repository.\",\n    description:\n      \"Install via CLI or copy the TypeScript file directly. No black-box npm wrapper, no CSS conflicts, and full control over markup.\",\n    metricLabel: \"Runtime Overhead\",\n    metricValue: \"0 KB External\",\n  },\n];\n\nexport function StickyScrollStory({\n  sections = DEFAULT_SECTIONS,\n  heading = \"Scroll inside the container or click any chapter\",\n  className,\n}: StickyScrollStoryProps) {\n  const shouldReduceMotion = useReducedMotion() ?? false;\n  const [activeIndex, setActiveIndex] = useState(0);\n  const scrollContainerRef = useRef<HTMLDivElement>(null);\n\n  const handleScroll = (e: React.UIEvent<HTMLDivElement>) => {\n    const el = e.currentTarget;\n    const maxScroll = el.scrollHeight - el.clientHeight;\n    if (maxScroll <= 0) return;\n    const progress = el.scrollTop / maxScroll;\n    const idx = Math.min(\n      sections.length - 1,\n      Math.max(0, Math.round(progress * (sections.length - 1)))\n    );\n    if (idx !== activeIndex) {\n      setActiveIndex(idx);\n    }\n  };\n\n  const scrollToChapter = (index: number) => {\n    setActiveIndex(index);\n    const el = scrollContainerRef.current;\n    if (!el) return;\n    const maxScroll = el.scrollHeight - el.clientHeight;\n    const targetTop =\n      sections.length > 1 ? (index / (sections.length - 1)) * maxScroll : 0;\n    el.scrollTo({ top: targetTop, behavior: \"smooth\" });\n  };\n\n  const activeSection = sections[activeIndex] ?? sections[0];\n\n  const icons = [\n    <Layers key=\"layers\" className=\"h-5 w-5\" />,\n    <Zap key=\"zap\" className=\"h-5 w-5\" />,\n    <Shield key=\"shield\" className=\"h-5 w-5\" />,\n    <Sparkles key=\"sparkles\" className=\"h-5 w-5\" />,\n  ];\n\n  return (\n    <div\n      className={cn(\n        \"w-full max-w-2xl overflow-hidden rounded-3xl border border-neutral-200 bg-white shadow-sm dark:border-neutral-800 dark:bg-[#0A0A0A]\",\n        className\n      )}\n    >\n      {/* Top Status Bar */}\n      <div className=\"flex items-center justify-between border-b border-neutral-200 bg-neutral-50/70 px-5 py-2.5 dark:border-neutral-800 dark:bg-neutral-900/50\">\n        <span className=\"font-mono text-[11px] text-neutral-500 dark:text-neutral-400\">\n          {heading}\n        </span>\n        <div className=\"flex items-center gap-1.5\">\n          {sections.map((sec, idx) => (\n            <button\n              key={sec.id}\n              type=\"button\"\n              aria-label={`Jump to chapter ${idx + 1}`}\n              onClick={() => scrollToChapter(idx)}\n              className={cn(\n                \"h-1.5 rounded-full transition-all\",\n                idx === activeIndex\n                  ? \"w-5 bg-neutral-900 dark:bg-white\"\n                  : \"w-1.5 bg-neutral-300 hover:bg-neutral-400 dark:bg-neutral-700\"\n              )}\n            />\n          ))}\n        </div>\n      </div>\n\n      {/* Split Scrollable Text + Sticky Synced Media */}\n      <div\n        ref={scrollContainerRef}\n        data-fullscreen-scroll\n        onScroll={handleScroll}\n        className=\"grid max-h-[340px] grid-cols-1 gap-6 overflow-y-auto p-6 sm:grid-cols-12\"\n      >\n        {/* Left Scrolling Chapters */}\n        <div className=\"space-y-24 py-6 pb-28 sm:col-span-7\">\n          {sections.map((section, idx) => {\n            const isActive = idx === activeIndex;\n            return (\n              <div\n                key={section.id}\n                onClick={() => scrollToChapter(idx)}\n                className={cn(\n                  \"cursor-pointer rounded-2xl p-4 transition-all duration-300\",\n                  isActive\n                    ? \"bg-neutral-100/80 opacity-100 dark:bg-neutral-900/80\"\n                    : \"opacity-40 hover:opacity-70\"\n                )}\n              >\n                <span className=\"font-mono text-[11px] font-semibold uppercase tracking-wider text-neutral-500 dark:text-neutral-400\">\n                  {section.badge}\n                </span>\n                <h3 className=\"mt-1.5 text-base font-bold tracking-tight text-neutral-950 dark:text-white sm:text-lg\">\n                  {section.title}\n                </h3>\n                <p className=\"mt-2 text-xs leading-relaxed text-neutral-600 dark:text-neutral-400\">\n                  {section.description}\n                </p>\n              </div>\n            );\n          })}\n        </div>\n\n        {/* Right Sticky Media Stage */}\n        <div className=\"sm:col-span-5\">\n          <div className=\"sticky top-2 flex h-[240px] flex-col justify-between overflow-hidden rounded-2xl border border-neutral-200 bg-neutral-50 p-5 dark:border-neutral-800 dark:bg-[#111111]\">\n            <AnimatePresence mode=\"wait\">\n              <motion.div\n                key={activeSection.id}\n                initial={\n                  shouldReduceMotion\n                    ? { opacity: 0 }\n                    : { opacity: 0, y: 14, scale: 0.96 }\n                }\n                animate={{ opacity: 1, y: 0, scale: 1 }}\n                exit={\n                  shouldReduceMotion\n                    ? { opacity: 0 }\n                    : { opacity: 0, y: -14, scale: 0.96 }\n                }\n                transition={{ type: \"spring\", stiffness: 360, damping: 28 }}\n                className=\"flex h-full flex-col justify-between\"\n              >\n                <div className=\"flex items-center justify-between\">\n                  <div className=\"flex h-10 w-10 items-center justify-center rounded-xl bg-neutral-900 text-white dark:bg-white dark:text-black\">\n                    {icons[activeIndex % icons.length]}\n                  </div>\n                  <span className=\"rounded-full border border-neutral-200 bg-white px-2.5 py-0.5 font-mono text-[10px] font-semibold text-neutral-600 dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-300\">\n                    Step {activeIndex + 1}/{sections.length}\n                  </span>\n                </div>\n\n                {/* Center Visual Graphic */}\n                <div className=\"my-auto rounded-xl border border-neutral-200/80 bg-white p-3.5 shadow-2xs dark:border-neutral-800 dark:bg-[#0A0A0A]\">\n                  <div className=\"font-mono text-[10px] uppercase tracking-wider text-neutral-400\">\n                    {activeSection.metricLabel}\n                  </div>\n                  <div className=\"mt-1 font-mono text-lg font-bold tracking-tight text-neutral-950 dark:text-white\">\n                    {activeSection.metricValue}\n                  </div>\n                  <div className=\"mt-2.5 h-1.5 w-full overflow-hidden rounded-full bg-neutral-100 dark:bg-neutral-900\">\n                    <motion.div\n                      initial={{ width: \"20%\" }}\n                      animate={{\n                        width: `${((activeIndex + 1) / sections.length) * 100}%`,\n                      }}\n                      transition={{ type: \"spring\", stiffness: 300, damping: 28 }}\n                      className=\"h-full rounded-full bg-neutral-900 dark:bg-white\"\n                    />\n                  </div>\n                </div>\n\n                <div className=\"font-mono text-[10px] text-neutral-400\">\n                  Synced Sticky Stage\n                </div>\n              </motion.div>\n            </AnimatePresence>\n          </div>\n        </div>\n      </div>\n    </div>\n  );\n}\n\nexport default StickyScrollStory;\n",
      "type": "registry:ui",
      "target": "components/ui/sticky-scroll-story.tsx"
    },
    {
      "path": "lib/utils.ts",
      "content": "import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nexport async function copyToClipboard(text: string): Promise<boolean> {\n  if (typeof window === \"undefined\") return false;\n\n  try {\n    if (navigator.clipboard && window.isSecureContext) {\n      await navigator.clipboard.writeText(text);\n      return true;\n    }\n\n    const textArea = document.createElement(\"textarea\");\n    textArea.value = text;\n    textArea.style.position = \"fixed\";\n    textArea.style.left = \"-999999px\";\n    textArea.style.top = \"-999999px\";\n    document.body.appendChild(textArea);\n    textArea.focus();\n    textArea.select();\n    const succeeded = document.execCommand(\"copy\");\n    textArea.remove();\n    return succeeded;\n  } catch {\n    return false;\n  }\n}\n",
      "type": "registry:lib",
      "target": "lib/utils.ts"
    }
  ]
}
