{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ink-divider",
  "title": "Ink divider",
  "description": "A rule a pen draws across the page: straight, wavy, sketchy (ink then accent), dotted, or two rules drawn outward from a label.",
  "dependencies": [
    "svg-scroll-draw@^2.29.0"
  ],
  "registryDependencies": [
    "https://scrollfx-ui.vercel.app/r/plotter.json",
    "https://scrollfx-ui.vercel.app/r/ink.json"
  ],
  "files": [
    {
      "path": "registry/ui/ink-divider.tsx",
      "content": "'use client';\n\n/**\n * ink-divider — a rule between sections that a pen draws across the page:\n * straight, wavy, sketchy (ruled twice, ink then accent), dotted, or a pair\n * of rules drawn outward from a label in the middle.\n *\n * Built on svg-scroll-draw (MIT): https://github.com/DhruvilChauahan0210/scrollfx\n * Needs: react, svg-scroll-draw, lib/plotter and lib/ink (installed with it).\n * Styling: Tailwind CSS with shadcn/ui tokens; it takes the width it is given.\n *\n * The label is in the server HTML; the rules are made in the browser at the\n * width they find, and made again when it changes. Reduced motion shows them\n * drawn.\n */\n\nimport { useEffect, useRef, useState } from 'react';\nimport 'svg-scroll-draw/no-flash.css';\nimport { inkDots, inkWave, ruledLine, sketchCircle, sketchLine, type Stroke } from '@/lib/plotter';\nimport { useInk, useSize, type InkTrigger } from '@/lib/ink';\n\nexport type InkDividerVariant = 'straight' | 'wavy' | 'sketchy' | 'dotted' | 'with-label';\n\nexport interface InkDividerProps {\n  variant?: InkDividerVariant;\n  /** The words in the middle, for `with-label`. */\n  label?: string;\n  /** The ink's colour. */\n  color?: string;\n  /** The accent pen's colour (the sketchy second pass, the label's dots). */\n  accent?: string;\n  strokeWidth?: number;\n  seed?: number;\n  /** `scroll`: drawn as it rises, done at mid-screen. `view`: played once as it comes into view. */\n  trigger?: InkTrigger;\n  /** With `view`, the drawing's length in ms. */\n  duration?: number;\n  className?: string;\n}\n\nconst H = 16;\n\nfunction strokesFor(variant: Exclude<InkDividerVariant, 'with-label'>, w: number, seed: number): Stroke[] {\n  switch (variant) {\n    case 'straight': return ruledLine({ w, h: H, seed });\n    case 'wavy': return inkWave({ w, h: H, seed, period: 34 });\n    case 'sketchy': return sketchLine({ w, h: H, seed, wobble: 0.8 });\n    case 'dotted': return inkDots({ w, h: H, seed, gap: 8 });\n  }\n}\n\n/** One rule, drawn across the box it is given. */\nfunction Rule({ make, color, accent, strokeWidth, trigger, duration, spread, dots }: { make: (w: number) => Stroke[]; color: string; accent: string; strokeWidth: number; trigger: InkTrigger; duration: number; spread: (n: number) => number; dots?: boolean }) {\n  const box = useRef<HTMLDivElement>(null);\n  const svg = useRef<SVGSVGElement>(null);\n  const size = useSize(box);\n  const strokes = size && size.w > 4 ? make(size.w) : null;\n  const n = strokes?.length ?? 0;\n  useInk(svg, { paths: n, spread: spread(n), trigger, duration, version: size?.w });\n  return (\n    <div ref={box} className=\"relative h-4 min-w-0 flex-1\">\n      {strokes && (\n        <svg ref={svg} key={size!.w} data-scroll-draw-pending=\"\" data-ink={trigger} aria-hidden width={size!.w} height={H} viewBox={`0 0 ${size!.w} ${H}`} className=\"absolute inset-0 block overflow-visible\" fill=\"none\" stroke={color} strokeWidth={dots ? strokeWidth * 1.7 : strokeWidth} strokeLinecap=\"round\" strokeLinejoin=\"round\">\n          {strokes.map((s, i) => <path key={i} d={s.d} stroke={s.pen ? accent : undefined} />)}\n        </svg>\n      )}\n    </div>\n  );\n}\n\nexport function InkDivider({\n  variant = 'straight',\n  label = 'Section',\n  color = 'currentColor',\n  accent = '#e0482a',\n  strokeWidth = 1.1,\n  seed = 1,\n  trigger = 'scroll',\n  duration = 1200,\n  className = '',\n}: InkDividerProps) {\n  const pen = { color, accent, strokeWidth, trigger, duration };\n  if (variant === 'with-label') {\n    // Two rules drawn outward from the label, both at once.\n    return (\n      <div role=\"separator\" aria-label={label} className={`flex items-center gap-3 ${className}`}>\n        <Rule {...pen} make={(w) => ruledLine({ w, h: H, seed, reverse: true })} spread={() => 0} />\n        <Dot {...pen} seed={seed + 1} />\n        <span className=\"shrink-0 px-1 font-mono text-[11px] uppercase tracking-[0.22em] text-muted-foreground\">{label}</span>\n        <Dot {...pen} seed={seed + 2} />\n        <Rule {...pen} make={(w) => ruledLine({ w, h: H, seed: seed + 3 })} spread={() => 0} />\n      </div>\n    );\n  }\n  return (\n    <div role=\"separator\" className={`flex ${className}`}>\n      <Rule\n        {...pen}\n        make={(w) => strokesFor(variant, w, seed)}\n        // Dots go down one after another, left to right; the sketchy rule's second pass follows the first.\n        spread={(n) => (variant === 'dotted' ? 1 : variant === 'sketchy' ? 0.5 : 0) * (n > 1 ? 1 : 0)}\n        dots={variant === 'dotted'}\n      />\n    </div>\n  );\n}\n\n/** A small ring in the accent pen beside the label. */\nfunction Dot({ accent, strokeWidth, trigger, duration, seed }: { accent: string; strokeWidth: number; trigger: InkTrigger; duration: number; seed: number }) {\n  const svg = useRef<SVGSVGElement>(null);\n  const [strokes, setStrokes] = useState<Stroke[]>([]);\n  useEffect(() => setStrokes(sketchCircle({ size: 10, seed, r: 2.6 })), [seed]);\n  useInk(svg, { paths: strokes.length, trigger, duration: duration * 0.4, version: strokes });\n  return (\n    <svg ref={svg} data-scroll-draw-pending=\"\" data-ink={trigger} aria-hidden width=\"10\" height=\"10\" viewBox=\"0 0 10 10\" className=\"shrink-0 overflow-visible\" fill=\"none\" stroke={accent} strokeWidth={strokeWidth * 1.2} strokeLinecap=\"round\">\n      {strokes.map((s, i) => <path key={i} d={s.d} />)}\n    </svg>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/scrollfx/ink-divider.tsx"
    }
  ],
  "type": "registry:ui"
}