{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "vllnt-mark",
  "title": "VLLNT Mark",
  "description": "The V mark of the vllnt brand as an inline SVG that draws in the current text colour.",
  "dependencies": [
    "@vllnt/ui@^0.3.0"
  ],
  "registryDependencies": [],
  "files": [
    {
      "path": "registry/default/vllnt-mark/vllnt-mark.tsx",
      "content": "import type { ComponentPropsWithoutRef } from \"react\";\n\nimport { cn } from \"@vllnt/ui\";\n\n/**\n * The V letter of the vllnt ASCII preset grid: 17 rows of `█ ▓ ▒ ░` and spaces.\n * This grid is the one source of the mark. The module derives the path data\n * from it at load, so there is no second copy to keep in step.\n */\nconst GRID = [\n  \"             ▒▒▒▒▒▒▒▒▒             ░▒▒▒▒▒▒▒▒\",\n  \"             ▒████████▓            █████████\",\n  \"              █████████░          ▒████████\",\n  \"               █████████          ████████▒\",\n  \"               ░████████░        ▓███████▓\",\n  \"                ▓████████       ░████████\",\n  \"                 ████████▒      ████████░\",\n  \"                 ░████████     ▒███████▒\",\n  \"                  ▒███████▓    ███████▓\",\n  \"                   ▓███████░  ▒███████\",\n  \"                    ███████▓  ███████░\",\n  \"                    ░███████░▓██████▓\",\n  \"                     ▓██████████████\",\n  \"                      █████████████░\",\n  \"                      ░███████████▒\",\n  \"                       ▒█████████▓\",\n  \"                        ▒▒▒▒▒▒▒▒▒\",\n] as const;\n\n/**\n * The grid is one square tile of 57 columns by 28 rows: the 17 letter rows sit\n * between 6 blank rows above and 5 below. A cell is 1/57 of the tile wide and\n * 1/28 of it tall.\n */\nconst TILE_COLUMNS = 57;\nconst TILE_ROWS_ABOVE = 6;\nconst TILE_ROWS_BELOW = 5;\n\n/** The height of the mark in viewBox units. */\nconst VIEW_HEIGHT = 1000;\n\n/** The shades from opaque to faint: a shade is an opacity, never a colour. */\nconst SHADES = [\n  { char: \"█\", opacity: 1 },\n  { char: \"▓\", opacity: 0.75 },\n  { char: \"▒\", opacity: 0.5 },\n  { char: \"░\", opacity: 0.25 },\n] as const;\n\n/** A horizontal run of one shade in one row. */\ntype Run = { char: string; column: number; length: number; row: number };\n\n/** The rounding of the Penpot atom: 3 decimals. */\nconst round3 = (value: number): number => Number(value.toFixed(3));\n\n/**\n * A number as the Penpot atom writes it: 3 decimals at most, and a whole\n * number keeps one (`0.0`, never `0`). The path data then equals the atom's\n * byte for byte.\n */\nconst format = (value: number): string => {\n  const rounded = round3(value);\n  return Number.isInteger(rounded) ? rounded.toFixed(1) : String(rounded);\n};\n\n/** Every run of equal shade characters in the grid, row by row. */\nconst findRuns = (grid: readonly string[]): Run[] =>\n  grid.flatMap((line, row) =>\n    [...line.matchAll(/([█▓▒░])\\1*/gu)].map((match) => ({\n      char: match[0].charAt(0),\n      column: match.index,\n      length: match[0].length,\n      row,\n    })),\n  );\n\n/**\n * Turns the grid into the mark: one rectangle per run, one path per shade, the\n * columns trimmed to the inked ones, and the height scaled to\n * {@link VIEW_HEIGHT}.\n *\n * @param grid - The rows of the letter.\n * @returns the `viewBox`, the width over the height, and one path per shade.\n */\nconst buildMark = (\n  grid: readonly string[],\n): {\n  aspect: number;\n  paths: readonly { d: string; opacity: number }[];\n  viewBox: string;\n} => {\n  const runs = findRuns(grid);\n  const cellWidth = 1 / TILE_COLUMNS;\n  const cellHeight = 1 / (TILE_ROWS_ABOVE + grid.length + TILE_ROWS_BELOW);\n  const scale = VIEW_HEIGHT / (grid.length * cellHeight);\n  const left = Math.min(...runs.map((run) => run.column));\n  const right = Math.max(...runs.map((run) => run.column + run.length));\n  const width = round3((right - left) * cellWidth * scale);\n  const height = format(cellHeight * scale);\n  const rectangle = (run: Run): string => {\n    const runWidth = format(run.length * cellWidth * scale);\n    const x = format((run.column - left) * cellWidth * scale);\n    const y = format(run.row * cellHeight * scale);\n    return `M${x} ${y}h${runWidth}v${height}h-${runWidth}z`;\n  };\n  return {\n    aspect: width / VIEW_HEIGHT,\n    paths: SHADES.map(({ char, opacity }) => ({\n      d: runs\n        .filter((run) => run.char === char)\n        .map((run) => rectangle(run))\n        .join(\"\"),\n      opacity,\n    })).filter((path) => path.d !== \"\"),\n    viewBox: `0 0 ${format(width)} ${VIEW_HEIGHT}`,\n  };\n};\n\nconst MARK = /* @__PURE__ */ buildMark(GRID);\n\n/** Props for {@link VllntMark}. */\nexport type VllntMarkProps = Omit<\n  ComponentPropsWithoutRef<\"svg\">,\n  \"children\" | \"height\" | \"viewBox\" | \"width\"\n> & {\n  /** The height of the mark in px: 20, 24 or 32. The width follows from it. */\n  size?: 20 | 24 | 32;\n  /**\n   * The accessible name. Without it the mark is decorative and hidden from\n   * assistive technology: name the link or button that wraps it instead.\n   */\n  title?: string;\n};\n\n/**\n * The V mark of the vllnt brand, as an inline SVG. It draws in `currentColor`,\n * so it follows the text colour in light and dark. The shades of the letter are\n * opacities of that one colour.\n *\n * Without `title` the mark is decorative. Put it in a link and name the link,\n * e.g. \"vllnt\" or \"vllnt oss\".\n *\n * @example\n * <a aria-label=\"vllnt\" href=\"/\"><VllntMark /></a>\n */\nconst VllntMark = /* @__PURE__ */ named(\n  \"VllntMark\",\n  ({\n    className,\n    size = 24,\n    title,\n    ...props\n  }: VllntMarkProps): React.ReactElement => {\n    const hasTitle = title !== undefined && title !== \"\";\n    return (\n      <svg\n        {...props}\n        aria-hidden={hasTitle ? undefined : true}\n        className={cn(\"shrink-0\", className)}\n        focusable=\"false\"\n        height={size}\n        role={hasTitle ? \"img\" : undefined}\n        viewBox={MARK.viewBox}\n        width={Math.round(size * MARK.aspect * 100) / 100}\n      >\n        {hasTitle ? <title>{title}</title> : undefined}\n        {MARK.paths.map(({ d, opacity }) => (\n          <path\n            d={d}\n            fill=\"currentColor\"\n            fillOpacity={opacity === 1 ? undefined : opacity}\n            key={opacity}\n          />\n        ))}\n      </svg>\n    );\n  },\n);\n\nexport { VllntMark };\n\nfunction named<TComponent extends object>(\n  displayName: string,\n  component: TComponent,\n): TComponent & { displayName: string };\nfunction named<TComponent extends object, TStatics extends object>(\n  displayName: string,\n  component: TComponent,\n  statics: () => TStatics,\n): TComponent & TStatics & { displayName: string };\nfunction named(\n  displayName: string,\n  component: object,\n  statics?: () => object,\n): object {\n  return Object.assign(component, statics?.(), { displayName });\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component",
  "version": "0.3.0",
  "stability": "stable",
  "platforms": [
    "web"
  ]
}
