{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "dot-board",
  "type": "registry:item",
  "title": "Dot Board",
  "description": "A departures board of LED dots whose lines light in a left-to-right sweep when their text changes.",
  "categories": [
    "data"
  ],
  "dependencies": [
    "@shopify/react-native-skia",
    "react-native-reanimated",
    "react-native-worklets"
  ],
  "registryDependencies": [
    "https://kinetik-ui.dev/r/kinetik-tokens.json",
    "https://kinetik-ui.dev/r/kinetik-motion.json"
  ],
  "files": [
    {
      "path": "src/components/kinetik/dot-board.tsx",
      "type": "registry:file",
      "target": "~/components/kinetik/dot-board.tsx",
      "content": "import { Canvas, Group, Path, rect, Skia } from '@shopify/react-native-skia';\nimport { useEffect, useMemo, useState } from 'react';\nimport { StyleSheet, Text, View, type StyleProp, type ViewStyle } from 'react-native';\nimport {\n  Easing,\n  useDerivedValue,\n  useSharedValue,\n  withDelay,\n  withTiming,\n} from 'react-native-reanimated';\n\nimport { useReduceMotion } from '../../lib/kinetik/hooks/use-reduce-motion';\nimport { useKinetikTheme } from '../../lib/kinetik/tokens/theme';\n\nexport type DotBoardRun = {\n  text: string;\n  /** Colour of the lit dots. Defaults to white. */\n  color?: string;\n};\n\n/** A line of the board: plain text, or runs in different colours. */\nexport type DotBoardLine = string | DotBoardRun[];\n\nexport type DotBoardProps = {\n  title: string;\n  subtitle?: string;\n  /** The lines shown on the board. Letters are upper-cased; unknown characters are blank. */\n  lines: DotBoardLine[];\n  /** Characters per line. Defaults to the longest line, and at least 9. */\n  columns?: number;\n  /** Delay in ms between one line starting to light and the next. Defaults to 140. */\n  stagger?: number;\n  style?: StyleProp<ViewStyle>;\n};\n\nconst W = 5;\nconst H = 7;\n/** Dots between characters and rows between lines. */\nconst GAP_X = 1;\nconst GAP_Y = 2;\nconst DOT = 0.8;\nconst SWEEP_MS = 620;\n\n/** Characters drawn on a 5 by 7 grid: one group per row, \"1\" is a lit dot. */\nconst GLYPHS: Record<string, string> = {\n  '0': '01110 10001 10011 10101 11001 10001 01110',\n  '1': '00100 01100 00100 00100 00100 00100 01110',\n  '2': '01110 10001 00001 00010 00100 01000 11111',\n  '3': '11110 00001 00001 01110 00001 00001 11110',\n  '4': '00010 00110 01010 10010 11111 00010 00010',\n  '5': '11111 10000 11110 00001 00001 10001 01110',\n  '6': '00110 01000 10000 11110 10001 10001 01110',\n  '7': '11111 00001 00010 00100 01000 01000 01000',\n  '8': '01110 10001 10001 01110 10001 10001 01110',\n  '9': '01110 10001 10001 01111 00001 00010 01100',\n  A: '01110 10001 10001 11111 10001 10001 10001',\n  B: '11110 10001 10001 11110 10001 10001 11110',\n  C: '01110 10001 10000 10000 10000 10001 01110',\n  D: '11110 10001 10001 10001 10001 10001 11110',\n  E: '11111 10000 10000 11110 10000 10000 11111',\n  F: '11111 10000 10000 11110 10000 10000 10000',\n  G: '01110 10001 10000 10111 10001 10001 01111',\n  H: '10001 10001 10001 11111 10001 10001 10001',\n  I: '01110 00100 00100 00100 00100 00100 01110',\n  J: '00111 00010 00010 00010 00010 10010 01100',\n  K: '10001 10010 10100 11000 10100 10010 10001',\n  L: '10000 10000 10000 10000 10000 10000 11111',\n  M: '10001 11011 10101 10101 10001 10001 10001',\n  N: '10001 11001 10101 10011 10001 10001 10001',\n  O: '01110 10001 10001 10001 10001 10001 01110',\n  P: '11110 10001 10001 11110 10000 10000 10000',\n  Q: '01110 10001 10001 10001 10101 10010 01101',\n  R: '11110 10001 10001 11110 10100 10010 10001',\n  S: '01111 10000 10000 01110 00001 00001 11110',\n  T: '11111 00100 00100 00100 00100 00100 00100',\n  U: '10001 10001 10001 10001 10001 10001 01110',\n  V: '10001 10001 10001 10001 10001 01010 00100',\n  W: '10001 10001 10001 10101 10101 11011 10001',\n  X: '10001 10001 01010 00100 01010 10001 10001',\n  Y: '10001 10001 01010 00100 00100 00100 00100',\n  Z: '11111 00001 00010 00100 01000 10000 11111',\n  ':': '00000 00100 00100 00000 00100 00100 00000',\n  '.': '00000 00000 00000 00000 00000 01100 01100',\n  '-': '00000 00000 00000 11111 00000 00000 00000',\n  '/': '00001 00001 00010 00100 01000 10000 10000',\n  '+': '00000 00100 00100 11111 00100 00100 00000',\n};\n\nfunction runsOf(line: DotBoardLine): DotBoardRun[] {\n  return typeof line === 'string' ? [{ text: line }] : line;\n}\n\nfunction textOf(line: DotBoardLine): string {\n  return runsOf(line)\n    .map((r) => r.text)\n    .join('');\n}\n\n/** SVG path of the dots of `chars` starting at column `from`: only the lit ones, or all of them. */\nexport function dotsPath(chars: string, from: number, row: number, pitch: number, lit: boolean) {\n  const size = (pitch * DOT).toFixed(2);\n  const parts: string[] = [];\n  [...chars].forEach((char, c) => {\n    const rows = lit ? GLYPHS[char.toUpperCase()]?.split(' ') : null;\n    if (lit && !rows) return;\n    for (let y = 0; y < H; y++) {\n      for (let x = 0; x < W; x++) {\n        if (rows && rows[y]?.[x] !== '1') continue;\n        const px = (from + c) * (W + GAP_X) * pitch + x * pitch;\n        const py = (row + y) * pitch;\n        parts.push(`M${px.toFixed(2)} ${py.toFixed(2)}h${size}v${size}h-${size}z`);\n      }\n    }\n  });\n  return parts.join('');\n}\n\n/** The lit dots of a line, one path per colour run. */\nfunction litPaths(line: DotBoardLine, row: number, pitch: number) {\n  const paths = [];\n  let from = 0;\n  for (const run of runsOf(line)) {\n    const d = dotsPath(run.text, from, row, pitch, true);\n    from += run.text.length;\n    paths.push({ path: d ? Skia.Path.MakeFromSVGString(d) : null, color: run.color });\n  }\n  return paths;\n}\n\n/**\n * A departures-style board: each character is a small block of LED dots, unlit\n * dots faintly visible. When a line changes, its new dots light in a sweep from\n * left to right, one line after another.\n */\nexport function DotBoard({ title, subtitle, lines, columns, stagger = 140, style }: DotBoardProps) {\n  const { colors, font, space } = useKinetikTheme();\n  const [width, setWidth] = useState(0);\n  const cols = columns ?? Math.max(9, ...lines.map((l) => textOf(l).length));\n  const dotsX = cols * (W + GAP_X) - GAP_X;\n  const dotsY = lines.length * (H + GAP_Y) - GAP_Y;\n  const pitch = width / dotsX;\n  const rows = lines.length;\n\n  const off = useMemo(() => {\n    if (!width) return null;\n    const blank = ' '.repeat(cols);\n    const d = Array.from({ length: rows }, (_, i) =>\n      dotsPath(blank, 0, i * (H + GAP_Y), pitch, false),\n    ).join('');\n    return Skia.Path.MakeFromSVGString(d);\n  }, [width, cols, rows, pitch]);\n\n  return (\n    <View\n      accessible\n      accessibilityLabel={[title, subtitle, ...lines.map(textOf)].filter(Boolean).join('. ')}\n      style={[styles.card, { padding: space[5], gap: space[1] }, style]}\n    >\n      <Text\n        style={{ color: colors.highlight, fontSize: font.size.lg, fontWeight: font.weight.bold }}\n      >\n        {title}\n      </Text>\n      {subtitle ? (\n        <Text style={{ color: MUTED, fontSize: font.size.sm + 1 }}>{subtitle}</Text>\n      ) : null}\n      <View style={[styles.frame, { marginTop: space[6] }]}>\n        <View style={styles.panel}>\n          <View\n            testID=\"dot-board-dots\"\n            style={[styles.dots, { aspectRatio: dotsX / dotsY }]}\n            onLayout={(e) => setWidth(e.nativeEvent.layout.width)}\n          >\n            {off ? (\n              <Canvas style={{ width, height: pitch * dotsY }} pointerEvents=\"none\">\n                <Path path={off} color={UNLIT} />\n                {lines.map((line, i) => (\n                  <LitLine\n                    key={i}\n                    line={line}\n                    row={i * (H + GAP_Y)}\n                    pitch={pitch}\n                    columns={dotsX}\n                    delay={i * stagger}\n                  />\n                ))}\n              </Canvas>\n            ) : null}\n          </View>\n        </View>\n      </View>\n    </View>\n  );\n}\n\n/** One line's lit dots, clipped by a sweep that steps a column at a time, like LEDs. */\nfunction LitLine({\n  line,\n  row,\n  pitch,\n  columns,\n  delay,\n}: {\n  line: DotBoardLine;\n  row: number;\n  pitch: number;\n  columns: number;\n  delay: number;\n}) {\n  const { colors } = useKinetikTheme();\n  const reduced = useReduceMotion();\n  const text = textOf(line);\n  const sweep = useSharedValue(reduced ? 1 : 0);\n\n  useEffect(() => {\n    if (reduced) {\n      sweep.set(1);\n      return;\n    }\n    sweep.set(0);\n    sweep.set(withDelay(delay, withTiming(1, { duration: SWEEP_MS, easing: Easing.linear })));\n  }, [text, reduced, delay, sweep]);\n\n  const clip = useDerivedValue(() =>\n    rect(0, row * pitch, Math.ceil(sweep.get() * columns) * pitch, H * pitch),\n  );\n\n  const paths = useMemo(() => litPaths(line, row, pitch), [line, row, pitch]);\n\n  return (\n    <Group clip={clip}>\n      {paths.map(({ path, color }, i) =>\n        path ? <Path key={i} path={path} color={color ?? colors.highlight} /> : null,\n      )}\n    </Group>\n  );\n}\n\nconst MUTED = 'hsl(215, 14%, 66%)';\nconst UNLIT = 'hsl(214, 15%, 18%)';\n\nconst styles = StyleSheet.create({\n  card: {\n    width: '100%',\n    maxWidth: 360,\n    alignSelf: 'center',\n    borderRadius: 30,\n    backgroundColor: 'hsl(215, 20%, 17%)',\n    boxShadow: '0px 18px 40px hsla(215, 30%, 8%, 0.28)',\n  },\n  frame: { borderRadius: 16, padding: 7, backgroundColor: 'hsl(215, 18%, 22%)' },\n  panel: { borderRadius: 11, padding: 14, backgroundColor: 'hsl(216, 20%, 8%)' },\n  dots: { width: '100%' },\n});\n"
    }
  ],
  "meta": {
    "version": "1.0.0",
    "kind": "component",
    "platforms": [
      "ios",
      "android",
      "web"
    ],
    "category": "data",
    "web": "live",
    "perf": {
      "budget": "One Skia canvas; the dots are prebuilt paths and the sweep only moves a clip on the UI thread. Nothing animates at rest.",
      "measurements": [
        {
          "device": "Huawei P20 Lite (ANE-LX1), Android 9",
          "kind": "device",
          "date": "2026-11-02",
          "build": "release",
          "frameMs": 16,
          "p90Ms": 20,
          "jankyPercent": 54.05,
          "atRest": "animating",
          "memoryMb": 129,
          "notes": "Frames at rest come from the demo, which changes departure every 4 s. A board with unchanged text draws nothing."
        }
      ]
    },
    "a11y": {
      "reducedMotion": "Dots appear lit at once, with no sweep.",
      "screenReader": "The title, subtitle and every line read as one label (\"Next Departure. Your ride leaves from gate twelve. 08:45. KYOTO. NZ204\").",
      "touchTarget": "Not interactive."
    },
    "requires": "React Native New Architecture (Reanimated 4)",
    "guide": "## Usage\n\n```tsx\nimport { DotBoard } from '@/components/kinetik/dot-board';\n\n<DotBoard\n  title=\"Next Departure\"\n  subtitle=\"Your ride leaves from gate twelve.\"\n  lines={[\n    '08:45',\n    [{ text: 'KYOTO', color: amber }],\n    [{ text: 'NZ', color: amber }, { text: '204' }],\n  ]}\n/>;\n```\n\n## When to use\n\n- One short, glanceable status: a departure, a score, a queue number, a countdown.\n- A place where a bit of hardware character suits the product.\n\n## When not to use\n\n- Long text. Each line holds about nine characters at this size.\n- Languages outside A to Z: the dot font has no accents or other scripts, and unknown characters stay blank.\n\n## Notes\n\n- A line is a string, or runs with their own colours.\n- Change a line's text and only that line lights up again.\n- `columns` sets the width of the board; dots shrink to fit, so keep it low on small cards.\n"
  },
  "docs": "Prefer `npx kinetik-ui add dot-board`: it installs dependencies with expo install, so versions match your Expo SDK."
}
