{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "thread-mark",
  "type": "registry:ui",
  "title": "Thread Mark",
  "description": "Interlace's thread, drawn as a state. Where a generic kit reaches for a spinner, an empty-box icon and a red warning triangle, Interlace says the same things with its one motif:",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "feedback",
    "primitive"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/thread-mark.tsx",
      "target": "components/ui/thread-mark.tsx",
      "type": "registry:ui",
      "content": "import * as React from 'react';\n\n// @interlace/thread-mark v1.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/thread-mark\n// What changed since: https://ds.interlace.tools/c/thread-mark#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — ThreadMark\n *\n * Interlace's thread, drawn as a state. Where a generic kit reaches for a\n * spinner, an empty-box icon and a red warning triangle, Interlace says the\n * same things with its one motif:\n *\n * | `state`   | What the thread does                            | Use it for                   |\n * | --------- | ----------------------------------------------- | ---------------------------- |\n * | `woven`   | Two strands cross twice, knotted at each end    | Done, connected, verified    |\n * | `drawing` | The woven pair draws in, over and over          | Loading, working             |\n * | `loose`   | One strand leaves a knot and trails off, untied | Empty: nothing woven yet     |\n * | `cut`     | One strand, snapped: two halves that never meet | Error: the thread was broken |\n *\n * `--strand-b` appears only in the woven gestures (`woven`, `drawing`), as the\n * brand rule asks: a single strand is never two-coloured.\n *\n * ## The meaning is in the words, not the mark\n *\n * The mark is always `aria-hidden`. It sits beside a title (\"No sources\n * yet\", \"Could not load the sources\"), inside an `EmptyState`'s `icon` slot,\n * or inside a `DataState` that already says `aria-busy` and announces the\n * state. Colour and shape only repeat what the text says, so the mark never\n * needs a label of its own.\n *\n * ## Motion\n *\n * `drawing` loops the draw verb's dash (pathLength 100, one keyframe for\n * every geometry). Under `prefers-reduced-motion: reduce` the loop is\n * removed outright and the pair rests fully woven, so a reduced-motion\n * reader sees a still thread and reads \"Loading\" from the text beside it.\n * Every other state is still.\n *\n * ## Sizes\n *\n * `sm` sits inline with body text, `md` beside a heading or in a button, and\n * `lg` is the illustration in an empty or error panel. The stroke scales with\n * the mark, so it reads at every size without a separate drawing.\n *\n * | Rule | Concept                 | Where in this file                                 |\n * | ---- | ----------------------- | -------------------------------------------------- |\n * | R4   | Extends native el       | `svg` props, minus children and aria-hidden        |\n * | R6   | data-slot + data-state  | `thread-mark`, `data-state={state}`                |\n * | R7   | cn + ...rest            | `cn(…, className)` + `{...props}`                  |\n * | R8   | Enums, not booleans     | `state`, `size`                                    |\n * | R19  | Tokens only             | `stroke-strand-a/-b`, `fill-foreground`            |\n * | R25  | Server component        | Pure render; the loop is CSS                       |\n * | R26  | A11y                    | Always hidden; the words beside it carry meaning   |\n */\n\nimport { cn } from '@/lib/utils';\n\nexport type ThreadMarkState = 'woven' | 'drawing' | 'loose' | 'cut';\n\nconst SIZE = {\n  sm: 'h-3 w-6',\n  md: 'h-5 w-10',\n  lg: 'h-12 w-24',\n} as const;\n\n/** Two strands that leave the left knot together, cross twice, and meet at the right. */\nconst WOVEN = [\n  'M4 12 C12 2, 18 2, 24 12 S36 22, 44 12',\n  'M4 12 C12 22, 18 22, 24 12 S36 2, 44 12',\n] as const;\n\n/** One strand from the knot, trailing off with nothing to tie to. */\nconst LOOSE = 'M4 12 C12 2, 20 2, 26 12 S38 21, 45 18';\n\n/** One strand, snapped: two halves that no longer meet. */\nconst CUT = ['M4 12 C10 4, 15 4, 19 9', 'M29 15 C33 20, 38 20, 44 12'] as const;\n\nconst STROKE = {\n  fill: 'none',\n  strokeWidth: 2,\n  strokeLinecap: 'round',\n  strokeLinejoin: 'round',\n} as const;\n\nexport interface ThreadMarkProps extends Omit<\n  React.ComponentPropsWithoutRef<'svg'>,\n  'children' | 'aria-hidden'\n> {\n  /** What the thread says. @default 'woven' */\n  state?: ThreadMarkState;\n  /** `sm` inline, `md` beside a heading, `lg` in an empty or error panel. @default 'md' */\n  size?: keyof typeof SIZE;\n}\n\nfunction Knot({ x }: { x: number }) {\n  return <circle cx={x} cy={12} r={2.5} className=\"fill-foreground\" />;\n}\n\nexport function ThreadMark({ state = 'woven', size = 'md', className, ...props }: ThreadMarkProps) {\n  return (\n    <svg\n      data-slot=\"thread-mark\"\n      data-state={state}\n      viewBox=\"0 0 48 24\"\n      className={cn('inline-block shrink-0 overflow-visible', SIZE[size], className)}\n      {...props}\n      aria-hidden\n      focusable=\"false\"\n    >\n      {state === 'woven' || state === 'drawing' ? (\n        <>\n          {WOVEN.map((d, i) => (\n            <path\n              key={d}\n              d={d}\n              pathLength={100}\n              {...STROKE}\n              className={cn(\n                i === 0 ? 'stroke-strand-a' : 'stroke-strand-b',\n                state === 'drawing' && 'animate-strand-loop [stroke-dasharray:100]',\n              )}\n            />\n          ))}\n          <Knot x={4} />\n          <Knot x={44} />\n        </>\n      ) : state === 'loose' ? (\n        <>\n          <path d={LOOSE} {...STROKE} className=\"stroke-strand-a\" />\n          <Knot x={4} />\n        </>\n      ) : (\n        <>\n          {CUT.map((d) => (\n            <path key={d} d={d} {...STROKE} className=\"stroke-strand-a\" />\n          ))}\n          <Knot x={4} />\n          <Knot x={44} />\n        </>\n      )}\n    </svg>\n  );\n}\n"
    }
  ],
  "meta": {
    "tier": "primitive",
    "client": false,
    "minViewport": null,
    "loading": false,
    "version": "1.0.0",
    "since": "2.0.0"
  },
  "docs": "## @interlace/thread-mark\n\nInstalled to `components/ui/thread-mark.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/thread-mark';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/thread-mark\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
