@rtkelly-labs/design-system 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.md +1 -1
  3. package/dist/components/DataTable.js +135 -52
  4. package/dist/components/DataTable.js.map +1 -1
  5. package/dist/components/InlineAction.js +58 -0
  6. package/dist/components/InlineAction.js.map +1 -0
  7. package/dist/components/ResourceState.js +55 -0
  8. package/dist/components/ResourceState.js.map +1 -0
  9. package/dist/components/docs/figures/ChangeSummary.js +5 -5
  10. package/dist/components/docs/figures/ChangeSummary.js.map +1 -1
  11. package/dist/components/docs/figures/DrawingSheet.js +4 -1
  12. package/dist/components/docs/figures/DrawingSheet.js.map +1 -1
  13. package/dist/components/docs/figures/FigureSurfaceContext.js +9 -0
  14. package/dist/components/docs/figures/FigureSurfaceContext.js.map +1 -0
  15. package/dist/components/docs/figures/FileChangeTree.js +4 -4
  16. package/dist/components/docs/figures/FileChangeTree.js.map +1 -1
  17. package/dist/components/docs/figures/IndexedSection.js +8 -2
  18. package/dist/components/docs/figures/IndexedSection.js.map +1 -1
  19. package/dist/components/docs/figures/index.js.map +1 -1
  20. package/dist/hooks/usePolledResource.js +98 -0
  21. package/dist/hooks/usePolledResource.js.map +1 -0
  22. package/dist/index.d.ts +303 -5
  23. package/dist/index.js +4 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/lib/theme.js +12 -0
  26. package/dist/lib/theme.js.map +1 -1
  27. package/dist/lib/units.js +25 -0
  28. package/dist/lib/units.js.map +1 -0
  29. package/dist/theme/contrast.js +15 -0
  30. package/dist/theme/contrast.js.map +1 -1
  31. package/dist/theme/levels.js +31 -0
  32. package/dist/theme/levels.js.map +1 -1
  33. package/dist/theme.css +30 -0
  34. package/package.json +2 -2
  35. package/tokens/palette.midnight.tokens.json +50 -0
  36. package/tokens/palette.sketch.tokens.json +50 -0
@@ -0,0 +1,25 @@
1
+ // src/lib/units.ts
2
+ var IEC = ["B", "KiB", "MiB", "GiB", "TiB", "PiB"];
3
+ var SI = ["B", "kB", "MB", "GB", "TB", "PB"];
4
+ function render(size, unit) {
5
+ return unit === 0 ? String(Math.round(size)) : size.toFixed(1).replace(/\.0$/, "");
6
+ }
7
+ function formatBytes(bytes, options = {}) {
8
+ if (typeof bytes !== "number" || !Number.isFinite(bytes)) return "\u2014";
9
+ const base = options.base === 1e3 ? 1e3 : 1024;
10
+ const labels = base === 1e3 ? SI : IEC;
11
+ const top = labels.length - 1;
12
+ let size = Math.abs(bytes);
13
+ let unit = 0;
14
+ while (unit < top && Number(render(size, unit)) >= base) {
15
+ size /= base;
16
+ unit += 1;
17
+ }
18
+ const text = render(size, unit);
19
+ const sign = bytes < 0 && Number(text) !== 0 ? "-" : "";
20
+ return `${sign}${text} ${labels[unit]}`;
21
+ }
22
+ export {
23
+ formatBytes
24
+ };
25
+ //# sourceMappingURL=units.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/lib/units.ts"],"sourcesContent":["/**\n * Quantities with a unit ladder: a byte count written in the largest unit that\n * keeps it under the next one.\n *\n * Everything here is pure and React-free, so a server component or a script\n * can call it.\n */\n\n/** Options for {@link formatBytes}. */\nexport interface FormatBytesOptions {\n /**\n * The step between units. `1024` (the default) labels them with IEC binary\n * prefixes — `KiB`, `MiB`, `GiB`; `1000` with SI decimal prefixes — `kB`,\n * `MB`, `GB`.\n */\n base?: 1024 | 1000;\n}\n\nconst IEC = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB'] as const;\nconst SI = ['B', 'kB', 'MB', 'GB', 'TB', 'PB'] as const;\n\n/** Whole bytes, one decimal above them, with a trailing `.0` dropped. */\nfunction render(size: number, unit: number): string {\n return unit === 0 ? String(Math.round(size)) : size.toFixed(1).replace(/\\.0$/, '');\n}\n\n/**\n * `512 B`, `1.5 KiB`, `20 MiB`, `3.2 TiB`: a byte count in the largest unit\n * that keeps it below the next one, whole for bytes and to one decimal above\n * them, with a trailing `.0` dropped as `formatShare` and `formatTraceDuration`\n * do. A space separates number and unit, as the SI and IEC conventions write\n * them.\n *\n * **Binary by default, and labelled as binary.** The counts this formats come\n * from the file system, memory and process accounting, which count in powers\n * of two — and Windows and most dashboards already divide by 1024. What they\n * get wrong is the label: `KB` for 1024 bytes is the JEDEC usage SI reserves\n * for 1000, so the same string means two numbers 2.4% apart at `KB` and 10%\n * apart at `TB`. `KiB` cannot be misread. Pass `{ base: 1000 }` for sizes\n * that are decimal by nature — network transfer, storage as a vendor states it\n * — and the labels become `kB`, `MB`, `GB`.\n *\n * The unit is chosen *after* rounding, so a value that would round up to the\n * base moves to the next unit: 1023.96 KiB is `1 MiB`, never `1024 KiB`, and\n * 1023.6 B is `1 KiB`. Petabytes are the top of the ladder; anything larger\n * stays in them (`2048 PiB`).\n *\n * A negative count — a size delta — keeps its sign (`-1.5 KiB`); `-0` is\n * `0 B`. `NaN` and `±Infinity` are `—`, as the other formatters here write a\n * value they cannot.\n */\nexport function formatBytes(bytes: number, options: FormatBytesOptions = {}): string {\n if (typeof bytes !== 'number' || !Number.isFinite(bytes)) return '—';\n const base = options.base === 1000 ? 1000 : 1024;\n const labels = base === 1000 ? SI : IEC;\n const top = labels.length - 1;\n let size = Math.abs(bytes);\n let unit = 0;\n // Step up while the value, as it would be printed, reaches the base.\n while (unit < top && Number(render(size, unit)) >= base) {\n size /= base;\n unit += 1;\n }\n const text = render(size, unit);\n const sign = bytes < 0 && Number(text) !== 0 ? '-' : '';\n return `${sign}${text} ${labels[unit]}`;\n}\n"],"mappings":";AAkBA,IAAM,MAAM,CAAC,KAAK,OAAO,OAAO,OAAO,OAAO,KAAK;AACnD,IAAM,KAAK,CAAC,KAAK,MAAM,MAAM,MAAM,MAAM,IAAI;AAG7C,SAAS,OAAO,MAAc,MAAsB;AAClD,SAAO,SAAS,IAAI,OAAO,KAAK,MAAM,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,EAAE,QAAQ,QAAQ,EAAE;AACnF;AA2BO,SAAS,YAAY,OAAe,UAA8B,CAAC,GAAW;AACnF,MAAI,OAAO,UAAU,YAAY,CAAC,OAAO,SAAS,KAAK,EAAG,QAAO;AACjE,QAAM,OAAO,QAAQ,SAAS,MAAO,MAAO;AAC5C,QAAM,SAAS,SAAS,MAAO,KAAK;AACpC,QAAM,MAAM,OAAO,SAAS;AAC5B,MAAI,OAAO,KAAK,IAAI,KAAK;AACzB,MAAI,OAAO;AAEX,SAAO,OAAO,OAAO,OAAO,OAAO,MAAM,IAAI,CAAC,KAAK,MAAM;AACvD,YAAQ;AACR,YAAQ;AAAA,EACV;AACA,QAAM,OAAO,OAAO,MAAM,IAAI;AAC9B,QAAM,OAAO,QAAQ,KAAK,OAAO,IAAI,MAAM,IAAI,MAAM;AACrD,SAAO,GAAG,IAAI,GAAG,IAAI,IAAI,OAAO,IAAI,CAAC;AACvC;","names":[]}
@@ -177,6 +177,9 @@ function auditHueAgreement(ladder) {
177
177
  for (const [role, ref] of Object.entries(def.intentHue)) {
178
178
  check(`intent.${role}`, def.intent[role], ref);
179
179
  }
180
+ for (const [role, ref] of Object.entries(def.deltaHue)) {
181
+ check(`delta.${role}`, def.delta[role], ref);
182
+ }
180
183
  }
181
184
  return results;
182
185
  }
@@ -216,6 +219,9 @@ function auditContrast(ladder, floor = WEB_FLOOR) {
216
219
  for (const tone of ["info", "success", "warning", "danger"]) {
217
220
  check(`intent.${tone} on ${groundName}`, def.intent[tone], ground, floor.role);
218
221
  }
222
+ for (const tone of ["added", "removed", "moved"]) {
223
+ check(`delta.${tone} on ${groundName}`, def.delta[tone], ground, floor.role);
224
+ }
219
225
  for (const hue of PALETTE_HUES_ORDER) {
220
226
  check(`palette.${hue} on ${groundName}`, def.palette[hue], ground, floor.hue);
221
227
  check(
@@ -237,6 +243,10 @@ function auditContrast(ladder, floor = WEB_FLOOR) {
237
243
  floor.role
238
244
  );
239
245
  }
246
+ for (const tone of ["added", "removed", "moved"]) {
247
+ check(`text.inverse on delta.${tone}`, def.text.inverse, def.delta[tone], floor.role);
248
+ }
249
+ check("text.inverse on text.secondary", def.text.inverse, def.text.secondary, floor.role);
240
250
  for (const tone of ["info", "success", "warning", "danger"]) {
241
251
  check(
242
252
  `text.inverse on intent.${tone}`,
@@ -245,6 +255,11 @@ function auditContrast(ladder, floor = WEB_FLOOR) {
245
255
  floor.role
246
256
  );
247
257
  }
258
+ for (const tone of ["added", "removed"]) {
259
+ check(`diff row: text.primary on deltaGround.${tone}`, def.text.primary, def.deltaGround[tone], floor.role);
260
+ check(`diff sign: delta.${tone} on deltaGround.${tone}`, def.delta[tone], def.deltaGround[tone], floor.role);
261
+ }
262
+ check("diff hunk: text.secondary on deltaGround.hunk", def.text.secondary, def.deltaGround.hunk, floor.role);
248
263
  check("select.option: text.primary on surface.raised", def.text.primary, def.surface.raised, floor.role);
249
264
  check("select.option disabled: text.muted on surface.raised", def.text.muted, def.surface.raised, floor.role);
250
265
  check("select.placeholder: text.muted on surface.base", def.text.muted, def.surface.base, floor.role);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/contrast.ts"],"sourcesContent":["/**\n * Contrast arithmetic over the ladder.\n *\n * Every colour in `levels.ts` is a literal, so contrast can be computed as data\n * — no browser, no screenshot, no rendering. `pnpm check:contrast` walks every\n * level and fails CI on a violation, which is the thing that makes the ladder\n * maintainable: every level times every role pair is a matrix nobody eyeballs\n * reliably twice.\n *\n * The gate is WCAG 2.1 relative luminance. APCA is the better predictor of\n * perceived contrast, but it is not yet normative and its thresholds are not\n * stable; WCAG ratios are what an audit will be run against. So APCA is\n * computed alongside and reported, never gated. It is reported because WCAG 2\n * overrates light text on a dark ground: midnight's `text.muted` passed at\n * 5.90:1 while scoring Lc -41, the weakest text pair in the system (#372).\n */\n\nimport type { Emphasis, Hue, HueRef, Intent, TextTone } from '../lib/theme';\nimport type { LevelDefinition, ThemeLevel } from './levels';\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n /** 0–1. Colours without an alpha channel parse as 1. */\n a: number;\n}\n\nconst HEX = /^#([0-9a-f]{3,8})$/i;\nconst RGB_FN = /^rgba?\\(\\s*([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)(?:[\\s,/]+([0-9.]+))?\\s*\\)$/i;\n\n/** Parse `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()`. */\nexport function parseColor(value: string): Rgb {\n const input = value.trim();\n\n const hex = HEX.exec(input);\n if (hex) {\n const digits = hex[1]!;\n const expand = (s: string) => Number.parseInt(s.length === 1 ? s + s : s, 16);\n if (digits.length === 3 || digits.length === 4) {\n return {\n r: expand(digits[0]!),\n g: expand(digits[1]!),\n b: expand(digits[2]!),\n a: digits.length === 4 ? expand(digits[3]!) / 255 : 1,\n };\n }\n if (digits.length === 6 || digits.length === 8) {\n return {\n r: expand(digits.slice(0, 2)),\n g: expand(digits.slice(2, 4)),\n b: expand(digits.slice(4, 6)),\n a: digits.length === 8 ? expand(digits.slice(6, 8)) / 255 : 1,\n };\n }\n }\n\n const fn = RGB_FN.exec(input);\n if (fn) {\n return {\n r: Number(fn[1]),\n g: Number(fn[2]),\n b: Number(fn[3]),\n a: fn[4] === undefined ? 1 : Number(fn[4]),\n };\n }\n\n throw new Error(`Unparseable colour: ${value}`);\n}\n\n/**\n * Flatten a possibly-translucent colour onto an opaque backdrop.\n *\n * Contrast is a property of what the eye receives, so a token with alpha has to\n * be composited before it can be measured. Without this step a scrim at 70%\n * would score against its own nominal colour and pass regardless of the surface\n * it actually sits on.\n */\nexport function composite(foreground: Rgb, backdrop: Rgb): Rgb {\n if (foreground.a >= 1) return foreground;\n const a = foreground.a;\n return {\n r: foreground.r * a + backdrop.r * (1 - a),\n g: foreground.g * a + backdrop.g * (1 - a),\n b: foreground.b * a + backdrop.b * (1 - a),\n a: 1,\n };\n}\n\n/** WCAG 2.1 relative luminance. */\nexport function relativeLuminance(color: Rgb): number {\n const channel = (value: number) => {\n const c = value / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b);\n}\n\n/**\n * WCAG contrast ratio between two colours, 1–21.\n *\n * The foreground is composited onto the background first, so translucent\n * tokens are measured as they render.\n */\nexport function contrastRatio(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const lighter = Math.max(relativeLuminance(fg), relativeLuminance(bg));\n const darker = Math.min(relativeLuminance(fg), relativeLuminance(bg));\n return (lighter + 0.05) / (darker + 0.05);\n}\n\n/**\n * APCA lightness contrast (Lc), per APCA-W3 0.0.98G — roughly -108 to 106.\n *\n * Signed by polarity: positive is dark text on a light ground, negative is\n * light on dark, and the magnitude is what compares across the two. Unlike a\n * WCAG ratio it is not symmetric, which is the point: the same pair of colours\n * reads differently depending on which one is the text.\n *\n * Constants are the published 0.0.98G set; the luminance is APCA's own simple\n * 2.4 power curve, not WCAG's piecewise one. Reported, not gated — see the\n * module comment.\n */\nexport function apcaContrast(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const y = (c: Rgb) =>\n 0.2126729 * (c.r / 255) ** 2.4 + 0.7151522 * (c.g / 255) ** 2.4 + 0.072175 * (c.b / 255) ** 2.4;\n const clamp = (lum: number) => (lum > 0.022 ? lum : lum + (0.022 - lum) ** 1.414);\n const text = clamp(y(fg));\n const ground = clamp(y(bg));\n if (Math.abs(ground - text) < 0.0005) return 0;\n if (ground > text) {\n const sapc = (ground ** 0.56 - text ** 0.57) * 1.14;\n return sapc < 0.1 ? 0 : (sapc - 0.027) * 100;\n }\n const sapc = (ground ** 0.65 - text ** 0.62) * 1.14;\n return sapc > -0.1 ? 0 : (sapc + 0.027) * 100;\n}\n\n/**\n * The bar each role has to clear, and why it differs.\n *\n * `text` and the accents clear WCAG AA for body copy, because they are read.\n * `borderStrong` and `borderDefault` clear the 3:1 non-text bar of WCAG 1.4.11,\n * because they are the load-bearing edges this system draws components with.\n * `borderSubtle` is a decorative divider — 1.4.11 does not cover it, so the bar\n * is only that it must be *visible* rather than accessible as a control.\n * Setting it to AA would force every hairline in the system to read as a rule.\n */\n/**\n * The Hue vocabulary, in wheel order. Declared here rather than imported so the\n * gate stays runnable by `scripts/check-contrast.mjs` without a `.ts` import\n * extension — and `satisfies` still makes a missing or misspelled Hue a\n * compile error, which is the property that matters.\n */\n/**\n * Above this, a colour declared `'neutral'` is not one. `accent.quiet` measures\n * 0.036 on `midnight` and 0.027 on `sketch` — both warm or cool greys with a\n * deliberate tint, which is why the bar is not zero.\n */\nexport const MAXIMUM_NEUTRAL_CHROMA = 0.045;\n\nexport interface HueAgreementCheck {\n readonly level: ThemeLevel;\n readonly role: string;\n readonly declared: HueRef;\n readonly value: string;\n /** The Hue's value, or null when the Role is declared `'neutral'`. */\n readonly expected: string | null;\n readonly passes: boolean;\n readonly detail: string;\n}\n\n/** OKLab chroma. Only used to prove a `'neutral'` really is one. */\nfunction oklabChroma(hex: string): number {\n const decode = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\n const [r, g, b] = [1, 3, 5].map((i) => decode(Number.parseInt(hex.slice(i, i + 2), 16) / 255));\n const l = Math.cbrt(0.4122214708 * r! + 0.5363325363 * g! + 0.0514459929 * b!);\n const m = Math.cbrt(0.2119034982 * r! + 0.6806995451 * g! + 0.1073969566 * b!);\n const s = Math.cbrt(0.0883024619 * r! + 0.2817188376 * g! + 0.6299787005 * b!);\n const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;\n const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;\n return Math.hypot(a, bb);\n}\n\nconst PALETTE_HUES_ORDER = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\nexport const MINIMUM_RATIO = {\n text: 4.5,\n /** `text.inverse` sits on an accent fill, not on a surface. */\n textInverse: 4.5,\n accent: 4.5,\n intent: 4.5,\n /**\n * A Hue, above WCAG AA deliberately. An editor draws selection, current-line,\n * find-match and diff backgrounds *behind* the same tokens, so a palette\n * solved to exactly 4.5:1 has no room left to tint the ground. At 4.5 the\n * light palette has one sRGB step of headroom; at 5.5 it has twenty-two.\n * See `docs/palette-provenance.md` and #78.\n */\n palette: 5.5,\n /**\n * These numbers are the **web** Medium's, and that indexing is the point.\n *\n * ADR 0004 names this the asymmetry most likely to be got wrong later:\n * *colour values do not vary by Medium, but the floors they must clear do.* A\n * projected 1080p frame, a compression-damaged video and an unantialiased\n * terminal cell are not the browser's legibility problem, and until now this\n * was one set of numbers for every surface the system emits to.\n *\n * `MEDIA_DEFINITIONS[medium].contrastFloor` carries the per-Medium values;\n * `auditContrast` takes a Medium and reads them. The constants here remain as\n * the web Medium's, so nothing moves on merge and a caller that does not care\n * about Media keeps working.\n */\n /** `bright` Hues carry emphasis, not body text, so AA is the right bar. */\n paletteBright: 4.5,\n borderStrong: 3,\n borderDefault: 3,\n borderSubtle: 1.4,\n /**\n * A modal's dialog against the scrimmed page behind it. Not an accessibility\n * threshold — an assertion that the scrim does the one job it exists for.\n */\n overlaySeparation: 3,\n /**\n * A selection device — the accent `fill` behind a chosen tab, or the 4px\n * accent `edge` beside it — against the surface it sits on. WCAG 1.4.11's\n * non-text bar: the device is a UI component boundary, not text.\n */\n stateDevice: 3,\n} as const;\n\nexport interface ContrastCheck {\n level: ThemeLevel;\n /** e.g. `text.muted on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n /** APCA Lc for the same pair, reported alongside the ratio and never gated. Null where the pair is a separation rather than a foreground on a ground. */\n apca: number | null;\n minimum: number;\n passes: boolean;\n}\n\n/**\n * Every pair worth asserting, for every level.\n *\n * Text, accents and intents are checked against `base`, `raised` *and*\n * `sunken`, because a component is free to sit on any of the three and a token\n * that only works on the page ground is a bug waiting for the first card.\n *\n * The ladder is passed in rather than imported so this module is pure colour\n * arithmetic over data — it can audit a consumer's own overrides, and it stays\n * runnable from a plain Node script with no bundler in the path.\n */\n/**\n * Does every Role actually hold the value of the Hue it says it is?\n *\n * `check:contrast` cannot answer this, and that is not an oversight in it — a\n * Role and a Hue are both foregrounds, both clear their own floors, and a\n * mismatch between them is not a contrast fault. It is a *drift* fault, and it\n * is the one ADR 0001 rejects its third option over:\n *\n * > the two sets then drift silently, and there is no arithmetic that can\n * > catch a `palette.cyan` that no longer matches the `accent.primary` it is\n * > supposed to be.\n *\n * This is that arithmetic. It exists because the repo shipped the fault: after\n * `palette` landed, `midnight`'s `accent.tertiary` sat at `#ec4899` (5.12:1,\n * clearing the 4.5 Role floor) while `palette.pink` sat at `#f955a4` (5.90:1,\n * clearing the 5.5 Hue floor). Both gates passed. The two values are 0.036\n * apart in OKLab — indistinguishable, so no screenshot would have caught it\n * either.\n *\n * A Role declared `'neutral'` is asserted to *be* neutral rather than skipped,\n * because \"declared as not-a-hue\" and \"quietly wrong\" must not look the same.\n */\nexport function auditHueAgreement(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): HueAgreementCheck[] {\n const results: HueAgreementCheck[] = [];\n\n for (const level of Object.keys(ladder) as ThemeLevel[]) {\n const def = ladder[level];\n\n const check = (role: string, value: string, ref: HueRef) => {\n if (ref === 'neutral') {\n const chroma = oklabChroma(value);\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected: null,\n passes: chroma <= MAXIMUM_NEUTRAL_CHROMA,\n detail: `chroma ${chroma.toFixed(3)} (max ${MAXIMUM_NEUTRAL_CHROMA})`,\n });\n return;\n }\n const expected = def.palette[ref];\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected,\n passes: value.toLowerCase() === expected.toLowerCase(),\n detail: `palette.${ref} is ${expected}`,\n });\n };\n\n for (const [role, ref] of Object.entries(def.accentHue)) {\n check(`accent.${role}`, def.accent[role as Emphasis], ref);\n }\n for (const [role, ref] of Object.entries(def.intentHue)) {\n check(`intent.${role}`, def.intent[role as Intent], ref);\n }\n }\n\n return results;\n}\n\n/** The three floors a Medium supplies. See `MediumDefinition.contrastFloor`. */\nexport interface ContrastFloor {\n readonly role: number;\n readonly hue: number;\n readonly hueBright: number;\n}\n\n/** The web Medium's floors, restated so the default call is unchanged. */\nexport const WEB_FLOOR: ContrastFloor = {\n role: MINIMUM_RATIO.text,\n hue: MINIMUM_RATIO.palette,\n hueBright: MINIMUM_RATIO.paletteBright,\n};\n\nexport function auditContrast(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n /**\n * The Medium's floors. Passed in rather than read from `media.ts`, because\n * this module has to stay importable by `scripts/check-contrast.mjs`, and a\n * runtime import there needs a `.ts` extension that `tsc` rejects. The script\n * owns the Medium; this module owns the arithmetic.\n */\n floor: ContrastFloor = WEB_FLOOR,\n): ContrastCheck[] {\n const results: ContrastCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ['surface.sunken', def.surface.sunken],\n ] as const;\n\n const check = (pair: string, foreground: string, background: string, minimum: number) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n pair,\n foreground,\n background,\n ratio,\n apca: apcaContrast(foreground, background),\n minimum,\n passes: ratio >= minimum,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n for (const tone of ['primary', 'secondary', 'muted'] as const satisfies readonly TextTone[]) {\n check(`text.${tone} on ${groundName}`, def.text[tone], ground, floor.role);\n }\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(`accent.${tone} on ${groundName}`, def.accent[tone], ground, floor.role);\n }\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(`intent.${tone} on ${groundName}`, def.intent[tone], ground, floor.role);\n }\n // ADR 0001: gate `palette` once per Hue rather than once per Role that\n // consumes it. Separate the palette, not each of its consumers.\n for (const hue of PALETTE_HUES_ORDER) {\n check(`palette.${hue} on ${groundName}`, def.palette[hue], ground, floor.hue);\n check(\n `palette.bright.${hue} on ${groundName}`,\n def.paletteBright[hue],\n ground,\n floor.hueBright,\n );\n }\n check(`border.strong on ${groundName}`, def.border.strong, ground, MINIMUM_RATIO.borderStrong);\n check(`border.default on ${groundName}`, def.border.default, ground, MINIMUM_RATIO.borderDefault);\n check(`border.subtle on ${groundName}`, def.border.subtle, ground, MINIMUM_RATIO.borderSubtle);\n }\n\n // `text.inverse` is what a filled accent button prints in, so it is measured\n // against the accents rather than against a surface.\n // `quiet` is in this list because `Tag` ships `bg-accent-quiet\n // text-content-inverse`. It was omitted while the other three were checked,\n // so a palette edit to `quiet` would have gone unmeasured — a coverage gap\n // rather than a live defect, but the README claims every pair is audited.\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(\n `text.inverse on accent.${tone}`,\n def.text.inverse,\n def.accent[tone],\n floor.role,\n );\n }\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(\n `text.inverse on intent.${tone}`,\n def.text.inverse,\n def.intent[tone],\n floor.role,\n );\n }\n // `Select`'s open list (#164), named for the component because it used to\n // be the one surface the palette did not reach: the operating system\n // painted it. The rows are `text.primary` on `surface.raised`; a disabled\n // row is `text.muted`; the highlighted row is `text.inverse` on the field's\n // accent fill, and the chosen row's mark is that accent on the list. The\n // accent is whichever the caller passes, so every Emphasis and Intent is\n // measured rather than only the default. The values repeat pairs above —\n // the point is that removing one of those cannot silently un-gate the list.\n check('select.option: text.primary on surface.raised', def.text.primary, def.surface.raised, floor.role);\n check('select.option disabled: text.muted on surface.raised', def.text.muted, def.surface.raised, floor.role);\n check('select.placeholder: text.muted on surface.base', def.text.muted, def.surface.base, floor.role);\n const listAccents = [\n ...(['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]).map(\n (tone) => [`accent.${tone}`, def.accent[tone]] as const,\n ),\n ...(['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]).map(\n (tone) => [`intent.${tone}`, def.intent[tone]] as const,\n ),\n ];\n for (const [name, fill] of listAccents) {\n check(`select.option highlighted: text.inverse on ${name}`, def.text.inverse, fill, floor.role);\n check(`select.option selected mark: ${name} on surface.raised`, fill, def.surface.raised, floor.role);\n }\n\n // A scrim's job is to separate the dialog from the page behind it. Nothing\n // renders text on the scrim, so the assertion is about separation — and it\n // can be satisfied by either edge of the dialog, because this system draws\n // components with a load-bearing 2px border as often as with a fill. On a\n // dark level the fill barely differs from the scrim and the white border\n // does the work; on a light level the white fill does it and the dark\n // border is the one that disappears. Requiring both would fail every level.\n const scrimOverBase = composite(\n parseColor(def.surface.overlay),\n parseColor(def.surface.base),\n );\n const scrim = `rgb(${Math.round(scrimOverBase.r)}, ${Math.round(scrimOverBase.g)}, ${Math.round(scrimOverBase.b)})`;\n const separation = Math.max(\n contrastRatio(def.surface.raised, scrim),\n contrastRatio(def.border.strong, scrim),\n );\n results.push({\n level,\n pair: 'dialog (fill or border) against scrimmed page',\n foreground: `${def.surface.raised} / ${def.border.strong}`,\n background: scrim,\n ratio: separation,\n apca: null,\n minimum: MINIMUM_RATIO.overlaySeparation,\n passes: separation >= MINIMUM_RATIO.overlaySeparation,\n });\n }\n\n return results;\n}\n\n/**\n * How far apart the text tones sit, in APCA Lc, on each ground.\n *\n * Reported, not gated. It is the other half of tuning `text.muted`: darkening it\n * for legibility is free until it lands so close to `text.secondary` that the\n * two stop reading as two tones. #372 measured `#4f4a3d` on sketch at 7 Lc from\n * secondary, which is why `#5c5546` was chosen instead.\n */\nexport interface TextHierarchyStep {\n level: ThemeLevel;\n ground: string;\n /** Lc magnitude of primary, secondary and muted on this ground. */\n lc: Readonly<Record<'primary' | 'secondary' | 'muted', number>>;\n /** secondary minus muted, in Lc magnitude. */\n mutedStep: number;\n}\n\nexport function auditTextHierarchy(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): TextHierarchyStep[] {\n const steps: TextHierarchyStep[] = [];\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n for (const ground of ['base', 'raised', 'sunken'] as const) {\n const lc = (tone: 'primary' | 'secondary' | 'muted') =>\n Math.abs(apcaContrast(def.text[tone], def.surface[ground]));\n const tones = { primary: lc('primary'), secondary: lc('secondary'), muted: lc('muted') };\n steps.push({ level, ground: `surface.${ground}`, lc: tones, mutedStep: tones.secondary - tones.muted });\n }\n }\n return steps;\n}\n\n/** How a component may mark a selected item. */\nexport type SelectionDevice = 'fill' | 'edge' | 'surface pair';\n\nexport interface SelectionDeviceCheck {\n level: ThemeLevel;\n device: SelectionDevice;\n /** e.g. `accent.primary on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n minimum: number;\n /** For `fill` and `edge`: the device is usable. For `surface pair`: it would be, and that is the trap. */\n passes: boolean;\n}\n\n/**\n * The state rule, as arithmetic.\n *\n * Selected state is carried by an accent **fill** or an accent **edge**, never\n * by swapping one surface for another. The reason is not taste: the surfaces\n * exist to *layer* — a strip behind its tabs, a panel over a page — so they\n * are deliberately close in lightness, and on the light rungs they are a few\n * percent apart. A widget that marks its chosen tab `surface.base` among\n * `surface.raised` siblings reads acceptably on `midnight` and is invisible on\n * `bright`. That is how the bug ships: it passes review on the dark rung the\n * reviewer happens to be on.\n *\n * So this audits both halves. The fill and edge devices — the accent against\n * every surface a tab can sit on — must clear the non-text bar on every level,\n * which is what makes the rule safe to follow. The surface pairs are measured\n * too, and reported, so the number that makes them unusable is in the gate's\n * output rather than in someone's memory. They are not expected to pass; a\n * level on which they *did* would be the one where a surface-pair widget\n * slips through.\n */\nexport function auditSelectionDevices(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): SelectionDeviceCheck[] {\n const results: SelectionDeviceCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ] as const;\n\n const check = (\n device: SelectionDevice,\n pair: string,\n foreground: string,\n background: string,\n ) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n device,\n pair,\n foreground,\n background,\n ratio,\n minimum: MINIMUM_RATIO.stateDevice,\n passes: ratio >= MINIMUM_RATIO.stateDevice,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n // `quiet` is the de-emphasised step, not a fifth colour — a tab it\n // marks is meant to recede, so it is not a selection device.\n for (const tone of ['primary', 'secondary', 'tertiary'] as const satisfies readonly Emphasis[]) {\n check('fill', `accent.${tone} fill on ${groundName}`, def.accent[tone], ground);\n check('edge', `accent.${tone} edge on ${groundName}`, def.accent[tone], ground);\n }\n }\n\n check('surface pair', 'surface.raised against surface.base', def.surface.raised, def.surface.base);\n check('surface pair', 'surface.sunken against surface.base', def.surface.sunken, def.surface.base);\n check('surface pair', 'surface.sunken against surface.raised', def.surface.sunken, def.surface.raised);\n }\n\n return results;\n}\n"],"mappings":";AA4BA,IAAM,MAAM;AACZ,IAAM,SAAS;AAGR,SAAS,WAAW,OAAoB;AAC7C,QAAM,QAAQ,MAAM,KAAK;AAEzB,QAAM,MAAM,IAAI,KAAK,KAAK;AAC1B,MAAI,KAAK;AACP,UAAM,SAAS,IAAI,CAAC;AACpB,UAAM,SAAS,CAAC,MAAc,OAAO,SAAS,EAAE,WAAW,IAAI,IAAI,IAAI,GAAG,EAAE;AAC5E,QAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GAAG;AAC9C,aAAO;AAAA,QACL,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG,OAAO,OAAO,CAAC,CAAE;AAAA,QACpB,GAAG,OAAO,WAAW,IAAI,OAAO,OAAO,CAAC,CAAE,IAAI,MAAM;AAAA,MACtD;AAAA,IACF;AACA,QAAI,OAAO,WAAW,KAAK,OAAO,WAAW,GA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CAAC;AAAA,IACH;AAEA,eAAW,CAAC,YAAY,MAAM,KAAK,SAAS;AAG1C,iBAAW,QAAQ,CAAC,WAAW,aAAa,UAAU,GAA0C;AAC9F,cAAM,QAAQ,UAAU,IAAI,YAAY,UAAU,IAAI,IAAI,OAAO,IAAI,GAAG,MAAM;AAC9E,cAAM,QAAQ,UAAU,IAAI,YAAY,UAAU,IAAI,IAAI,OAAO,IAAI,GAAG,MAAM;AAAA,MAChF;AAAA,IACF;AAEA,UAAM,gBAAgB,uCAAuC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACjG,UAAM,gBAAgB,uCAAuC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACjG,UAAM,gBAAgB,yCAAyC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAAA,EACvG;AAEA,SAAO;AACT;","names":["sapc"]}
1
+ {"version":3,"sources":["../../src/theme/contrast.ts"],"sourcesContent":["/**\n * Contrast arithmetic over the ladder.\n *\n * Every colour in `levels.ts` is a literal, so contrast can be computed as data\n * — no browser, no screenshot, no rendering. `pnpm check:contrast` walks every\n * level and fails CI on a violation, which is the thing that makes the ladder\n * maintainable: every level times every role pair is a matrix nobody eyeballs\n * reliably twice.\n *\n * The gate is WCAG 2.1 relative luminance. APCA is the better predictor of\n * perceived contrast, but it is not yet normative and its thresholds are not\n * stable; WCAG ratios are what an audit will be run against. So APCA is\n * computed alongside and reported, never gated. It is reported because WCAG 2\n * overrates light text on a dark ground: midnight's `text.muted` passed at\n * 5.90:1 while scoring Lc -41, the weakest text pair in the system (#372).\n */\n\nimport type { Delta, DeltaGround, Emphasis, Hue, HueRef, Intent, TextTone } from '../lib/theme';\nimport type { LevelDefinition, ThemeLevel } from './levels';\n\nexport interface Rgb {\n r: number;\n g: number;\n b: number;\n /** 0–1. Colours without an alpha channel parse as 1. */\n a: number;\n}\n\nconst HEX = /^#([0-9a-f]{3,8})$/i;\nconst RGB_FN = /^rgba?\\(\\s*([0-9.]+)[\\s,]+([0-9.]+)[\\s,]+([0-9.]+)(?:[\\s,/]+([0-9.]+))?\\s*\\)$/i;\n\n/** Parse `#rgb`, `#rrggbb`, `#rrggbbaa`, `rgb()` and `rgba()`. */\nexport function parseColor(value: string): Rgb {\n const input = value.trim();\n\n const hex = HEX.exec(input);\n if (hex) {\n const digits = hex[1]!;\n const expand = (s: string) => Number.parseInt(s.length === 1 ? s + s : s, 16);\n if (digits.length === 3 || digits.length === 4) {\n return {\n r: expand(digits[0]!),\n g: expand(digits[1]!),\n b: expand(digits[2]!),\n a: digits.length === 4 ? expand(digits[3]!) / 255 : 1,\n };\n }\n if (digits.length === 6 || digits.length === 8) {\n return {\n r: expand(digits.slice(0, 2)),\n g: expand(digits.slice(2, 4)),\n b: expand(digits.slice(4, 6)),\n a: digits.length === 8 ? expand(digits.slice(6, 8)) / 255 : 1,\n };\n }\n }\n\n const fn = RGB_FN.exec(input);\n if (fn) {\n return {\n r: Number(fn[1]),\n g: Number(fn[2]),\n b: Number(fn[3]),\n a: fn[4] === undefined ? 1 : Number(fn[4]),\n };\n }\n\n throw new Error(`Unparseable colour: ${value}`);\n}\n\n/**\n * Flatten a possibly-translucent colour onto an opaque backdrop.\n *\n * Contrast is a property of what the eye receives, so a token with alpha has to\n * be composited before it can be measured. Without this step a scrim at 70%\n * would score against its own nominal colour and pass regardless of the surface\n * it actually sits on.\n */\nexport function composite(foreground: Rgb, backdrop: Rgb): Rgb {\n if (foreground.a >= 1) return foreground;\n const a = foreground.a;\n return {\n r: foreground.r * a + backdrop.r * (1 - a),\n g: foreground.g * a + backdrop.g * (1 - a),\n b: foreground.b * a + backdrop.b * (1 - a),\n a: 1,\n };\n}\n\n/** WCAG 2.1 relative luminance. */\nexport function relativeLuminance(color: Rgb): number {\n const channel = (value: number) => {\n const c = value / 255;\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;\n };\n return 0.2126 * channel(color.r) + 0.7152 * channel(color.g) + 0.0722 * channel(color.b);\n}\n\n/**\n * WCAG contrast ratio between two colours, 1–21.\n *\n * The foreground is composited onto the background first, so translucent\n * tokens are measured as they render.\n */\nexport function contrastRatio(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const lighter = Math.max(relativeLuminance(fg), relativeLuminance(bg));\n const darker = Math.min(relativeLuminance(fg), relativeLuminance(bg));\n return (lighter + 0.05) / (darker + 0.05);\n}\n\n/**\n * APCA lightness contrast (Lc), per APCA-W3 0.0.98G — roughly -108 to 106.\n *\n * Signed by polarity: positive is dark text on a light ground, negative is\n * light on dark, and the magnitude is what compares across the two. Unlike a\n * WCAG ratio it is not symmetric, which is the point: the same pair of colours\n * reads differently depending on which one is the text.\n *\n * Constants are the published 0.0.98G set; the luminance is APCA's own simple\n * 2.4 power curve, not WCAG's piecewise one. Reported, not gated — see the\n * module comment.\n */\nexport function apcaContrast(foreground: string, background: string): number {\n const bg = parseColor(background);\n const fg = composite(parseColor(foreground), bg);\n const y = (c: Rgb) =>\n 0.2126729 * (c.r / 255) ** 2.4 + 0.7151522 * (c.g / 255) ** 2.4 + 0.072175 * (c.b / 255) ** 2.4;\n const clamp = (lum: number) => (lum > 0.022 ? lum : lum + (0.022 - lum) ** 1.414);\n const text = clamp(y(fg));\n const ground = clamp(y(bg));\n if (Math.abs(ground - text) < 0.0005) return 0;\n if (ground > text) {\n const sapc = (ground ** 0.56 - text ** 0.57) * 1.14;\n return sapc < 0.1 ? 0 : (sapc - 0.027) * 100;\n }\n const sapc = (ground ** 0.65 - text ** 0.62) * 1.14;\n return sapc > -0.1 ? 0 : (sapc + 0.027) * 100;\n}\n\n/**\n * The bar each role has to clear, and why it differs.\n *\n * `text` and the accents clear WCAG AA for body copy, because they are read.\n * `borderStrong` and `borderDefault` clear the 3:1 non-text bar of WCAG 1.4.11,\n * because they are the load-bearing edges this system draws components with.\n * `borderSubtle` is a decorative divider — 1.4.11 does not cover it, so the bar\n * is only that it must be *visible* rather than accessible as a control.\n * Setting it to AA would force every hairline in the system to read as a rule.\n */\n/**\n * The Hue vocabulary, in wheel order. Declared here rather than imported so the\n * gate stays runnable by `scripts/check-contrast.mjs` without a `.ts` import\n * extension — and `satisfies` still makes a missing or misspelled Hue a\n * compile error, which is the property that matters.\n */\n/**\n * Above this, a colour declared `'neutral'` is not one. `accent.quiet` measures\n * 0.036 on `midnight` and 0.027 on `sketch` — both warm or cool greys with a\n * deliberate tint, which is why the bar is not zero.\n */\nexport const MAXIMUM_NEUTRAL_CHROMA = 0.045;\n\nexport interface HueAgreementCheck {\n readonly level: ThemeLevel;\n readonly role: string;\n readonly declared: HueRef;\n readonly value: string;\n /** The Hue's value, or null when the Role is declared `'neutral'`. */\n readonly expected: string | null;\n readonly passes: boolean;\n readonly detail: string;\n}\n\n/** OKLab chroma. Only used to prove a `'neutral'` really is one. */\nfunction oklabChroma(hex: string): number {\n const decode = (v: number) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);\n const [r, g, b] = [1, 3, 5].map((i) => decode(Number.parseInt(hex.slice(i, i + 2), 16) / 255));\n const l = Math.cbrt(0.4122214708 * r! + 0.5363325363 * g! + 0.0514459929 * b!);\n const m = Math.cbrt(0.2119034982 * r! + 0.6806995451 * g! + 0.1073969566 * b!);\n const s = Math.cbrt(0.0883024619 * r! + 0.2817188376 * g! + 0.6299787005 * b!);\n const a = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;\n const bb = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;\n return Math.hypot(a, bb);\n}\n\nconst PALETTE_HUES_ORDER = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\nexport const MINIMUM_RATIO = {\n text: 4.5,\n /** `text.inverse` sits on an accent fill, not on a surface. */\n textInverse: 4.5,\n accent: 4.5,\n intent: 4.5,\n /**\n * A Hue, above WCAG AA deliberately. An editor draws selection, current-line,\n * find-match and diff backgrounds *behind* the same tokens, so a palette\n * solved to exactly 4.5:1 has no room left to tint the ground. At 4.5 the\n * light palette has one sRGB step of headroom; at 5.5 it has twenty-two.\n * See `docs/palette-provenance.md` and #78.\n */\n palette: 5.5,\n /**\n * These numbers are the **web** Medium's, and that indexing is the point.\n *\n * ADR 0004 names this the asymmetry most likely to be got wrong later:\n * *colour values do not vary by Medium, but the floors they must clear do.* A\n * projected 1080p frame, a compression-damaged video and an unantialiased\n * terminal cell are not the browser's legibility problem, and until now this\n * was one set of numbers for every surface the system emits to.\n *\n * `MEDIA_DEFINITIONS[medium].contrastFloor` carries the per-Medium values;\n * `auditContrast` takes a Medium and reads them. The constants here remain as\n * the web Medium's, so nothing moves on merge and a caller that does not care\n * about Media keeps working.\n */\n /** `bright` Hues carry emphasis, not body text, so AA is the right bar. */\n paletteBright: 4.5,\n borderStrong: 3,\n borderDefault: 3,\n borderSubtle: 1.4,\n /**\n * A modal's dialog against the scrimmed page behind it. Not an accessibility\n * threshold — an assertion that the scrim does the one job it exists for.\n */\n overlaySeparation: 3,\n /**\n * A selection device — the accent `fill` behind a chosen tab, or the 4px\n * accent `edge` beside it — against the surface it sits on. WCAG 1.4.11's\n * non-text bar: the device is a UI component boundary, not text.\n */\n stateDevice: 3,\n} as const;\n\nexport interface ContrastCheck {\n level: ThemeLevel;\n /** e.g. `text.muted on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n /** APCA Lc for the same pair, reported alongside the ratio and never gated. Null where the pair is a separation rather than a foreground on a ground. */\n apca: number | null;\n minimum: number;\n passes: boolean;\n}\n\n/**\n * Every pair worth asserting, for every level.\n *\n * Text, accents and intents are checked against `base`, `raised` *and*\n * `sunken`, because a component is free to sit on any of the three and a token\n * that only works on the page ground is a bug waiting for the first card.\n *\n * The ladder is passed in rather than imported so this module is pure colour\n * arithmetic over data — it can audit a consumer's own overrides, and it stays\n * runnable from a plain Node script with no bundler in the path.\n */\n/**\n * Does every Role actually hold the value of the Hue it says it is?\n *\n * `check:contrast` cannot answer this, and that is not an oversight in it — a\n * Role and a Hue are both foregrounds, both clear their own floors, and a\n * mismatch between them is not a contrast fault. It is a *drift* fault, and it\n * is the one ADR 0001 rejects its third option over:\n *\n * > the two sets then drift silently, and there is no arithmetic that can\n * > catch a `palette.cyan` that no longer matches the `accent.primary` it is\n * > supposed to be.\n *\n * This is that arithmetic. It exists because the repo shipped the fault: after\n * `palette` landed, `midnight`'s `accent.tertiary` sat at `#ec4899` (5.12:1,\n * clearing the 4.5 Role floor) while `palette.pink` sat at `#f955a4` (5.90:1,\n * clearing the 5.5 Hue floor). Both gates passed. The two values are 0.036\n * apart in OKLab — indistinguishable, so no screenshot would have caught it\n * either.\n *\n * A Role declared `'neutral'` is asserted to *be* neutral rather than skipped,\n * because \"declared as not-a-hue\" and \"quietly wrong\" must not look the same.\n */\nexport function auditHueAgreement(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): HueAgreementCheck[] {\n const results: HueAgreementCheck[] = [];\n\n for (const level of Object.keys(ladder) as ThemeLevel[]) {\n const def = ladder[level];\n\n const check = (role: string, value: string, ref: HueRef) => {\n if (ref === 'neutral') {\n const chroma = oklabChroma(value);\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected: null,\n passes: chroma <= MAXIMUM_NEUTRAL_CHROMA,\n detail: `chroma ${chroma.toFixed(3)} (max ${MAXIMUM_NEUTRAL_CHROMA})`,\n });\n return;\n }\n const expected = def.palette[ref];\n results.push({\n level,\n role,\n declared: ref,\n value,\n expected,\n passes: value.toLowerCase() === expected.toLowerCase(),\n detail: `palette.${ref} is ${expected}`,\n });\n };\n\n for (const [role, ref] of Object.entries(def.accentHue)) {\n check(`accent.${role}`, def.accent[role as Emphasis], ref);\n }\n for (const [role, ref] of Object.entries(def.intentHue)) {\n check(`intent.${role}`, def.intent[role as Intent], ref);\n }\n for (const [role, ref] of Object.entries(def.deltaHue)) {\n check(`delta.${role}`, def.delta[role as Delta], ref);\n }\n }\n\n return results;\n}\n\n/** The three floors a Medium supplies. See `MediumDefinition.contrastFloor`. */\nexport interface ContrastFloor {\n readonly role: number;\n readonly hue: number;\n readonly hueBright: number;\n}\n\n/** The web Medium's floors, restated so the default call is unchanged. */\nexport const WEB_FLOOR: ContrastFloor = {\n role: MINIMUM_RATIO.text,\n hue: MINIMUM_RATIO.palette,\n hueBright: MINIMUM_RATIO.paletteBright,\n};\n\nexport function auditContrast(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n /**\n * The Medium's floors. Passed in rather than read from `media.ts`, because\n * this module has to stay importable by `scripts/check-contrast.mjs`, and a\n * runtime import there needs a `.ts` extension that `tsc` rejects. The script\n * owns the Medium; this module owns the arithmetic.\n */\n floor: ContrastFloor = WEB_FLOOR,\n): ContrastCheck[] {\n const results: ContrastCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ['surface.sunken', def.surface.sunken],\n ] as const;\n\n const check = (pair: string, foreground: string, background: string, minimum: number) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n pair,\n foreground,\n background,\n ratio,\n apca: apcaContrast(foreground, background),\n minimum,\n passes: ratio >= minimum,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n for (const tone of ['primary', 'secondary', 'muted'] as const satisfies readonly TextTone[]) {\n check(`text.${tone} on ${groundName}`, def.text[tone], ground, floor.role);\n }\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(`accent.${tone} on ${groundName}`, def.accent[tone], ground, floor.role);\n }\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(`intent.${tone} on ${groundName}`, def.intent[tone], ground, floor.role);\n }\n for (const tone of ['added', 'removed', 'moved'] as const satisfies readonly Delta[]) {\n check(`delta.${tone} on ${groundName}`, def.delta[tone], ground, floor.role);\n }\n // ADR 0001: gate `palette` once per Hue rather than once per Role that\n // consumes it. Separate the palette, not each of its consumers.\n for (const hue of PALETTE_HUES_ORDER) {\n check(`palette.${hue} on ${groundName}`, def.palette[hue], ground, floor.hue);\n check(\n `palette.bright.${hue} on ${groundName}`,\n def.paletteBright[hue],\n ground,\n floor.hueBright,\n );\n }\n check(`border.strong on ${groundName}`, def.border.strong, ground, MINIMUM_RATIO.borderStrong);\n check(`border.default on ${groundName}`, def.border.default, ground, MINIMUM_RATIO.borderDefault);\n check(`border.subtle on ${groundName}`, def.border.subtle, ground, MINIMUM_RATIO.borderSubtle);\n }\n\n // `text.inverse` is what a filled accent button prints in, so it is measured\n // against the accents rather than against a surface.\n // `quiet` is in this list because `Tag` ships `bg-accent-quiet\n // text-content-inverse`. It was omitted while the other three were checked,\n // so a palette edit to `quiet` would have gone unmeasured — a coverage gap\n // rather than a live defect, but the README claims every pair is audited.\n for (const tone of ['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]) {\n check(\n `text.inverse on accent.${tone}`,\n def.text.inverse,\n def.accent[tone],\n floor.role,\n );\n }\n // `FileChangeTree` prints its change mark in `text.inverse` on a `delta` fill.\n for (const tone of ['added', 'removed', 'moved'] as const satisfies readonly Delta[]) {\n check(`text.inverse on delta.${tone}`, def.text.inverse, def.delta[tone], floor.role);\n }\n check('text.inverse on text.secondary', def.text.inverse, def.text.secondary, floor.role);\n for (const tone of ['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]) {\n check(\n `text.inverse on intent.${tone}`,\n def.text.inverse,\n def.intent[tone],\n floor.role,\n );\n }\n // A diff row: the line in `text.primary`, its sign in the matching `delta`\n // role, both on that row's ground. The hunk header is `text.secondary`.\n for (const tone of ['added', 'removed'] as const satisfies readonly DeltaGround[]) {\n check(`diff row: text.primary on deltaGround.${tone}`, def.text.primary, def.deltaGround[tone], floor.role);\n check(`diff sign: delta.${tone} on deltaGround.${tone}`, def.delta[tone], def.deltaGround[tone], floor.role);\n }\n check('diff hunk: text.secondary on deltaGround.hunk', def.text.secondary, def.deltaGround.hunk, floor.role);\n // `Select`'s open list (#164), named for the component because it used to\n // be the one surface the palette did not reach: the operating system\n // painted it. The rows are `text.primary` on `surface.raised`; a disabled\n // row is `text.muted`; the highlighted row is `text.inverse` on the field's\n // accent fill, and the chosen row's mark is that accent on the list. The\n // accent is whichever the caller passes, so every Emphasis and Intent is\n // measured rather than only the default. The values repeat pairs above —\n // the point is that removing one of those cannot silently un-gate the list.\n check('select.option: text.primary on surface.raised', def.text.primary, def.surface.raised, floor.role);\n check('select.option disabled: text.muted on surface.raised', def.text.muted, def.surface.raised, floor.role);\n check('select.placeholder: text.muted on surface.base', def.text.muted, def.surface.base, floor.role);\n const listAccents = [\n ...(['primary', 'secondary', 'tertiary', 'quiet'] as const satisfies readonly Emphasis[]).map(\n (tone) => [`accent.${tone}`, def.accent[tone]] as const,\n ),\n ...(['info', 'success', 'warning', 'danger'] as const satisfies readonly Intent[]).map(\n (tone) => [`intent.${tone}`, def.intent[tone]] as const,\n ),\n ];\n for (const [name, fill] of listAccents) {\n check(`select.option highlighted: text.inverse on ${name}`, def.text.inverse, fill, floor.role);\n check(`select.option selected mark: ${name} on surface.raised`, fill, def.surface.raised, floor.role);\n }\n\n // A scrim's job is to separate the dialog from the page behind it. Nothing\n // renders text on the scrim, so the assertion is about separation — and it\n // can be satisfied by either edge of the dialog, because this system draws\n // components with a load-bearing 2px border as often as with a fill. On a\n // dark level the fill barely differs from the scrim and the white border\n // does the work; on a light level the white fill does it and the dark\n // border is the one that disappears. Requiring both would fail every level.\n const scrimOverBase = composite(\n parseColor(def.surface.overlay),\n parseColor(def.surface.base),\n );\n const scrim = `rgb(${Math.round(scrimOverBase.r)}, ${Math.round(scrimOverBase.g)}, ${Math.round(scrimOverBase.b)})`;\n const separation = Math.max(\n contrastRatio(def.surface.raised, scrim),\n contrastRatio(def.border.strong, scrim),\n );\n results.push({\n level,\n pair: 'dialog (fill or border) against scrimmed page',\n foreground: `${def.surface.raised} / ${def.border.strong}`,\n background: scrim,\n ratio: separation,\n apca: null,\n minimum: MINIMUM_RATIO.overlaySeparation,\n passes: separation >= MINIMUM_RATIO.overlaySeparation,\n });\n }\n\n return results;\n}\n\n/**\n * How far apart the text tones sit, in APCA Lc, on each ground.\n *\n * Reported, not gated. It is the other half of tuning `text.muted`: darkening it\n * for legibility is free until it lands so close to `text.secondary` that the\n * two stop reading as two tones. #372 measured `#4f4a3d` on sketch at 7 Lc from\n * secondary, which is why `#5c5546` was chosen instead.\n */\nexport interface TextHierarchyStep {\n level: ThemeLevel;\n ground: string;\n /** Lc magnitude of primary, secondary and muted on this ground. */\n lc: Readonly<Record<'primary' | 'secondary' | 'muted', number>>;\n /** secondary minus muted, in Lc magnitude. */\n mutedStep: number;\n}\n\nexport function auditTextHierarchy(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): TextHierarchyStep[] {\n const steps: TextHierarchyStep[] = [];\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n for (const ground of ['base', 'raised', 'sunken'] as const) {\n const lc = (tone: 'primary' | 'secondary' | 'muted') =>\n Math.abs(apcaContrast(def.text[tone], def.surface[ground]));\n const tones = { primary: lc('primary'), secondary: lc('secondary'), muted: lc('muted') };\n steps.push({ level, ground: `surface.${ground}`, lc: tones, mutedStep: tones.secondary - tones.muted });\n }\n }\n return steps;\n}\n\n/** How a component may mark a selected item. */\nexport type SelectionDevice = 'fill' | 'edge' | 'surface pair';\n\nexport interface SelectionDeviceCheck {\n level: ThemeLevel;\n device: SelectionDevice;\n /** e.g. `accent.primary on surface.raised`. */\n pair: string;\n foreground: string;\n background: string;\n ratio: number;\n minimum: number;\n /** For `fill` and `edge`: the device is usable. For `surface pair`: it would be, and that is the trap. */\n passes: boolean;\n}\n\n/**\n * The state rule, as arithmetic.\n *\n * Selected state is carried by an accent **fill** or an accent **edge**, never\n * by swapping one surface for another. The reason is not taste: the surfaces\n * exist to *layer* — a strip behind its tabs, a panel over a page — so they\n * are deliberately close in lightness, and on the light rungs they are a few\n * percent apart. A widget that marks its chosen tab `surface.base` among\n * `surface.raised` siblings reads acceptably on `midnight` and is invisible on\n * `bright`. That is how the bug ships: it passes review on the dark rung the\n * reviewer happens to be on.\n *\n * So this audits both halves. The fill and edge devices — the accent against\n * every surface a tab can sit on — must clear the non-text bar on every level,\n * which is what makes the rule safe to follow. The surface pairs are measured\n * too, and reported, so the number that makes them unusable is in the gate's\n * output rather than in someone's memory. They are not expected to pass; a\n * level on which they *did* would be the one where a surface-pair widget\n * slips through.\n */\nexport function auditSelectionDevices(\n ladder: Readonly<Record<ThemeLevel, LevelDefinition>>,\n): SelectionDeviceCheck[] {\n const results: SelectionDeviceCheck[] = [];\n\n for (const [level, def] of Object.entries(ladder) as [ThemeLevel, LevelDefinition][]) {\n const grounds = [\n ['surface.base', def.surface.base],\n ['surface.raised', def.surface.raised],\n ] as const;\n\n const check = (\n device: SelectionDevice,\n pair: string,\n foreground: string,\n background: string,\n ) => {\n const ratio = contrastRatio(foreground, background);\n results.push({\n level,\n device,\n pair,\n foreground,\n background,\n ratio,\n minimum: MINIMUM_RATIO.stateDevice,\n passes: ratio >= MINIMUM_RATIO.stateDevice,\n });\n };\n\n for (const [groundName, ground] of grounds) {\n // `quiet` is the de-emphasised step, not a fifth colour — a tab it\n // marks is meant to recede, so it is not a selection device.\n for (const tone of ['primary', 'secondary', 'tertiary'] as const satisfies readonly Emphasis[]) {\n check('fill', `accent.${tone} fill on ${groundName}`, def.accent[tone], ground);\n check('edge', `accent.${tone} edge on ${groundName}`, def.accent[tone], ground);\n }\n }\n\n check('surface pair', 'surface.raised against surface.base', def.surface.raised, def.surface.base);\n check('surface pair', 'surface.sunken against surface.base', def.surface.sunken, def.surface.base);\n check('surface pair', 'surface.sunken against surface.raised', def.surface.sunken, def.surface.raised);\n }\n\n return results;\n}\n"],"mappings":";AA4BA,IAAM,MAAM;AACZ,IAAM,SAAS;A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AClD,cAAQ,KAAK;AAAA,QACX;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,SAAS,cAAc;AAAA,QACvB,QAAQ,SAAS,cAAc;AAAA,MACjC,CAAC;AAAA,IACH;AAEA,eAAW,CAAC,YAAY,MAAM,KAAK,SAAS;AAG1C,iBAAW,QAAQ,CAAC,WAAW,aAAa,UAAU,GAA0C;AAC9F,cAAM,QAAQ,UAAU,IAAI,YAAY,UAAU,IAAI,IAAI,OAAO,IAAI,GAAG,MAAM;AAC9E,cAAM,QAAQ,UAAU,IAAI,YAAY,UAAU,IAAI,IAAI,OAAO,IAAI,GAAG,MAAM;AAAA,MAChF;AAAA,IACF;AAEA,UAAM,gBAAgB,uCAAuC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACjG,UAAM,gBAAgB,uCAAuC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,IAAI;AACjG,UAAM,gBAAgB,yCAAyC,IAAI,QAAQ,QAAQ,IAAI,QAAQ,MAAM;AAAA,EACvG;AAEA,SAAO;AACT;","names":["sapc"]}
@@ -58,6 +58,17 @@ var LEVELS = {
58
58
  warning: "#facc15",
59
59
  danger: "#f955a4"
60
60
  },
61
+ delta: {
62
+ added: "#39ff14",
63
+ removed: "#ff586e",
64
+ // red, not intent.danger's pink: a removal is not an alarm
65
+ moved: "#c3afff"
66
+ },
67
+ deltaGround: {
68
+ added: "#0f2a17",
69
+ removed: "#2e1020",
70
+ hunk: "#1c1c38"
71
+ },
61
72
  accentHue: {
62
73
  primary: "cyan",
63
74
  secondary: "yellow",
@@ -70,6 +81,11 @@ var LEVELS = {
70
81
  warning: "yellow",
71
82
  danger: "pink"
72
83
  },
84
+ deltaHue: {
85
+ added: "green",
86
+ removed: "red",
87
+ moved: "violet"
88
+ },
73
89
  palette: {
74
90
  red: "#ff586e",
75
91
  // 16deg — lifted from #f43f5e (dim accent.tertiary), 4.59:1
@@ -151,6 +167,16 @@ var LEVELS = {
151
167
  warning: "#974503",
152
168
  danger: "#bd0010"
153
169
  },
170
+ delta: {
171
+ added: "#006b2e",
172
+ removed: "#bd0010",
173
+ moved: "#7d00f4"
174
+ },
175
+ deltaGround: {
176
+ added: "#dcefdc",
177
+ removed: "#f6dcd8",
178
+ hunk: "#e7e2d4"
179
+ },
154
180
  accentHue: {
155
181
  primary: "blue",
156
182
  secondary: "green",
@@ -163,6 +189,11 @@ var LEVELS = {
163
189
  warning: "orange",
164
190
  danger: "red"
165
191
  },
192
+ deltaHue: {
193
+ added: "green",
194
+ removed: "red",
195
+ moved: "violet"
196
+ },
166
197
  palette: {
167
198
  red: "#bd0010",
168
199
  // 16deg — was #dc2626, 4.03:1 — failed WCAG AA
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/theme/levels.ts"],"sourcesContent":["/**\n * The theme ladder — the single place a level name or a level's colour is written.\n *\n * Everything else in the system derives from this file: the CSS in\n * `theme.generated.css`, the runtime provider, the Storybook toolbar, the\n * walkthrough matrix, and the contrast gate. Adding a level here is a type\n * error everywhere it has not been handled; adding a *role* is a type error in\n * every level at once. That is the guarantee — not a convention.\n *\n * ## Why a ladder and not a polarity, at two levels\n *\n * The ladder ran to four rungs — `midnight`, `dim`, `bright`, `white` — on the\n * argument that two themes can share a polarity and still want different\n * grounds. That argument was sound; the assumption under it was not. Nothing\n * consumed the fourth rung and nothing reached the second, so three of the four\n * were paid for and never collected. The pair is `midnight` and `light`.\n *\n * Polarity nevertheless stays a *declared property of a level* rather than the\n * axis, and this is worth stating because the collapse is usually assumed to\n * end it. It does not, because **neither level is named for its polarity**:\n * `midnight` has polarity `dark`, `sketch` has polarity `light`. So\n * {@link SYSTEM_LEVEL} still has a real job — mapping two media states onto two\n * names that are neither of them — and a `Record<Polarity, T>` remains a\n * different type from a `Record<ThemeLevel, T>`. Had the levels been called\n * `dark` and `light` the two would have collapsed into one thing and polarity\n * could have gone with them.\n *\n * Both polarity variants therefore survive: `dark:` and `light:` each span a\n * polarity rather than naming a level, so neither collides with a level\n * variant. `midnight` names a ground; `sketch` names a surface and a way of\n * drawing on it. Neither is a synonym for its polarity, which is the property\n * that keeps a third level cheap.\n *\n * ## Why every value is a literal\n *\n * The previous token layer derived surfaces, text and borders from two poles\n * with `color-mix()` percentages. Percentages tuned against near-black do not\n * hold at the light end — `border-subtle` at 28% is a visible hairline on\n * black and invisible on paper. Literals also make the ladder *checkable*:\n * `pnpm check:contrast` can compute every text-on-surface ratio without a\n * browser — 260 pairs, 130 per Level, including every Hue against every\n * ground, which is what makes hand-tuned literals sustainable rather than\n * twenty times the manual review. Stated per Level deliberately: 440 was\n * written here in the commit that collapsed four Levels to two, so the total\n * was stale the moment it was typed.\n *\n * The one exception is `surface.overlay`, which is a scrim and needs alpha.\n */\n\nimport type { BorderTone, Emphasis, Hue, HueRef, Intent, Surface, TextTone } from '../lib/theme';\n\n/**\n * The ladder, ordered from darkest to lightest. Order is meaningful: it is what\n * `cycleLevel` steps through and what the Storybook toolbar and walkthrough\n * matrix render in.\n */\nexport const THEME_LEVELS = ['midnight', 'sketch'] as const;\n\n/** A level of the ladder. */\nexport type ThemeLevel = (typeof THEME_LEVELS)[number];\n\n/**\n * Whether a level reads as dark-on-light or light-on-dark. Declared per level\n * rather than inferred, because it drives things a luminance calculation should\n * not silently decide: the `color-scheme` property (which controls native form\n * controls, scrollbars and the caret), the `dark:`/`light:` Tailwind variants,\n * and the `prefers-color-scheme` mapping.\n */\nexport type Polarity = 'dark' | 'light';\n\n/**\n * The three colours that do **not** vary by level.\n *\n * Every other colour in this module is declared once per level and swaps with\n * it. These do not, and that invariance is the whole point: `#ffffff` means\n * *white*, not \"whatever this level calls its lightest ground\". The\n * `--color-black` / `--color-white` compat aliases are the counter-example —\n * they track `surface.base` and `text.primary`, so `--color-black` resolves to\n * `#ffffff` on the `white` level. A token named for an appearance, holding the\n * opposite appearance.\n *\n * Use these when true black or true white is genuinely meant: a print surface,\n * an SVG fill, a scrim. Not as a page ground — that is `surface.base`.\n */\nexport const FIXED_COLOURS = {\n black: '#000000',\n white: '#ffffff',\n transparent: 'transparent',\n} as const;\n\nexport type FixedColour = keyof typeof FIXED_COLOURS;\n\n/**\n * The Hue vocabulary, in wheel order starting at red.\n *\n * Ten is the ceiling, not a comfortable middle: the tightest pair already sits\n * at deltaE 0.049 on the light levels, and an eleventh candidate was dropped\n * during derivation for landing 13 degrees from the measured blue at deltaE\n * 0.024. Adding one means checking the separation gate, not just this array.\n */\nexport const PALETTE_HUES = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\n/**\n * Every colour a level must define. Adding a field here is a compile error in\n * all four levels until each one answers it — the property that a bare string\n * union cannot provide.\n */\nexport interface LevelDefinition {\n /** Human-facing name, used in the Storybook toolbar and the sandbox. */\n readonly label: string;\n /** One line on what the level is for. Rendered in the sandbox. */\n readonly description: string;\n readonly polarity: Polarity;\n readonly surface: Readonly<Record<Surface, string>>;\n readonly text: Readonly<Record<TextTone, string>>;\n readonly border: Readonly<Record<BorderTone, string>>;\n readonly accent: Readonly<Record<Emphasis, string>>;\n readonly intent: Readonly<Record<Intent, string>>;\n /**\n * The Hue vocabulary — appearance, not job. Declared *below* the Roles above\n * and referenced by them, never derived from them. Only a Target with no\n * notion of jobs addresses these: a terminal's sixteen ANSI slots, half a\n * JetBrains scheme, a generated diagram needing N distinguishable colours.\n *\n * Every entry clears 5.5:1 against the tightest of this level's three\n * grounds — above WCAG AA, so an editor still has room to tint the ground\n * behind it. `bright` fills the upper eight ANSI slots at a 4.5:1 floor,\n * since those carry emphasis rather than body text.\n */\n readonly palette: Readonly<Record<Hue, string>>;\n /** The `bright` half of each Hue. ANSI's upper eight, and nothing else yet. */\n readonly paletteBright: Readonly<Record<Hue, string>>;\n /**\n * Which Hue each Role is. **The declared lookup ADR 0001 requires.**\n *\n * The ADR rejects deriving this by inspecting hex — ambiguous when two Roles\n * share a value, lossy when no Hue sits on a Role's. So it is declared, and\n * `check:contrast` asserts the Role's value actually equals the Hue's. That\n * assertion is the point: without it the two vocabularies drift silently,\n * which is the failure the ADR's rejected \"both, independently declared\"\n * option was rejected for — and which this repo shipped for exactly one\n * commit, with two pinks on `midnight` 0.036 apart.\n */\n readonly accentHue: Readonly<Record<Emphasis, HueRef>>;\n /** As `accentHue`, for the meaning Roles. */\n readonly intentHue: Readonly<Record<Intent, HueRef>>;\n /** Colour of the hard offset shadows. Normally tracks `border.strong`. */\n readonly shadow: string;\n}\n\n/**\n * Surfaces do not move in the same direction on every level, and that is the\n * point of declaring them.\n *\n * On the dark levels a raised card sits *above* the page and so lightens. On\n * `bright` — a warm desk with paper on it — a raised card is a fresh white\n * sheet, so it also lightens, but past the ground rather than away from black.\n * On `white` there is nowhere lighter to go, so elevation is carried by the\n * hard border and shadow while the panel itself takes a faint cool grey. A\n * single derived formula cannot express those three behaviours; four literal\n * ramps can.\n */\nexport const LEVELS: Readonly<Record<ThemeLevel, LevelDefinition>> = {\n midnight: {\n label: 'Midnight',\n description: 'Neon on blue-black. The maximal end of the ladder.',\n polarity: 'dark',\n surface: {\n base: '#0a0a1a',\n raised: '#14142a',\n sunken: '#050510',\n overlay: 'rgba(5, 5, 16, 0.82)',\n },\n text: {\n primary: '#ffffff',\n secondary: '#c3c3d4',\n // Was #8b8ba3: 5.90:1, but APCA Lc -41, the weakest text pair in the\n // system. WCAG 2 overrates light-on-dark. Now 7.39:1 / Lc -50, still 21 Lc\n // below `secondary`. accent.quiet keeps the old value — a fill, not text.\n muted: '#9d9db4',\n inverse: '#0a0a1a',\n },\n border: {\n strong: '#ffffff',\n default: '#9d9db4',\n subtle: '#33334d',\n },\n accent: {\n primary: '#22d3ee',\n secondary: '#facc15',\n // Was #ec4899 — the brand pink, and 5.12:1, which cleared the 4.5 Role\n // floor while `palette.pink` sat at 5.90:1. Two pinks 0.036 apart in one\n // level, invisibly different and therefore worse than visibly. Now the\n // Hue's value, per `accentHue` below.\n tertiary: '#f955a4',\n quiet: '#8b8ba3',\n },\n intent: {\n info: '#22d3ee',\n success: '#39ff14',\n warning: '#facc15',\n danger: '#f955a4',\n },\n accentHue: {\n primary: 'cyan',\n secondary: 'yellow',\n tertiary: 'pink',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'cyan',\n success: 'green',\n warning: 'yellow',\n danger: 'pink',\n },\n palette: {\n red: '#ff586e', // 16deg — lifted from #f43f5e (dim accent.tertiary), 4.59:1\n orange: '#ff8c00', // 58deg — kept — 410 commits\n yellow: '#facc15', // 92deg — kept — 533 commits, brand\n green: '#39ff14', // 142deg — kept — 533 commits, brand\n teal: '#34d399', // 163deg — kept — 364 commits\n cyan: '#22d3ee', // 212deg — kept — 534 commits, brand\n blue: '#38bdf8', // 233deg — kept — dim accent.primary, 233deg (a sky blue by heritage)\n violet: '#c3afff', // 295deg — new — 57 tried across six years, none canonical\n magenta: '#ff1cff', // 328deg — lifted from #ff00ff, 5.37:1\n pink: '#f955a4', // 354deg — lifted from #ec4899 (brand), 4.77:1 — deltaE 0.036\n },\n paletteBright: {\n red: '#ff939b',\n orange: '#ffba85',\n yellow: '#ffeaab',\n green: '#c0ffb8',\n teal: '#00f7ae',\n cyan: '#88ebff',\n blue: '#8cd7ff',\n violet: '#ddd4ff',\n magenta: '#ff88fd',\n pink: '#ff8ebe',\n },\n shadow: '#ffffff',\n },\n\n sketch: {\n label: 'Sketch',\n description: 'Warm paper and pen ink. The light half of the pair.',\n polarity: 'light',\n surface: {\n base: '#f5f3ec', // sketch paper\n raised: '#ffffff', // FIXED_COLOURS.white — a fresh sheet on the desk\n sunken: '#efeadf', // the binding ground: every value below is solved against this\n overlay: 'rgba(35, 38, 46, 0.72)',\n },\n text: {\n primary: '#23262e', // sketch ink\n secondary: '#33373f',\n // Was #6a6252: 5.03:1 / APCA Lc 68 on `sunken`, carried by 11px labels.\n // Now 6.16:1 / Lc 73 there. Darker still (#4f4a3d) left muted 7 Lc from\n // `secondary`, and the two tones stopped reading as two. accent.quiet keeps\n // the old value.\n muted: '#5c5546',\n inverse: '#f5f3ec',\n },\n border: {\n strong: '#23262e',\n default: '#8f8672',\n subtle: '#c8c3b4', // darker than sketch's #d8d3c4, which was 1.25:1 on a pure-white `raised`\n },\n accent: {\n primary: '#1450d7', // palette.blue\n secondary: '#006b2e', // palette.green\n tertiary: '#bd0010', // palette.red\n quiet: '#6a6252',\n },\n intent: {\n info: '#1450d7',\n success: '#006b2e',\n warning: '#974503',\n danger: '#bd0010',\n },\n accentHue: {\n primary: 'blue',\n secondary: 'green',\n tertiary: 'red',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'blue',\n success: 'green',\n warning: 'orange',\n danger: 'red',\n },\n palette: {\n red: '#bd0010', // 16deg — was #dc2626, 4.03:1 — failed WCAG AA\n orange: '#974503', // 58deg — was #9a4708, 5.34:1\n yellow: '#705a00', // 92deg — new — no light yellow was ever authored\n green: '#006b2e', // 142deg — was #15803d, 4.18:1 — failed\n teal: '#006859', // 163deg — new\n cyan: '#006675', // 212deg — new\n blue: '#1450d7', // 233deg — was #2563eb, 4.31:1 — failed\n violet: '#7d00f4', // 295deg — new\n magenta: '#a300ad', // 328deg — new\n pink: '#b4006c', // 354deg — new\n },\n paletteBright: {\n red: '#8f002a',\n orange: '#6c3700',\n yellow: '#534200',\n green: '#024f00',\n teal: '#004d34',\n cyan: '#004b56',\n blue: '#004e6d',\n violet: '#6000bd',\n magenta: '#7f0080',\n pink: '#8a0052',\n },\n shadow: '#23262e',\n },\n};\n\n/** The level applied when nothing else has been chosen or persisted. */\nexport const DEFAULT_LEVEL: ThemeLevel = 'midnight';\n\n/**\n * Which level each OS colour-scheme preference maps to. `prefers-color-scheme`\n * is binary, so the ladder has to nominate a representative at each end; making\n * that an explicit constant means it can be changed in one place rather than\n * being an accident of ordering.\n */\nexport const SYSTEM_LEVEL: Readonly<Record<Polarity, ThemeLevel>> = {\n dark: 'midnight',\n light: 'sketch',\n};\n\n/**\n * The weight running text is drawn at, by polarity — not by level.\n *\n * Light strokes on a dark ground spread optically and read heavier than they\n * are; dark strokes on a light ground do not, so one weight cannot look the\n * same at both ends. The type was tuned on `midnight`, and on `sketch` body copy\n * read thin, most visibly on paper (#372). Same argument as `syntaxEmphasis`:\n * light grounds compress the usable luma band, so weight does work colour cannot.\n *\n * Keyed on Polarity because a Level carries colour and only colour (ADR 0004,\n * asserted in `media.test.ts`), and this is exactly the non-colour,\n * light-vs-dark property the polarity variants exist for. Emitted per level as\n * `--ds-ink-weight` and applied in `styles.css`'s base layer, so any weight\n * utility still wins. Inter and Space Grotesk are variable and draw 450 as\n * asked; IBM Plex Mono ships static cuts and resolves 450 to its 500.\n */\nexport const INK_WEIGHT: Readonly<Record<Polarity, number>> = {\n dark: 400,\n light: 450,\n};\n\n/** Type guard for values arriving from `localStorage`, URLs, or props. */\nexport function isThemeLevel(value: unknown): value is ThemeLevel {\n return typeof value === 'string' && (THEME_LEVELS as readonly string[]).includes(value);\n}\n\n/** The next level on the ladder, wrapping from the lightest back to the darkest. */\nexport function nextLevel(level: ThemeLevel): ThemeLevel {\n const index = THEME_LEVELS.indexOf(level);\n return THEME_LEVELS[(index + 1) % THEME_LEVELS.length]!;\n}\n\n/**\n * Exhaustiveness guard for `switch` statements over a level.\n *\n * Prefer a `Record<ThemeLevel, T>` where the branches are values — it is\n * checked without any call site remembering to add a default. Where control\n * flow genuinely has to branch, end the switch with `assertNever(level)` so\n * adding a fifth level fails the build instead of falling through.\n */\nexport function assertNever(value: never, message = 'Unhandled theme level'): never {\n throw new Error(`${message}: ${String(value)}`);\n}\n"],"mappings":";AAwDO,IAAM,eAAe,CAAC,YAAY,QAAQ;AA4B1C,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,aAAa;AACf;AAYO,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAA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AA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACF;AAGO,IAAM,gBAA4B;AAQlC,IAAM,eAAuD;AAAA,EAClE,MAAM;AAAA,EACN,OAAO;AACT;AAkBO,IAAM,aAAiD;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT;AAGO,SAAS,aAAa,OAAqC;AAChE,SAAO,OAAO,UAAU,YAAa,aAAmC,SAAS,KAAK;AACxF;AAGO,SAAS,UAAU,OAA+B;AACvD,QAAM,QAAQ,aAAa,QAAQ,KAAK;AACxC,SAAO,cAAc,QAAQ,KAAK,aAAa,MAAM;AACvD;AAUO,SAAS,YAAY,OAAc,UAAU,yBAAgC;AAClF,QAAM,IAAI,MAAM,GAAG,OAAO,KAAK,OAAO,KAAK,CAAC,EAAE;AAChD;","names":[]}
1
+ {"version":3,"sources":["../../src/theme/levels.ts"],"sourcesContent":["/**\n * The theme ladder — the single place a level name or a level's colour is written.\n *\n * Everything else in the system derives from this file: the CSS in\n * `theme.generated.css`, the runtime provider, the Storybook toolbar, the\n * walkthrough matrix, and the contrast gate. Adding a level here is a type\n * error everywhere it has not been handled; adding a *role* is a type error in\n * every level at once. That is the guarantee — not a convention.\n *\n * ## Why a ladder and not a polarity, at two levels\n *\n * The ladder ran to four rungs — `midnight`, `dim`, `bright`, `white` — on the\n * argument that two themes can share a polarity and still want different\n * grounds. That argument was sound; the assumption under it was not. Nothing\n * consumed the fourth rung and nothing reached the second, so three of the four\n * were paid for and never collected. The pair is `midnight` and `light`.\n *\n * Polarity nevertheless stays a *declared property of a level* rather than the\n * axis, and this is worth stating because the collapse is usually assumed to\n * end it. It does not, because **neither level is named for its polarity**:\n * `midnight` has polarity `dark`, `sketch` has polarity `light`. So\n * {@link SYSTEM_LEVEL} still has a real job — mapping two media states onto two\n * names that are neither of them — and a `Record<Polarity, T>` remains a\n * different type from a `Record<ThemeLevel, T>`. Had the levels been called\n * `dark` and `light` the two would have collapsed into one thing and polarity\n * could have gone with them.\n *\n * Both polarity variants therefore survive: `dark:` and `light:` each span a\n * polarity rather than naming a level, so neither collides with a level\n * variant. `midnight` names a ground; `sketch` names a surface and a way of\n * drawing on it. Neither is a synonym for its polarity, which is the property\n * that keeps a third level cheap.\n *\n * ## Why every value is a literal\n *\n * The previous token layer derived surfaces, text and borders from two poles\n * with `color-mix()` percentages. Percentages tuned against near-black do not\n * hold at the light end — `border-subtle` at 28% is a visible hairline on\n * black and invisible on paper. Literals also make the ladder *checkable*:\n * `pnpm check:contrast` can compute every text-on-surface ratio without a\n * browser — 296 pairs, 148 per Level, including every Hue against every\n * ground, which is what makes hand-tuned literals sustainable rather than\n * twenty times the manual review. Stated per Level deliberately: 440 was\n * written here in the commit that collapsed four Levels to two, so the total\n * was stale the moment it was typed.\n *\n * The one exception is `surface.overlay`, which is a scrim and needs alpha.\n */\n\nimport type { BorderTone, Delta, DeltaGround, Emphasis, Hue, HueRef, Intent, Surface, TextTone } from '../lib/theme';\n\n/**\n * The ladder, ordered from darkest to lightest. Order is meaningful: it is what\n * `cycleLevel` steps through and what the Storybook toolbar and walkthrough\n * matrix render in.\n */\nexport const THEME_LEVELS = ['midnight', 'sketch'] as const;\n\n/** A level of the ladder. */\nexport type ThemeLevel = (typeof THEME_LEVELS)[number];\n\n/**\n * Whether a level reads as dark-on-light or light-on-dark. Declared per level\n * rather than inferred, because it drives things a luminance calculation should\n * not silently decide: the `color-scheme` property (which controls native form\n * controls, scrollbars and the caret), the `dark:`/`light:` Tailwind variants,\n * and the `prefers-color-scheme` mapping.\n */\nexport type Polarity = 'dark' | 'light';\n\n/**\n * The three colours that do **not** vary by level.\n *\n * Every other colour in this module is declared once per level and swaps with\n * it. These do not, and that invariance is the whole point: `#ffffff` means\n * *white*, not \"whatever this level calls its lightest ground\". The\n * `--color-black` / `--color-white` compat aliases are the counter-example —\n * they track `surface.base` and `text.primary`, so `--color-black` resolves to\n * `#ffffff` on the `white` level. A token named for an appearance, holding the\n * opposite appearance.\n *\n * Use these when true black or true white is genuinely meant: a print surface,\n * an SVG fill, a scrim. Not as a page ground — that is `surface.base`.\n */\nexport const FIXED_COLOURS = {\n black: '#000000',\n white: '#ffffff',\n transparent: 'transparent',\n} as const;\n\nexport type FixedColour = keyof typeof FIXED_COLOURS;\n\n/**\n * The Hue vocabulary, in wheel order starting at red.\n *\n * Ten is the ceiling, not a comfortable middle: the tightest pair already sits\n * at deltaE 0.049 on the light levels, and an eleventh candidate was dropped\n * during derivation for landing 13 degrees from the measured blue at deltaE\n * 0.024. Adding one means checking the separation gate, not just this array.\n */\nexport const PALETTE_HUES = [\n 'red',\n 'orange',\n 'yellow',\n 'green',\n 'teal',\n 'cyan',\n 'blue',\n 'violet',\n 'magenta',\n 'pink',\n] as const satisfies readonly Hue[];\n\n/**\n * Every colour a level must define. Adding a field here is a compile error in\n * all four levels until each one answers it — the property that a bare string\n * union cannot provide.\n */\nexport interface LevelDefinition {\n /** Human-facing name, used in the Storybook toolbar and the sandbox. */\n readonly label: string;\n /** One line on what the level is for. Rendered in the sandbox. */\n readonly description: string;\n readonly polarity: Polarity;\n readonly surface: Readonly<Record<Surface, string>>;\n readonly text: Readonly<Record<TextTone, string>>;\n readonly border: Readonly<Record<BorderTone, string>>;\n readonly accent: Readonly<Record<Emphasis, string>>;\n readonly intent: Readonly<Record<Intent, string>>;\n /**\n * Change, as a comparison reports it: a line or record added, removed, or\n * moved. Separate from `intent` on purpose. An added line is not a success\n * and a removed one is not a danger; whether a change is acceptable is a\n * policy's call, and a renderer that paints it green or red has made that\n * call for the reader. The two groups may share a Hue, as `added` and\n * `intent.success` do, and still diverge where the meanings would clash:\n * `midnight`'s `removed` is red while its `danger` is pink.\n */\n readonly delta: Readonly<Record<Delta, string>>;\n /**\n * The grounds a diff paints behind changed rows, and behind a hunk header.\n * Literal tints rather than `color-mix()` for the reason given in the\n * module header. `text.primary` and the matching `delta` role must both\n * clear the text floor on each, which `check:contrast` asserts.\n */\n readonly deltaGround: Readonly<Record<DeltaGround, string>>;\n /**\n * The Hue vocabulary — appearance, not job. Declared *below* the Roles above\n * and referenced by them, never derived from them. Only a Target with no\n * notion of jobs addresses these: a terminal's sixteen ANSI slots, half a\n * JetBrains scheme, a generated diagram needing N distinguishable colours.\n *\n * Every entry clears 5.5:1 against the tightest of this level's three\n * grounds — above WCAG AA, so an editor still has room to tint the ground\n * behind it. `bright` fills the upper eight ANSI slots at a 4.5:1 floor,\n * since those carry emphasis rather than body text.\n */\n readonly palette: Readonly<Record<Hue, string>>;\n /** The `bright` half of each Hue. ANSI's upper eight, and nothing else yet. */\n readonly paletteBright: Readonly<Record<Hue, string>>;\n /**\n * Which Hue each Role is. **The declared lookup ADR 0001 requires.**\n *\n * The ADR rejects deriving this by inspecting hex — ambiguous when two Roles\n * share a value, lossy when no Hue sits on a Role's. So it is declared, and\n * `check:contrast` asserts the Role's value actually equals the Hue's. That\n * assertion is the point: without it the two vocabularies drift silently,\n * which is the failure the ADR's rejected \"both, independently declared\"\n * option was rejected for — and which this repo shipped for exactly one\n * commit, with two pinks on `midnight` 0.036 apart.\n */\n readonly accentHue: Readonly<Record<Emphasis, HueRef>>;\n /** As `accentHue`, for the meaning Roles. */\n readonly intentHue: Readonly<Record<Intent, HueRef>>;\n /** As `accentHue`, for the change Roles. */\n readonly deltaHue: Readonly<Record<Delta, HueRef>>;\n /** Colour of the hard offset shadows. Normally tracks `border.strong`. */\n readonly shadow: string;\n}\n\n/**\n * Surfaces do not move in the same direction on every level, and that is the\n * point of declaring them.\n *\n * On the dark levels a raised card sits *above* the page and so lightens. On\n * `bright` — a warm desk with paper on it — a raised card is a fresh white\n * sheet, so it also lightens, but past the ground rather than away from black.\n * On `white` there is nowhere lighter to go, so elevation is carried by the\n * hard border and shadow while the panel itself takes a faint cool grey. A\n * single derived formula cannot express those three behaviours; four literal\n * ramps can.\n */\nexport const LEVELS: Readonly<Record<ThemeLevel, LevelDefinition>> = {\n midnight: {\n label: 'Midnight',\n description: 'Neon on blue-black. The maximal end of the ladder.',\n polarity: 'dark',\n surface: {\n base: '#0a0a1a',\n raised: '#14142a',\n sunken: '#050510',\n overlay: 'rgba(5, 5, 16, 0.82)',\n },\n text: {\n primary: '#ffffff',\n secondary: '#c3c3d4',\n // Was #8b8ba3: 5.90:1, but APCA Lc -41, the weakest text pair in the\n // system. WCAG 2 overrates light-on-dark. Now 7.39:1 / Lc -50, still 21 Lc\n // below `secondary`. accent.quiet keeps the old value — a fill, not text.\n muted: '#9d9db4',\n inverse: '#0a0a1a',\n },\n border: {\n strong: '#ffffff',\n default: '#9d9db4',\n subtle: '#33334d',\n },\n accent: {\n primary: '#22d3ee',\n secondary: '#facc15',\n // Was #ec4899 — the brand pink, and 5.12:1, which cleared the 4.5 Role\n // floor while `palette.pink` sat at 5.90:1. Two pinks 0.036 apart in one\n // level, invisibly different and therefore worse than visibly. Now the\n // Hue's value, per `accentHue` below.\n tertiary: '#f955a4',\n quiet: '#8b8ba3',\n },\n intent: {\n info: '#22d3ee',\n success: '#39ff14',\n warning: '#facc15',\n danger: '#f955a4',\n },\n delta: {\n added: '#39ff14',\n removed: '#ff586e', // red, not intent.danger's pink: a removal is not an alarm\n moved: '#c3afff',\n },\n deltaGround: {\n added: '#0f2a17',\n removed: '#2e1020',\n hunk: '#1c1c38',\n },\n accentHue: {\n primary: 'cyan',\n secondary: 'yellow',\n tertiary: 'pink',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'cyan',\n success: 'green',\n warning: 'yellow',\n danger: 'pink',\n },\n deltaHue: {\n added: 'green',\n removed: 'red',\n moved: 'violet',\n },\n palette: {\n red: '#ff586e', // 16deg — lifted from #f43f5e (dim accent.tertiary), 4.59:1\n orange: '#ff8c00', // 58deg — kept — 410 commits\n yellow: '#facc15', // 92deg — kept — 533 commits, brand\n green: '#39ff14', // 142deg — kept — 533 commits, brand\n teal: '#34d399', // 163deg — kept — 364 commits\n cyan: '#22d3ee', // 212deg — kept — 534 commits, brand\n blue: '#38bdf8', // 233deg — kept — dim accent.primary, 233deg (a sky blue by heritage)\n violet: '#c3afff', // 295deg — new — 57 tried across six years, none canonical\n magenta: '#ff1cff', // 328deg — lifted from #ff00ff, 5.37:1\n pink: '#f955a4', // 354deg — lifted from #ec4899 (brand), 4.77:1 — deltaE 0.036\n },\n paletteBright: {\n red: '#ff939b',\n orange: '#ffba85',\n yellow: '#ffeaab',\n green: '#c0ffb8',\n teal: '#00f7ae',\n cyan: '#88ebff',\n blue: '#8cd7ff',\n violet: '#ddd4ff',\n magenta: '#ff88fd',\n pink: '#ff8ebe',\n },\n shadow: '#ffffff',\n },\n\n sketch: {\n label: 'Sketch',\n description: 'Warm paper and pen ink. The light half of the pair.',\n polarity: 'light',\n surface: {\n base: '#f5f3ec', // sketch paper\n raised: '#ffffff', // FIXED_COLOURS.white — a fresh sheet on the desk\n sunken: '#efeadf', // the binding ground: every value below is solved against this\n overlay: 'rgba(35, 38, 46, 0.72)',\n },\n text: {\n primary: '#23262e', // sketch ink\n secondary: '#33373f',\n // Was #6a6252: 5.03:1 / APCA Lc 68 on `sunken`, carried by 11px labels.\n // Now 6.16:1 / Lc 73 there. Darker still (#4f4a3d) left muted 7 Lc from\n // `secondary`, and the two tones stopped reading as two. accent.quiet keeps\n // the old value.\n muted: '#5c5546',\n inverse: '#f5f3ec',\n },\n border: {\n strong: '#23262e',\n default: '#8f8672',\n subtle: '#c8c3b4', // darker than sketch's #d8d3c4, which was 1.25:1 on a pure-white `raised`\n },\n accent: {\n primary: '#1450d7', // palette.blue\n secondary: '#006b2e', // palette.green\n tertiary: '#bd0010', // palette.red\n quiet: '#6a6252',\n },\n intent: {\n info: '#1450d7',\n success: '#006b2e',\n warning: '#974503',\n danger: '#bd0010',\n },\n delta: {\n added: '#006b2e',\n removed: '#bd0010',\n moved: '#7d00f4',\n },\n deltaGround: {\n added: '#dcefdc',\n removed: '#f6dcd8',\n hunk: '#e7e2d4',\n },\n accentHue: {\n primary: 'blue',\n secondary: 'green',\n tertiary: 'red',\n quiet: 'neutral',\n },\n intentHue: {\n info: 'blue',\n success: 'green',\n warning: 'orange',\n danger: 'red',\n },\n deltaHue: {\n added: 'green',\n removed: 'red',\n moved: 'violet',\n },\n palette: {\n red: '#bd0010', // 16deg — was #dc2626, 4.03:1 — failed WCAG AA\n orange: '#974503', // 58deg — was #9a4708, 5.34:1\n yellow: '#705a00', // 92deg — new — no light yellow was ever authored\n green: '#006b2e', // 142deg — was #15803d, 4.18:1 — failed\n teal: '#006859', // 163deg — new\n cyan: '#006675', // 212deg — new\n blue: '#1450d7', // 233deg — was #2563eb, 4.31:1 — failed\n violet: '#7d00f4', // 295deg — new\n magenta: '#a300ad', // 328deg — new\n pink: '#b4006c', // 354deg — new\n },\n paletteBright: {\n red: '#8f002a',\n orange: '#6c3700',\n yellow: '#534200',\n green: '#024f00',\n teal: '#004d34',\n cyan: '#004b56',\n blue: '#004e6d',\n violet: '#6000bd',\n magenta: '#7f0080',\n pink: '#8a0052',\n },\n shadow: '#23262e',\n },\n};\n\n/** The level applied when nothing else has been chosen or persisted. */\nexport const DEFAULT_LEVEL: ThemeLevel = 'midnight';\n\n/**\n * Which level each OS colour-scheme preference maps to. `prefers-color-scheme`\n * is binary, so the ladder has to nominate a representative at each end; making\n * that an explicit constant means it can be changed in one place rather than\n * being an accident of ordering.\n */\nexport const SYSTEM_LEVEL: Readonly<Record<Polarity, ThemeLevel>> = {\n dark: 'midnight',\n light: 'sketch',\n};\n\n/**\n * The weight running text is drawn at, by polarity — not by level.\n *\n * Light strokes on a dark ground spread optically and read heavier than they\n * are; dark strokes on a light ground do not, so one weight cannot look the\n * same at both ends. The type was tuned on `midnight`, and on `sketch` body copy\n * read thin, most visibly on paper (#372). Same argument as `syntaxEmphasis`:\n * light grounds compress the usable luma band, so weight does work colour cannot.\n *\n * Keyed on Polarity because a Level carries colour and only colour (ADR 0004,\n * asserted in `media.test.ts`), and this is exactly the non-colour,\n * light-vs-dark property the polarity variants exist for. Emitted per level as\n * `--ds-ink-weight` and applied in `styles.css`'s base layer, so any weight\n * utility still wins. Inter and Space Grotesk are variable and draw 450 as\n * asked; IBM Plex Mono ships static cuts and resolves 450 to its 500.\n */\nexport const INK_WEIGHT: Readonly<Record<Polarity, number>> = {\n dark: 400,\n light: 450,\n};\n\n/** Type guard for values arriving from `localStorage`, URLs, or props. */\nexport function isThemeLevel(value: unknown): value is ThemeLevel {\n return typeof value === 'string' && (THEME_LEVELS as readonly string[]).includes(value);\n}\n\n/** The next level on the ladder, wrapping from the lightest back to the darkest. */\nexport function nextLevel(level: ThemeLevel): ThemeLevel {\n const index = THEME_LEVELS.indexOf(level);\n return THEME_LEVELS[(index + 1) % THEME_LEVELS.length]!;\n}\n\n/**\n * Exhaustiveness guard for `switch` statements over a level.\n *\n * Prefer a `Record<ThemeLevel, T>` where the branches are values — it is\n * checked without any call site remembering to add a default. Where control\n * flow genuinely has to branch, end the switch with `assertNever(level)` so\n * adding a fifth level fails the build instead of falling through.\n */\nexport function assertNever(value: never, message = 'Unhandled theme level'): never {\n throw new Error(`${message}: ${String(value)}`);\n}\n"],"mappings":";AAwDO,IAAM,eAAe,CAAC,YAAY,QAAQ;AA4B1C,IAAM,gBAAgB;AAAA,EAC3B,OAAO;AAAA,EACP,OAAO;AAAA,EACP,aAAa;AACf;AAYO,IAAM,eAAe;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAiFO,IAAM,SAAwD;AAAA,EACnE,UAAU;AAAA,IACR,OAAO;AAAA,IACP,aAAa;AAAA,IACb,UAAU;AAAA,IACV,SAAS;AAAA,MACP,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,WAAW;AAAA;AAAA;AAAA;AAAA,MAIX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AM;AAAA;AAAA,MACN,QAAQ;AAAA;AAAA,MACR,SAAS;AAAA;AAAA,MACT,MAAM;AAAA;AAAA,IACR;AAAA,IACA,eAAe;AAAA,MACb,KAAK;AAAA,MACL,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,MAAM;AAAA,MACN,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,IACA,QAAQ;AAAA,EACV;AACF;AAGO,IAAM,gBAA4B;AAQlC,IAAM,eAAuD;AAAA,EAClE,MAAM;AAAA,EACN,OAAO;AACT;AAkBO,IAAM,aAAiD;AAAA,EAC5D,MAAM;AAAA,EACN,OAAO;AACT;AAGO,SAAS,aAAa,OAAqC;AAChE,SAAO,OAAO,UAAU,YAAa,aAAmC,SAAS,KAAK;AACxF;AAGO,SAAS,UAAU,OAA+B;AACvD,QAAM,QAAQ,aAAa,QAAQ,KAAK;AACxC,SAAO,cAAc,QAAQ,KAAK,aAAa,MAAM;AACvD;AAUO,SAAS,YAAY,OAAc,UAAU,yBAAgC;AAClF,QAAM,IAAI,MAAM,GAAG,OAAO,KAAK,OAAO,KAAK,CAAC,EAAE;AAChD;","names":[]}
package/dist/theme.css CHANGED
@@ -82,6 +82,12 @@
82
82
  --color-intent-success: var(--ds-intent-success);
83
83
  --color-intent-warning: var(--ds-intent-warning);
84
84
  --color-intent-danger: var(--ds-intent-danger);
85
+ --color-delta-added: var(--ds-delta-added);
86
+ --color-delta-removed: var(--ds-delta-removed);
87
+ --color-delta-moved: var(--ds-delta-moved);
88
+ --color-delta-ground-added: var(--ds-delta-ground-added);
89
+ --color-delta-ground-removed: var(--ds-delta-ground-removed);
90
+ --color-delta-ground-hunk: var(--ds-delta-ground-hunk);
85
91
  --color-palette-red: var(--ds-palette-red);
86
92
  --color-palette-orange: var(--ds-palette-orange);
87
93
  --color-palette-yellow: var(--ds-palette-yellow);
@@ -331,6 +337,12 @@
331
337
  --ds-intent-success: #39ff14;
332
338
  --ds-intent-warning: #facc15;
333
339
  --ds-intent-danger: #f955a4;
340
+ --ds-delta-added: #39ff14;
341
+ --ds-delta-removed: #ff586e;
342
+ --ds-delta-moved: #c3afff;
343
+ --ds-delta-ground-added: #0f2a17;
344
+ --ds-delta-ground-removed: #2e1020;
345
+ --ds-delta-ground-hunk: #1c1c38;
334
346
  --ds-palette-red: #ff586e;
335
347
  --ds-palette-orange: #ff8c00;
336
348
  --ds-palette-yellow: #facc15;
@@ -373,6 +385,12 @@
373
385
  --color-intent-success: var(--ds-intent-success);
374
386
  --color-intent-warning: var(--ds-intent-warning);
375
387
  --color-intent-danger: var(--ds-intent-danger);
388
+ --color-delta-added: var(--ds-delta-added);
389
+ --color-delta-removed: var(--ds-delta-removed);
390
+ --color-delta-moved: var(--ds-delta-moved);
391
+ --color-delta-ground-added: var(--ds-delta-ground-added);
392
+ --color-delta-ground-removed: var(--ds-delta-ground-removed);
393
+ --color-delta-ground-hunk: var(--ds-delta-ground-hunk);
376
394
  --color-palette-red: var(--ds-palette-red);
377
395
  --color-palette-orange: var(--ds-palette-orange);
378
396
  --color-palette-yellow: var(--ds-palette-yellow);
@@ -440,6 +458,12 @@
440
458
  --ds-intent-success: #006b2e;
441
459
  --ds-intent-warning: #974503;
442
460
  --ds-intent-danger: #bd0010;
461
+ --ds-delta-added: #006b2e;
462
+ --ds-delta-removed: #bd0010;
463
+ --ds-delta-moved: #7d00f4;
464
+ --ds-delta-ground-added: #dcefdc;
465
+ --ds-delta-ground-removed: #f6dcd8;
466
+ --ds-delta-ground-hunk: #e7e2d4;
443
467
  --ds-palette-red: #bd0010;
444
468
  --ds-palette-orange: #974503;
445
469
  --ds-palette-yellow: #705a00;
@@ -482,6 +506,12 @@
482
506
  --color-intent-success: var(--ds-intent-success);
483
507
  --color-intent-warning: var(--ds-intent-warning);
484
508
  --color-intent-danger: var(--ds-intent-danger);
509
+ --color-delta-added: var(--ds-delta-added);
510
+ --color-delta-removed: var(--ds-delta-removed);
511
+ --color-delta-moved: var(--ds-delta-moved);
512
+ --color-delta-ground-added: var(--ds-delta-ground-added);
513
+ --color-delta-ground-removed: var(--ds-delta-ground-removed);
514
+ --color-delta-ground-hunk: var(--ds-delta-ground-hunk);
485
515
  --color-palette-red: var(--ds-palette-red);
486
516
  --color-palette-orange: var(--ds-palette-orange);
487
517
  --color-palette-yellow: var(--ds-palette-yellow);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtkelly-labs/design-system",
3
- "version": "0.17.0",
3
+ "version": "0.19.0",
4
4
  "description": "Brutalist design system for Ryan Kelly websites: a two-level theme ladder, role-addressed tokens, and Base UI-backed components",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -97,7 +97,7 @@
97
97
  "test:watch": "vitest",
98
98
  "test:coverage": "vitest run --coverage",
99
99
  "test:leaks": "node --disable-warning=MODULE_TYPELESS_PACKAGE_JSON scripts/vitest-leaks.mjs",
100
- "storybook": "storybook dev -p 6006",
100
+ "storybook": "storybook dev -p 8100",
101
101
  "build-storybook": "storybook build -o storybook-static",
102
102
  "test:a11y": "playwright test tests/a11y.spec.ts",
103
103
  "test:visual": "playwright test tests/visual.spec.ts",
@@ -459,6 +459,56 @@
459
459
  "$value": "{palette.pink}"
460
460
  }
461
461
  },
462
+ "delta": {
463
+ "$type": "color",
464
+ "$description": "Change Roles, aliased onto Hues by the declared `deltaHue` map. Not meaning: an added line is not a success.",
465
+ "added": {
466
+ "$value": "{palette.green}"
467
+ },
468
+ "removed": {
469
+ "$value": "{palette.red}"
470
+ },
471
+ "moved": {
472
+ "$value": "{palette.violet}"
473
+ }
474
+ },
475
+ "deltaGround": {
476
+ "$type": "color",
477
+ "$description": "The grounds a diff paints behind changed rows and hunk headers.",
478
+ "added": {
479
+ "$value": {
480
+ "colorSpace": "oklch",
481
+ "components": [
482
+ 0.2576,
483
+ 0.0488,
484
+ 151.26
485
+ ],
486
+ "hex": "#0f2a17"
487
+ }
488
+ },
489
+ "removed": {
490
+ "$value": {
491
+ "colorSpace": "oklch",
492
+ "components": [
493
+ 0.2265,
494
+ 0.0544,
495
+ 349.12
496
+ ],
497
+ "hex": "#2e1020"
498
+ }
499
+ },
500
+ "hunk": {
501
+ "$value": {
502
+ "colorSpace": "oklch",
503
+ "components": [
504
+ 0.2423,
505
+ 0.0527,
506
+ 281.74
507
+ ],
508
+ "hex": "#1c1c38"
509
+ }
510
+ }
511
+ },
462
512
  "shadow": {
463
513
  "$type": "color",
464
514
  "color": {
@@ -459,6 +459,56 @@
459
459
  "$value": "{palette.red}"
460
460
  }
461
461
  },
462
+ "delta": {
463
+ "$type": "color",
464
+ "$description": "Change Roles, aliased onto Hues by the declared `deltaHue` map. Not meaning: an added line is not a success.",
465
+ "added": {
466
+ "$value": "{palette.green}"
467
+ },
468
+ "removed": {
469
+ "$value": "{palette.red}"
470
+ },
471
+ "moved": {
472
+ "$value": "{palette.violet}"
473
+ }
474
+ },
475
+ "deltaGround": {
476
+ "$type": "color",
477
+ "$description": "The grounds a diff paints behind changed rows and hunk headers.",
478
+ "added": {
479
+ "$value": {
480
+ "colorSpace": "oklch",
481
+ "components": [
482
+ 0.9329,
483
+ 0.0323,
484
+ 145.31
485
+ ],
486
+ "hex": "#dcefdc"
487
+ }
488
+ },
489
+ "removed": {
490
+ "$value": {
491
+ "colorSpace": "oklch",
492
+ "components": [
493
+ 0.9147,
494
+ 0.0294,
495
+ 28.13
496
+ ],
497
+ "hex": "#f6dcd8"
498
+ }
499
+ },
500
+ "hunk": {
501
+ "$value": {
502
+ "colorSpace": "oklch",
503
+ "components": [
504
+ 0.9129,
505
+ 0.0195,
506
+ 90.55
507
+ ],
508
+ "hex": "#e7e2d4"
509
+ }
510
+ }
511
+ },
462
512
  "shadow": {
463
513
  "$type": "color",
464
514
  "color": {