// Plan step 4.6 (CS-16): the waiter's colours are @xenia/ui tokens (var(--x-…) or the app's // --bg / --text / --accent… made of them), so light / dark and the venue's colour reach every // screen. No colour value may be written in the app's code; a colour that isn't a token yet // becomes one in packages/ui/src/tokens.css. Colours the venue stores are data, not styling: // the table-card palette's defaults (store/tableColourStore.js) are the one exception. import { test } from 'node:test' import assert from 'node:assert/strict' import { readdirSync, readFileSync, statSync } from 'node:fs' import path from 'node:path' import { fileURLToPath } from 'node:url' const SRC = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..', 'src') const DATA = new Set(['store/tableColourStore.js']) const COLOUR = [ /(^|[^\w&])#[0-9a-fA-F]{3}(?:[0-9a-fA-F]{3})?(?:[0-9a-fA-F]{2})?\b/, // #fff, #f59e0b, #f59e0b40 /\brgba?\(\s*\d/, // rgb(245, 158, 11) /\bhsla?\(\s*\d/, /['"](white|black)['"]/, // named colours as values /var\(--[\w-]+\)[0-9a-fA-F]{2}\b/, // 'var(--accent)18': invalid CSS ] function walk(dir, out = []) { for (const name of readdirSync(dir)) { const p = path.join(dir, name) if (statSync(p).isDirectory()) walk(p, out) else if (/\.(jsx?|css)$/.test(name)) out.push(p) } return out } test('no colour literal in the waiter app (tokens only)', () => { const hits = [] for (const file of walk(SRC)) { const rel = path.relative(SRC, file).split(path.sep).join('/') if (DATA.has(rel)) continue readFileSync(file, 'utf8').split('\n').forEach((line, i) => { if (COLOUR.some(re => re.test(line))) hits.push(`${rel}:${i + 1}: ${line.trim().slice(0, 90)}`) }) } assert.deepEqual(hits, [], `colour values in app code — use a token (var(--x-…)):\n${hits.join('\n')}`) })