{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "pinned-feature-tour",
  "type": "registry:block",
  "title": "Pinned Feature Tour",
  "description": "A section pinned under your header while three features take turns, each with a line drawing that inks itself as the pin moves on.",
  "dependencies": [
    "svg-scroll-draw@^2.20.0"
  ],
  "files": [
    {
      "path": "registry/blocks/pinned-feature-tour.tsx",
      "content": "'use client';\n\n/**\n * pinned-feature-tour — a section that pins just below your sticky header while\n * its features take turns. Each feature has a line drawing that inks itself in\n * as the reader scrolls through that feature's share of the pin, and its copy\n * steps forward in the list beside it.\n *\n * Built on svg-scroll-draw (MIT): https://svg-scroll-draw.vercel.app/blocks\n * Needs: react, svg-scroll-draw. Styling: Tailwind CSS.\n *\n * Uses `scrollPin` (svg-scroll-draw/pin) to hold the stage still and\n * `scrollDraw` (svg-scroll-draw) for the drawings. The drawings follow the\n * pin's `onProgress` through `seek()`, not their own place on the page. Unlike\n * sticky-feature, nothing scrolls past: the whole stage stays put for\n * (features − 1) screens of scroll and the features change in place.\n *\n * Props: `eyebrow` and `heading` for the intro above the tour; `features`, each\n * a title, a body and the path `d` strings of its drawing in a 200 × 160 box;\n * `headerOffset`, the height in px of your sticky header (0 if you have none);\n * `className` for the outer section.\n *\n * While pinned the stage is `position: fixed`. An ancestor with a transform,\n * filter, perspective or `contain: paint` makes fixed relative to itself, so\n * keep the block out of one. The page must scroll on the window. The pin's\n * length is measured once, on mount, so a phone's URL bar showing and hiding\n * never changes it; after a rotation the tour keeps its first length.\n *\n * Reduced motion: the library shows every drawing finished and `seek()` does\n * nothing; this file turns off the cross-fades. The pin and the switching keep\n * working, because pinning holds the content still rather than moving it.\n */\n\nimport { useEffect, useRef, useState, type CSSProperties } from 'react';\nimport { scrollDraw } from 'svg-scroll-draw';\nimport { scrollPin } from 'svg-scroll-draw/pin';\n\nexport interface TourFeature {\n  title: string;\n  body: string;\n  /** Path `d` strings in a 200 × 160 box, drawn together as the reader scrolls through this feature. */\n  art: string[];\n}\n\nexport interface PinnedFeatureTourProps {\n  eyebrow?: string;\n  heading?: string;\n  features?: TourFeature[];\n  /** Height in px of your sticky header: the tour pins just below it. 0 if you have none. */\n  headerOffset?: number;\n  className?: string;\n}\n\nconst DEFAULT_FEATURES: TourFeature[] = [\n  {\n    title: 'From three farms',\n    body: 'A washed lot from Ethiopia, a honey lot from Costa Rica and a natural from Colombia, bought direct from the people who grow them.',\n    // Two hills, a row of coffee bushes and the sun.\n    art: [\n      'M 8 112 C 44 84 78 88 104 98 S 160 80 192 92',\n      'M 8 138 C 58 116 122 132 192 120',\n      'M 30 104 q 7 -11 14 0 q 7 -11 14 0 q 7 -11 14 0 q 7 -11 14 0',\n      'M 150 26 A 16 16 0 1 1 150 58 A 16 16 0 1 1 150 26',\n    ],\n  },\n  {\n    title: 'Roasted on Tuesday',\n    body: 'Small batches every Tuesday morning, so the bag you open was roasted days ago, not months.',\n    // A drum roaster on its legs, with its chimney and the flame under it.\n    art: [\n      'M 64 46 H 136 A 32 32 0 0 1 136 110 H 64 A 32 32 0 0 1 64 46 Z',\n      'M 100 62 A 16 16 0 1 1 100 94 A 16 16 0 1 1 100 62',\n      'M 120 46 V 24 H 132 V 46',\n      'M 70 110 V 128 M 130 110 V 128',\n      'M 100 152 C 88 142 92 132 100 124 C 108 132 112 142 100 152 Z',\n    ],\n  },\n  {\n    title: 'At your door in two days',\n    body: 'Packed the morning after roasting and shipped free on orders over $40, in bags you can compost.',\n    // A parcel, its tape and two speed lines.\n    art: [\n      'M 50 62 L 100 42 L 150 62 L 150 118 L 100 138 L 50 118 Z',\n      'M 50 62 L 100 82 L 150 62 M 100 82 V 138',\n      'M 76 52 L 126 72',\n      'M 18 96 H 38 M 24 110 H 40',\n    ],\n  },\n];\n\n/*\n * Where three features would not fit on the pinned stage (phones, and screens\n * too short for the list) only the current one is shown. While pinned, whatever\n * does not fit can never be scrolled to. The others stay in the page for screen\n * readers: sr-only, not display: none.\n */\nconst COMPACT_HIDE = 'max-md:sr-only [@media(max-height:640px)]:sr-only';\nconst COMPACT_SHOW = 'hidden max-md:inline [@media(max-height:640px)]:inline';\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n\nexport function PinnedFeatureTour({\n  eyebrow = 'How it works',\n  heading = 'From the farm to your door in a week',\n  features = DEFAULT_FEATURES,\n  headerOffset = 64,\n  className = '',\n}: PinnedFeatureTourProps) {\n  const stageRef = useRef<HTMLDivElement>(null);\n  const [active, setActive] = useState(0);\n  const current = Math.min(active, features.length - 1);\n  // Rebuild the drawings and the pin when the art changes, not on every new array.\n  const artKey = features.map((f) => f.art.join(' ')).join('\\n');\n\n  useEffect(() => {\n    const stage = stageRef.current;\n    if (!stage) return;\n    const arts = Array.from(stage.querySelectorAll<SVGSVGElement>('[data-tour-art]'));\n    const n = arts.length;\n    if (!n) return;\n\n    // One drawing per feature, moved by the pin rather than by its own position.\n    // Each starts empty: the first one draws once the stage has pinned.\n    const drawings = arts.map((svg) => scrollDraw(svg));\n    drawings.forEach((d) => d.seek(0));\n\n    const pin = scrollPin(stage, {\n      top: headerOffset,\n      // n − 1 screens of scroll: three features get two-thirds of a screen each.\n      // One feature still gets one screen: a pin of 0 has no progress to report.\n      // vh is CSS's vh (svg-scroll-draw 2.20.0+): a rotation re-measures it,\n      // the URL bar showing and hiding does not, so the tour never stretches\n      // under the reader's thumb.\n      pinDistance: `${Math.max(1, n - 1) * 100}vh`,\n      // 0 where the pin starts, 1 where it ends. Cut into n equal shares: the\n      // feature whose share the reader is in is current; earlier drawings are\n      // finished, later ones empty, the current one as far as its share.\n      onProgress: (p) => {\n        const i = Math.min(n - 1, Math.floor(p * n));\n        setActive(i);\n        drawings.forEach((d, j) => d.seek(j < i ? 1 : j > i ? 0 : p * n - i));\n      },\n    });\n\n    // StrictMode mounts effects twice in development: destroy() puts the stage\n    // back where it was and restores its styles, so the second run starts clean.\n    return () => {\n      pin.destroy();\n      drawings.forEach((d) => d.destroy());\n    };\n  }, [artKey, headerOffset]);\n\n  return (\n    <section className={`mx-auto w-full max-w-5xl ${className}`}>\n      <p className=\"font-mono text-xs text-neutral-600 dark:text-neutral-400\">\n        {eyebrow}\n      </p>\n      <h2 className=\"mt-3 text-3xl font-medium tracking-tight text-neutral-950 sm:text-4xl dark:text-neutral-50\">\n        {heading}\n      </h2>\n\n      {/* scrollPin moves the stage into a wrapper div of its own. So the stage is\n          not this component's root (React removes its root from where it put it),\n          and it is the only child of this div, so React never has to insert a\n          node beside it. Style the stage by its own classes, never by its parent. */}\n      <div className=\"mt-10\">\n        {/* One screen below the header, from the same number the pin uses.\n            100svh where supported, so the phone's toolbars never cover the bottom. */}\n        <div\n          ref={stageRef}\n          style={{ '--tour-header': `${headerOffset}px` } as CSSProperties}\n          className=\"box-border h-[calc(100vh_-_var(--tour-header))] py-4 supports-[height:100svh]:h-[calc(100svh_-_var(--tour-header))] md:py-6\"\n        >\n          <div className=\"grid h-full grid-cols-1 content-center items-center gap-6 md:grid-cols-2 md:grid-rows-[minmax(0,1fr)] md:gap-12\">\n            {/* The drawings, stacked: only the current one is shown. Keyed by\n                position, not title: the effect holds these nodes and only rebuilds\n                when the art changes, so a renamed feature must keep its svg. */}\n            <div className=\"relative mx-auto aspect-[5/4] w-full max-w-[280px] rounded-3xl border border-neutral-200 bg-white text-neutral-900 md:max-h-full md:max-w-none dark:border-neutral-800 dark:bg-neutral-950 dark:text-neutral-100\">\n              {features.map((f, i) => (\n                <svg\n                  key={i}\n                  data-tour-art=\"\"\n                  data-on={i === current || undefined}\n                  viewBox=\"0 0 200 160\"\n                  fill=\"none\"\n                  stroke=\"currentColor\"\n                  strokeWidth={2}\n                  strokeLinecap=\"round\"\n                  strokeLinejoin=\"round\"\n                  aria-hidden=\"true\"\n                  className=\"absolute left-[8%] top-[8%] h-[84%] w-[84%] overflow-visible opacity-0 transition-opacity duration-300 motion-reduce:transition-none data-[on]:opacity-100\"\n                >\n                  {f.art.map((d, j) => (\n                    <path key={j} d={d} />\n                  ))}\n                </svg>\n              ))}\n            </div>\n\n            <ol className=\"grid gap-7\">\n              {features.map((f, i) => (\n                <li\n                  key={f.title}\n                  aria-current={i === current ? 'step' : undefined}\n                  // Not the current feature: greyed by colour, not opacity, so every feature keeps WCAG AA contrast (at 35% opacity the text measured about 2:1).\n                  className={`transition-colors duration-300 motion-reduce:transition-none ${\n                    i === current ? '' : COMPACT_HIDE\n                  }`}\n                >\n                  <span className=\"flex items-center gap-2 font-mono text-xs\">\n                    <span className={`inline-flex h-7 w-7 items-center justify-center rounded-full font-medium transition-colors duration-300 motion-reduce:transition-none ${i === current ? 'bg-[#ff90e8] text-neutral-950' : 'bg-neutral-200 text-neutral-700 dark:bg-neutral-800 dark:text-neutral-300'}`}>\n                      {pad(i + 1)}\n                    </span>\n                    {/* With one feature on screen, say how many there are. */}\n                    <span aria-hidden=\"true\" className={`${COMPACT_SHOW} text-neutral-600 dark:text-neutral-400`}>\n                      of {pad(features.length)}\n                    </span>\n                  </span>\n                  <h3 className={`mt-3 text-2xl font-semibold leading-tight ${i === current ? 'text-neutral-950 dark:text-neutral-50' : 'text-neutral-600 dark:text-neutral-400'}`}>\n                    {f.title}\n                  </h3>\n                  <p className={`mt-1.5 max-w-[36ch] leading-relaxed ${i === current ? 'text-neutral-600 dark:text-neutral-300' : 'text-neutral-600 dark:text-neutral-400'}`}>{f.body}</p>\n                </li>\n              ))}\n            </ol>\n          </div>\n        </div>\n      </div>\n    </section>\n  );\n}\n\nexport default PinnedFeatureTour;\n",
      "type": "registry:component",
      "target": "components/scroll/pinned-feature-tour.tsx"
    }
  ],
  "categories": [
    "scroll",
    "svg",
    "pin"
  ]
}
