{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "ink-frame",
  "title": "Ink frame",
  "description": "A border a pen draws round any children: rect or rounded (twice round, ink then accent), double, or crop marks at the corners.",
  "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-frame.tsx",
      "content": "'use client';\n\n/**\n * ink-frame — a border a pen draws round anything: a card, a figure, an\n * image, a quote. `rect` and `rounded` go round twice, ink then accent, never\n * quite on the same line; `double` draws a second, finer frame inside the\n * first; `corner-marks` sets crop marks at the corners, as on a proof.\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. The frame draws on the box's edge: give the box its\n * own padding (and a `bg-card` if it should read as a sheet).\n *\n * What it frames is in the server HTML; the frame is made in the browser at\n * the size it finds, and made again when that changes. Reduced motion shows\n * it drawn.\n */\n\nimport { useRef, type ReactNode } from 'react';\nimport 'svg-scroll-draw/no-flash.css';\nimport { cropMarks, sketchRect, type Stroke } from '@/lib/plotter';\nimport { useInk, useSize, type InkTrigger } from '@/lib/ink';\n\nexport type InkFrameVariant = 'rect' | 'rounded' | 'double' | 'corner-marks';\n\nexport interface InkFrameProps {\n  children: ReactNode;\n  variant?: InkFrameVariant;\n  /** The ink's colour. */\n  color?: string;\n  /** The accent pen's colour (the second pass, the inner frame). */\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\n/** How far the drawing reaches past the box on each side, so strokes on its edge are not cut. */\nconst BLEED = 10;\n\ntype Placed = Stroke & { at: number };\n\nfunction strokesFor(variant: InkFrameVariant, w: number, h: number, seed: number): Placed[] {\n  // Each frame is drawn in its own box, moved `at` px in from the drawing's corner.\n  const place = (s: Stroke[], at: number) => s.map((k) => ({ ...k, at }));\n  switch (variant) {\n    case 'rect':\n      return place(sketchRect({ w: w + 4, h: h + 4, seed, wobble: 1.3, r: 3 }), BLEED - 2);\n    case 'rounded':\n      return place(sketchRect({ w: w + 4, h: h + 4, seed, wobble: 1.3, r: 16 }), BLEED - 2);\n    case 'double':\n      return [\n        ...place(sketchRect({ w: w + 4, h: h + 4, seed, wobble: 1.2, r: 3 }).slice(0, 1), BLEED - 2),\n        ...place(sketchRect({ w: w - 10, h: h - 10, seed: seed + 5, wobble: 0.9, r: 2 }).slice(0, 1).map((k) => ({ ...k, pen: 1 as const })), BLEED + 5),\n      ];\n    case 'corner-marks':\n      return place(cropMarks({ w: w + 2 * BLEED, h: h + 2 * BLEED, seed, len: Math.min(22, Math.max(10, Math.min(w, h) * 0.08)), inset: 2 }), 0);\n  }\n}\n\nexport function InkFrame({\n  children,\n  variant = 'rect',\n  color = 'currentColor',\n  accent = '#e0482a',\n  strokeWidth = 1.1,\n  seed = 1,\n  trigger = 'scroll',\n  duration = 1400,\n  className = '',\n}: InkFrameProps) {\n  const box = useRef<HTMLDivElement>(null);\n  const svg = useRef<SVGSVGElement>(null);\n  const size = useSize(box);\n  const strokes = size ? strokesFor(variant, size.w, size.h, seed) : null;\n  const n = strokes?.length ?? 0;\n  // The second pass follows the first; crop marks go down one corner after another.\n  useInk(svg, { paths: n, spread: n > 1 ? 0.5 : 0, trigger, duration, version: size && `${size.w}x${size.h}` });\n  return (\n    <div ref={box} className={`relative ${className}`}>\n      {children}\n      {size && strokes && (\n        <svg\n          ref={svg}\n          key={`${size.w}x${size.h}`}\n          data-scroll-draw-pending=\"\"\n          data-ink={trigger}\n          aria-hidden\n          width={size.w + 2 * BLEED}\n          height={size.h + 2 * BLEED}\n          viewBox={`0 0 ${size.w + 2 * BLEED} ${size.h + 2 * BLEED}`}\n          className=\"pointer-events-none absolute overflow-visible\"\n          style={{ left: -BLEED, top: -BLEED }}\n          fill=\"none\"\n          stroke={color}\n          strokeWidth={strokeWidth}\n          strokeLinecap=\"round\"\n          strokeLinejoin=\"round\"\n        >\n          {strokes.map((s, i) => <path key={i} d={s.d} transform={s.at ? `translate(${s.at} ${s.at})` : undefined} stroke={s.pen ? accent : undefined} strokeWidth={s.pen && variant === 'double' ? strokeWidth * 0.8 : undefined} />)}\n        </svg>\n      )}\n    </div>\n  );\n}\n",
      "type": "registry:ui",
      "target": "components/scrollfx/ink-frame.tsx"
    }
  ],
  "type": "registry:ui"
}