{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "weave-texture",
  "type": "registry:ui",
  "title": "Weave Texture",
  "description": "A quiet woven cloth behind a section: warp threads in `--strand-a` and weft threads in `--strand-b`, passing over and under each other in a plain weave. It is texture, not glow: nothing moves, nothing shines, and at the default strength it sits just above…",
  "author": "ofri-peretz <https://github.com/ofri-peretz>",
  "categories": [
    "decorative",
    "effect"
  ],
  "dependencies": [],
  "registryDependencies": [
    "https://ds.interlace.tools/r/interlace-base.json",
    "https://ds.interlace.tools/r/cn.json"
  ],
  "files": [
    {
      "path": "registry/interlace-ui/effects/weave-texture.tsx",
      "target": "components/ui/effects/weave-texture.tsx",
      "type": "registry:ui",
      "content": "import * as React from 'react';\n\n// @interlace/weave-texture v1.0.0 — Interlace design system.\n// Docs, props and live preview: https://ds.interlace.tools/c/weave-texture\n// What changed since: https://ds.interlace.tools/c/weave-texture#history\n// Generated banner — keep it, the upgrade diff reads this version.\n\n/**\n * @interlace/ui — WeaveTexture\n *\n * A quiet woven cloth behind a section: warp threads in `--strand-a` and weft\n * threads in `--strand-b`, passing over and under each other in a plain\n * weave. It is texture, not glow: nothing moves, nothing shines, and at the\n * default strength it sits just above the page colour, so text on top keeps\n * its full contrast.\n *\n * The survey behind Interlace's identity asks for \"texture instead of glow\":\n * where the genre lights a dark hero with beams and particles, Interlace\n * dresses a light page in its own material.\n *\n * ## How it is drawn\n *\n * One SVG `<pattern>` tile in real pixels (no viewBox scaling, so the thread\n * width is the same at any section size), repeated to fill the parent. The\n * tile is two cells square: a warp and a weft thread cross in each cell, and\n * the one on top alternates like a checkerboard, which is what makes a plain\n * weave read as cloth rather than a grid. The thread on top is edged in the\n * page colour, so the crossing shows without any shading.\n *\n * ## Host contract\n *\n * Absolutely positioned to fill its parent, like every Interlace backdrop.\n * Put it first inside a `relative` (or `isolate`) section; content after it\n * paints on top.\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               | `weave-texture`                                        |\n * | R7   | cn + ...rest            | `cn(…, className)` + `{...props}`                      |\n * | R8   | Enums, not booleans     | `density`, `strength`, `fade`                          |\n * | R19  | Tokens only             | `--strand-a`, `--strand-b`, `--background`             |\n * | R23  | CLS=0                   | `absolute inset-0`, never in flow                      |\n * | R25  | Server component        | Only `useId`, which RSC supports → no `'use client'`   |\n */\n\nimport { cn } from '@/lib/utils';\n\n/** Thread spacing in CSS pixels: one cell of the weave. */\nconst CELL = { fine: 8, default: 12, coarse: 20 } as const;\n\n/** How far the cloth stands out from the page. */\nconst STRENGTH = { faint: 0.06, default: 0.1, strong: 0.18 } as const;\n\nconst FADE = {\n  none: '',\n  edges: '[mask-image:radial-gradient(ellipse_at_center,black_40%,transparent_85%)]',\n  bottom: '[mask-image:linear-gradient(to_bottom,black_30%,transparent)]',\n} as const;\n\nexport interface WeaveTextureProps extends Omit<\n  React.ComponentPropsWithoutRef<'svg'>,\n  'children' | 'aria-hidden'\n> {\n  /** Thread spacing. @default 'default' */\n  density?: keyof typeof CELL;\n  /** How far the cloth stands out from the page. @default 'default' */\n  strength?: keyof typeof STRENGTH;\n  /** Let the cloth thin out toward the section's edges or bottom. @default 'none' */\n  fade?: keyof typeof FADE;\n}\n\nexport function WeaveTexture({\n  density = 'default',\n  strength = 'default',\n  fade = 'none',\n  className,\n  ...props\n}: WeaveTextureProps) {\n  const id = `weave-${React.useId().replace(/:/g, '')}`;\n  const c = CELL[density];\n  const s = c * 2;\n  const w = c * 0.55;\n  const o = (c - w) / 2;\n\n  // A thread is a band `w` wide down the middle of its cell.\n  const warp = (x: number, y: number) => (\n    <rect x={x + o} y={y} width={w} height={c} fill=\"var(--strand-a)\" />\n  );\n  const weft = (x: number, y: number) => (\n    <rect x={x} y={y + o} width={c} height={w} fill=\"var(--strand-b)\" />\n  );\n  // Where the top thread crosses the one beneath, its two long sides are\n  // edged in the page colour. Only across the crossing: an edge along the\n  // whole cell would cut the thread where it runs on into the next cell.\n  const over = (x: number, y: number, dir: 'warp' | 'weft') => {\n    const [a, b] = [o, o + w];\n    const lines =\n      dir === 'warp'\n        ? [\n            [x + a, y + a, x + a, y + b],\n            [x + b, y + a, x + b, y + b],\n          ]\n        : [\n            [x + a, y + a, x + b, y + a],\n            [x + a, y + b, x + b, y + b],\n          ];\n    return (\n      <>\n        {dir === 'warp' ? warp(x, y) : weft(x, y)}\n        {lines.map(([x1, y1, x2, y2]) => (\n          <line\n            key={`${x1}-${y1}`}\n            x1={x1}\n            y1={y1}\n            x2={x2}\n            y2={y2}\n            stroke=\"var(--background)\"\n            strokeWidth={1}\n          />\n        ))}\n      </>\n    );\n  };\n\n  return (\n    <svg\n      data-slot=\"weave-texture\"\n      className={cn('pointer-events-none absolute inset-0 size-full', FADE[fade], className)}\n      {...props}\n      aria-hidden\n      focusable=\"false\"\n    >\n      <defs>\n        <pattern id={id} width={s} height={s} patternUnits=\"userSpaceOnUse\">\n          {/* Cells (0,0) and (1,1): warp over weft. (1,0) and (0,1): weft over warp. */}\n          {weft(0, 0)}\n          {over(0, 0, 'warp')}\n          {warp(c, 0)}\n          {over(c, 0, 'weft')}\n          {warp(0, c)}\n          {over(0, c, 'weft')}\n          {weft(c, c)}\n          {over(c, c, 'warp')}\n        </pattern>\n      </defs>\n      <rect width=\"100%\" height=\"100%\" fill={`url(#${id})`} opacity={STRENGTH[strength]} />\n    </svg>\n  );\n}\n"
    }
  ],
  "meta": {
    "tier": "effect",
    "client": false,
    "minViewport": null,
    "loading": false,
    "version": "1.0.0",
    "since": "2.0.0"
  },
  "docs": "## @interlace/weave-texture\n\nInstalled to `components/ui/effects/weave-texture.tsx`.\n\n```tsx\nimport { /* … */ } from '@/components/ui/effects/weave-texture';\n```\n\nProps, a11y contract, live preview and source: https://ds.interlace.tools/c/weave-texture\n\nRequires the `@interlace/interlace-base` CSS baseline (installed automatically as a registry dependency). For the Interlace look, also add `@interlace/theme`."
}
