@intentius/behold 0.29.17 → 0.29.19

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.
package/web/kiosk.test.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from "vitest";
2
- import { INTRO_HEAD, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, focusRoots, introText, scenarioHead, frameSrc, factLines, kioskView, legendWords, matchingPull, pendingApproval, renderKiosk, renderViewToggle, reportless, runPanel, runPin, stepView, viewZoom } from "./kiosk.js";
2
+ import { BEAT_CHANGES, INTRO_HEAD, READ_STORE, READ_TITLE, STEP_VIEW, STEP_WORDS, aboutRows, approvalPanel, approveGloss, chantProject, factsLine, focusRoots, holdHead, holdModel, introText, readStored, readingRows, renderReading, scenarioHead, frameSrc, factLines, kioskView, matchingPull, pendingApproval, renderKiosk, renderViewToggle, reportless, runPanel, runPin, stepView, viewZoom } from "./kiosk.js";
3
3
  import { VENDORS } from "./kiosk-vendor.js";
4
4
  import { PICK_HOLD_MS } from "./kiosk-runs.js";
5
5
 
@@ -42,6 +42,25 @@ describe("focusRoots (#569)", () => {
42
42
  });
43
43
  });
44
44
 
45
+ describe("the hold panel (behold#571)", () => {
46
+ it("heads the panel with its wave, its run and its plan, else what its note is about", () => {
47
+ expect(holdHead({ wave: 2, run: 3605, digest: "jcs1-sha256:02812a1b9999" })).toBe("Wave 2 · run #3605 · plan 02812a1b");
48
+ expect(holdHead({ wave: 3 })).toBe("Wave 3");
49
+ expect(holdHead({ pull: 7 })).toBe("Pull request #7");
50
+ expect(holdHead({ commit: "abc12345ffff" })).toBe("Merge abc12345");
51
+ expect(holdHead({})).toBe(null);
52
+ });
53
+ it("holds how the hold ends, else the driver's approval, else the run's note, and nothing past that", () => {
54
+ const model = { wave: 2, digest: "sha256:02812a1b", run: 3605, rows: [] };
55
+ expect(holdModel({ approval: model }, demo("waiting"))).toMatchObject({ kind: "approval", wave: 2, head: "Wave 2 · run #3605 · plan 02812a1b" });
56
+ const p = progress([{ number: 2, state: "waiting", roots: ["app"], reads: [], digest: "jcs1-sha256:0accc105ba06" }]);
57
+ expect(holdModel({ progress: p }, demo("waiting", { next: { action: "approve wave-2", at: null } }))).toMatchObject({ kind: "driver", wave: 2, head: "Wave 2 · plan 0accc105" });
58
+ expect(holdModel({ answer: null, progress: null }, demo("planned", { pull: 989 }))).toEqual({ kind: "note", wave: null, head: "Pull request #989", lines: [{ cls: "k-note", text: "The pipeline is planning pull request #989." }] });
59
+ expect(holdModel({ noReports: true }, demo("planned"))).toBe(null);
60
+ expect(holdModel({ answer, progress: null }, demo("planned"))).toBe(null);
61
+ });
62
+ });
63
+
45
64
  describe("frameSrc (#569)", () => {
46
65
  it("frames behold's own view, bare, told its host", () => {
47
66
  expect(frameSrc("http://localhost:4700")).toBe("/?embed=1&bare=1&zoom=resources&host=http%3A%2F%2Flocalhost%3A4700");
@@ -51,6 +70,8 @@ describe("frameSrc (#569)", () => {
51
70
  describe("factLines (#569)", () => {
52
71
  it("says the pull request's totals and blast radius", () => {
53
72
  expect(factLines(demo("planned"), answer)).toEqual(["pull request #7 changes across 3 roots: 3 update", "blast radius: app, edge, network", "unchanged: other"]);
73
+ // behold#571: the lead block shows them as one line.
74
+ expect(factsLine(demo("planned"), answer)).toBe("pull request #7 changes across 3 roots: 3 update · blast radius: app, edge, network · unchanged: other");
54
75
  expect(factLines(demo("planned"), answer, "terragrunt")[0]).toBe("pull request #7 changes across 3 units: 3 update");
55
76
  });
56
77
  });
@@ -128,27 +149,37 @@ describe("the scenario's card under the title (behold#571)", () => {
128
149
  const bar = document.createElement("header");
129
150
  const s = { demo: { source: "fx", read: "2026-10-15T03:00:00Z", demo: demo("failed", { scenario: "failure", about }) }, answer: null, progress: null };
130
151
  renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
131
- const left = find(bar, "k-left")[0];
132
- // behold#571: the title, the card and the step, each in its own fixed box.
133
- expect(left.children.map((c) => c.className.split(" ")[0])).toEqual(["k-box", "k-box", "k-box"]);
134
- expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-title"], ["k-about"], ["k-step"]]);
152
+ const left = find(bar, "k-lead")[0];
153
+ // behold#571: the lead block: the title, the two beats (what changes, the step), the progress, the rest of the card, the facts; each box fixed.
154
+ expect(left.children.map((c) => c.className)).toEqual(["k-box k-box-title", "k-box k-box-beat", "k-box k-box-step", "k-progress", "k-box k-box-more", "k-box k-box-facts k-box-empty"]);
155
+ expect(left.children.map((c) => c.children.map((x) => x.className.split(" ")[0]))).toEqual([["k-title"], ["k-beat"], ["k-step"], ["k-strip", "k-next"], ["k-about"], []]);
156
+ const beat = find(bar, "k-beat")[0];
157
+ expect(beat.children.map((c) => [c.className, c.textContent])).toEqual([["k-beat-label", BEAT_CHANGES], ["k-beat-text", about.changes]]);
158
+ // The step's progress sits with the step line: the strip's stops, the driver's next action.
159
+ expect(find(bar, "k-stop").map((c) => c.textContent)).toEqual(["pull request", "planned", "merged", "waves", "applied", "reset"]);
160
+ // The rest of the card, one quieter paragraph: each field after its label.
135
161
  const card = find(bar, "k-about")[0];
136
- expect(card.tagName).toBe("dl");
137
- expect(card.children.map((c) => [c.tagName, c.textContent])).toEqual([
138
- ["dt", "What changes"], ["dd", about.changes],
139
- ["dt", "Watch for"], ["dd", about.watch],
140
- ["dt", "Shows"], ["dd", about.shows],
162
+ expect(card.tagName).toBe("p");
163
+ expect(card.children.filter((c) => c.className).map((c) => [c.className, c.textContent])).toEqual([
164
+ ["k-about-label", "Watch for"], ["k-about-text", about.watch],
165
+ ["k-about-label", "Shows"], ["k-about-text", about.shows],
141
166
  ]);
142
167
 
143
168
  s.demo.demo = demo("reset", { scenario: "base", about: null });
144
169
  renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
145
170
  expect(find(bar, "k-about")).toEqual([]);
171
+ expect(find(bar, "k-beat")).toEqual([]);
172
+ // Render what's present: the boxes with nothing in them draw no box.
173
+ expect(find(bar, "k-box-empty").map((c) => c.className)).toEqual(["k-box k-box-beat k-box-empty", "k-box k-box-more k-box-empty", "k-box k-box-facts k-box-empty"]);
174
+ // On the base, the hold panel holds the run's note, quiet, with no wave to light.
175
+ expect(find(bar, "k-box-hold")[0].className).toBe("k-box k-box-hold k-hold");
146
176
 
147
177
  // behold#571: no intro band at a live step; between scenarios the intro takes the card's box.
148
178
  const intro = "Terraform keeps what it built in a state file.";
149
179
  s.demo.demo = demo("waiting", { scenario: "failure", about, intro });
150
180
  renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
151
181
  expect(find(bar, "k-intro")).toEqual([]);
182
+ expect(find(bar, "k-beat")).toHaveLength(1);
152
183
  s.demo.demo = demo("reset", { scenario: "failure", about, intro });
153
184
  renderKiosk(bar, s, new Date("2026-10-15T03:01:00Z"));
154
185
  const shown = find(bar, "k-intro");
@@ -193,8 +224,9 @@ describe("the approval panel's drawing (behold#571)", () => {
193
224
  ],
194
225
  };
195
226
  const panel = approvalPanel(model, { showLine: (l) => shown.push(l) });
196
- const head = find(panel, "k-ap-head")[0];
197
- expect([head.textContent, ...head.children.map((c) => c.textContent)].join("")).toBe("How this hold ends · wave 2 plan 0accc105ba06 · times in UTC");
227
+ // behold#571: the wave, the run and the plan head the hold panel; the panel's own head says what its rows are.
228
+ expect(find(panel, "k-ap-head")[0].textContent).toBe("How this hold ends · times in UTC");
229
+ expect(holdHead({ wave: model.wave, run: 3605, digest: model.digest })).toBe("Wave 2 · run #3605 · plan 0accc105");
198
230
  expect(find(panel, "k-ap-row").map((r) => r.className)).toEqual(["k-ap-row k-ap-lit", "k-ap-row k-ap-dim", "k-ap-row k-ap-dim", "k-ap-row k-ap-dim"]);
199
231
  expect(find(panel, "k-ap-facts")[0].textContent).toBe("04:09:41 · ledger 57869649");
200
232
  expect(find(panel, "k-command")[0].textContent).toBe("chant approve tf-apply wave-2");
@@ -244,21 +276,67 @@ describe("which view the frame shows (#571)", () => {
244
276
  expect(viewZoom("nonsense")).toBe("resources");
245
277
  });
246
278
 
247
- it("says how to read the view shown", () => {
248
- expect(legendWords("components")).toMatch(/^Components shows the pipeline's jobs and waves\. Each card is a Terraform root .* titled with the job that applies it/);
249
- expect(legendWords("resources")).toMatch(/^Each box is a Terraform root/);
279
+ it("says how to read the view shown, a row per mark", () => {
280
+ const words = (v, t) => readingRows(v, t).map((r) => r.words).join(" ");
281
+ expect(readingRows("components").map((r) => r.mark)).toEqual(["card", "box", "solid", "dashed", "order", "marks"]);
282
+ expect(readingRows("resources").map((r) => r.mark)).toEqual(["box", "card", "solid", "dashed", "marks"]);
283
+ expect(readingRows("components")[0].words).toBe("Card: a Terraform root with its own state.");
284
+ expect(readingRows("components")[1].words).toBe("Box: a wave, titled with the job that applies it.");
285
+ expect(readingRows("resources")[0].words).toBe("Box: a Terraform root with its own state.");
286
+ expect(words("components")).toMatch(/Solid arrow: a read of applied outputs\. Dashed arrow: planned values, before they apply\./);
287
+ expect(words("components")).toMatch(/Marks: the forge and the tools a job runs/);
288
+ // Short items, so two to a line keep the open frame a few lines tall.
289
+ for (const v of ["components", "resources"]) for (const r of readingRows(v, "terragrunt")) expect(r.words.length, r.words).toBeLessThanOrEqual(50);
250
290
  // behold#571: a Terragrunt scenario names its units.
251
291
  for (const v of ["components", "resources"]) {
252
- const words = legendWords(v, "terragrunt");
253
- expect(words).toMatch(/is a Terragrunt unit with its own state/);
254
- expect(words).toMatch(/one unit reading another's outputs.*applies its units together/);
255
- expect(words).not.toMatch(/\broots?\b/);
292
+ const w = words(v, "terragrunt");
293
+ expect(w).toMatch(/a Terragrunt unit with its own state/);
294
+ expect(w).not.toMatch(/\broots?\b/);
256
295
  }
296
+ expect(words("components", "terragrunt")).toMatch(/Waves apply in order, units in a wave together/);
257
297
  // A tool whose pipeline writes no reports: behold's own components graph, with no jobs or planned values in it.
258
- expect(legendWords("components", "chant")).toBe(
259
- "Components shows the project's components, in a box per wave. Each card is a Terraform root with its own state, and an arrow is one component reading another's outputs.",
260
- );
261
- expect(legendWords("resources", "chant")).toBe("Each box is a Terraform root with its own state.");
298
+ expect(readingRows("components", "chant")).toEqual([
299
+ { mark: "card", words: "Card: a Terraform root with its own state." },
300
+ { mark: "box", words: "Box: a wave of components that apply together." },
301
+ { mark: "solid", words: "Arrow: a component reading another's outputs." },
302
+ ]);
303
+ expect(readingRows("resources", "chant")).toEqual([{ mark: "box", words: "Box: a Terraform root with its own state." }]);
304
+ });
305
+
306
+ it("draws 'How to read this' as a header that folds the rows, and keeps the viewer's fold", () => {
307
+ const was = globalThis.document;
308
+ globalThis.document = { createElement: (tag) => {
309
+ const n = { tagName: tag, className: "", textContent: "", children: [], attrs: {}, listeners: {} };
310
+ n.appendChild = (c) => (n.children.push(c), c);
311
+ n.append = (...cs) => cs.forEach((c) => n.children.push(c));
312
+ n.replaceChildren = () => (n.children = []);
313
+ n.setAttribute = (k, v) => (n.attrs[k] = v);
314
+ n.addEventListener = (k, f) => (n.listeners[k] = f);
315
+ return n;
316
+ } };
317
+ try {
318
+ const host = document.createElement("section");
319
+ const toggled = [];
320
+ renderReading(host, "components", null, { open: true, onToggle: (o) => toggled.push(o) });
321
+ expect(host.hidden).toBe(false);
322
+ expect(host.children.map((c) => c.className)).toEqual(["k-read-head", "k-read-rows"]);
323
+ expect(host.children[0].textContent).toBe(READ_TITLE);
324
+ expect(host.children[1].children.map((li) => li.children[0].className)).toEqual(["k-read-mark k-read-card", "k-read-mark k-read-box", "k-read-mark k-read-solid", "k-read-mark k-read-dashed", "k-read-mark k-read-order", "k-read-mark k-read-marks"]);
325
+ host.children[0].listeners.click();
326
+ expect(toggled).toEqual([false]);
327
+ // Folded, the header stays as its one line.
328
+ renderReading(host, "components", null, { open: false });
329
+ expect(host.children.map((c) => c.className)).toEqual(["k-read-head"]);
330
+ expect(host.children[0].attrs["aria-expanded"]).toBe("false");
331
+ } finally {
332
+ globalThis.document = was;
333
+ }
334
+ const store = (v) => ({ getItem: (k) => (k === READ_STORE ? v : null) });
335
+ expect(readStored(store("open"))).toBe(true);
336
+ expect(readStored(store("closed"))).toBe(false);
337
+ expect(readStored(store(null))).toBe(null);
338
+ expect(readStored({ getItem: () => { throw new Error("blocked"); } })).toBe(null);
339
+ expect(readStored(null)).toBe(null);
262
340
  });
263
341
 
264
342
  it("knows a tool whose pipeline writes no terragucci reports, and a chant project behold draws itself", () => {
@@ -383,6 +461,10 @@ describe("the kiosk for a viewer new to the demo (behold#571)", () => {
383
461
  const card = find(bar, "k-approve")[0];
384
462
  expect(card.children.map((c) => c.className)).toEqual(["k-approve-gloss", "k-command", "k-approve-then"]);
385
463
  expect(card.children[1].textContent).toBe("chant approve tf-apply wave-2 --actor <reviewer> --sign <reviewer key>");
464
+ // behold#571: the hold panel is headed with its wave and plan, and lit as its wave's job row is.
465
+ const hold = find(bar, "k-box-hold")[0];
466
+ expect(hold.className).toBe("k-box k-box-hold k-hold k-hold-wave");
467
+ expect(hold.children[0].textContent).toBe("Wave 2 · plan 0accc105");
386
468
  } finally {
387
469
  globalThis.document = was;
388
470
  }
package/web/theme.js CHANGED
@@ -65,6 +65,27 @@ export function oklchToHex({ L, C, H }) {
65
65
  l2s(-0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s));
66
66
  }
67
67
 
68
+ // behold#571: the most chroma an OKLCH lightness and hue holds inside sRGB,
69
+ // so a lightness walk keeps its hue by giving up chroma, not by clipping.
70
+ function oklchInGamut({ L, C, H }) {
71
+ const h = H * Math.PI / 180, a = C * Math.cos(h), bb = C * Math.sin(h);
72
+ const l = (L + 0.3963377774 * a + 0.2158037573 * bb) ** 3;
73
+ const m = (L - 0.1055613458 * a - 0.0638541728 * bb) ** 3;
74
+ const s = (L - 0.0894841775 * a - 1.2914855480 * bb) ** 3;
75
+ const rgb = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s];
76
+ return rgb.every((v) => v >= -1e-4 && v <= 1 + 1e-4);
77
+ }
78
+ export function oklchToHexMapped({ L, C, H }) {
79
+ if (oklchInGamut({ L, C, H })) return oklchToHex({ L, C, H });
80
+ let lo = 0, hi = C;
81
+ for (let i = 0; i < 24; i++) {
82
+ const mid = (lo + hi) / 2;
83
+ if (oklchInGamut({ L, C: mid, H })) lo = mid;
84
+ else hi = mid;
85
+ }
86
+ return oklchToHex({ L, C: lo, H });
87
+ }
88
+
68
89
  // Drop a colour's chroma without touching its lightness — the chrome's one
69
90
  // "quieter" step (#229). Used on the tokens that SURROUND the drift hues, never
70
91
  // on the drift hues themselves.
@@ -313,9 +334,26 @@ const KIOSK_VARS = { surfaceBox: "surface-box", surfacePaneA: "surface-pane-a",
313
334
  export function pinTokensFor(th) {
314
335
  const P = th.palette, fgMix = (t) => mix(th.bg, th.fg, t);
315
336
  const good = P[2], warn = P[1], accent = P[4], runtime = P[6]; // P[6] = the cyan the CSS --runtime var rides
316
- const panel = fgMix(0.18); // node card base — elevated well off the bg
337
+ // behold#571: a card a state's words can read on at 4.5:1. A mid-tone palette
338
+ // (Blue Dolphin, Grass) mixes a card even white or black can't reach that on;
339
+ // its lightness steps away from the text's side until one of them can.
340
+ const panel = (() => {
341
+ const p0 = fgMix(0.18);
342
+ const best = (c) => Math.max(contrast(c, "#ffffff"), contrast(c, "#000000"));
343
+ if (best(p0) >= 4.8) return p0;
344
+ const o = hexToOklch(p0);
345
+ const dir = contrast(p0, "#ffffff") >= contrast(p0, "#000000") ? -1 : 1;
346
+ for (let step = 1; step <= 40; step++) {
347
+ const c = oklchToHexMapped({ ...o, L: clamp(o.L + dir * step * 0.005, 0, 1) });
348
+ if (best(c) >= 4.8) return c;
349
+ }
350
+ return p0;
351
+ })(); // node card base — elevated well off the bg
317
352
  const fill = (c) => mix(panel, c, 0.4); // panel pulled strongly toward the status hue
318
- const stroke = (c) => mix(th.bg, c, 0.62);
353
+ // behold#571: a status outline is a thin line on the background and the wave box: 3:1 on both, its hue kept.
354
+ const up = hexToOklch(th.bg).L < 0.6;
355
+ const line = (c) => lightnessFor(c, [th.bg, fgMix(0.045)], 3, up);
356
+ const stroke = (c) => line(mix(th.bg, c, 0.62));
319
357
  return {
320
358
  bg0: th.bg, bg1: fgMix(0.045), dots: fgMix(0.12),
321
359
  text: th.fg, textMuted: fgMix(0.5), textFaint: fgMix(0.38), edge: fgMix(0.3),
@@ -324,9 +362,62 @@ export function pinTokensFor(th) {
324
362
  goodFill: fill(good), goodStroke: stroke(good), goodBar: good,
325
363
  warnFill: fill(warn), warnStroke: stroke(warn), warnBar: warn,
326
364
  runtimeFill: fill(runtime), runtimeStroke: stroke(runtime), runtimeBar: runtime,
327
- selectedStroke: accent,
365
+ selectedStroke: line(accent),
366
+ };
367
+ }
368
+ /**
369
+ * behold#571: the state colours as the graph frame draws them as text and thin
370
+ * lines: a card's state words and its outline, a wave box's job status and
371
+ * outline, a read's line. Each is the state's hue with its OKLCH lightness
372
+ * moved until it reads at WCAG AA (4.5:1) on the ground its words sit on, and
373
+ * at 3:1 (a line's floor) on every other ground of the frame: `box` inks for
374
+ * the background and the wave boxes, `card` inks for the cards.
375
+ */
376
+ export const FRAME_STATES = ["managed", "foreign", "pending", "degraded", "runtime", "neutral", "focus", "muted"];
377
+ export function frameGrounds(th) {
378
+ const pin = pinTokensFor(th);
379
+ return { box: [th.bg, pin.bg1], card: [pin.neutralFill] };
380
+ }
381
+ const worstOn = (c, grounds) => Math.min(...grounds.map((g) => contrast(c, g)));
382
+ /**
383
+ * `hex` with its OKLCH lightness walked, its hue kept, until it clears
384
+ * `floor` on each of `grounds` and `lineFloor` on each of `others`. Chroma
385
+ * gives way only where sRGB can't hold it at that lightness; a theme whose
386
+ * grounds leave no room at all gets white or black.
387
+ */
388
+ function lightnessFor(hex, grounds, floor, up, others = [], lineFloor = 3) {
389
+ const ok = (c) => worstOn(c, grounds) >= floor && (!others.length || worstOn(c, others) >= lineFloor);
390
+ if (ok(hex)) return hex;
391
+ const o = hexToOklch(hex);
392
+ const walk = (dir) => {
393
+ for (let step = 1; step <= 200; step++) {
394
+ const L = clamp(o.L + dir * step * 0.005, 0, 1);
395
+ const out = oklchToHexMapped({ L, C: o.C, H: o.H });
396
+ if (ok(out)) return out;
397
+ if (L === 0 || L === 1) break;
398
+ }
399
+ return null;
328
400
  };
401
+ const found = walk(up ? 1 : -1) || walk(up ? -1 : 1);
402
+ if (found) return found;
403
+ const ends = up ? ["#ffffff", "#000000"] : ["#000000", "#ffffff"];
404
+ return ends.find(ok) || ends.reduce((a, b) => (worstOn(b, grounds) > worstOn(a, grounds) ? b : a));
405
+ }
406
+ export function frameInks(th) {
407
+ const t = tokensFor(th);
408
+ const g = frameGrounds(th);
409
+ const all = [...g.box, ...g.card];
410
+ // Lighter on a ground that is dark, darker on a light one.
411
+ const up = (gs) => hexToOklch(gs[0]).L < 0.6;
412
+ const box = {};
413
+ const card = {};
414
+ for (const s of FRAME_STATES) {
415
+ box[s] = lightnessFor(t[s], g.box, 4.5, up(g.box), all);
416
+ card[s] = lightnessFor(t[s], g.card, 4.5, up(g.card), all);
417
+ }
418
+ return { box, card };
329
419
  }
420
+
330
421
  const PIN_VARS = ["bg0", "bg1", "dots", "text", "textMuted", "textFaint", "edge", "neutralFill", "neutralStroke", "neutralBar", "accentFill", "accentStroke", "accentBar", "goodFill", "goodStroke", "goodBar", "warnFill", "warnStroke", "warnBar", "runtimeFill", "runtimeStroke", "runtimeBar", "selectedStroke"];
331
422
 
332
423
  function hash(s) { let h = 2166136261; for (let i = 0; i < s.length; i++) { h ^= s.charCodeAt(i); h = Math.imul(h, 16777619); } return h >>> 0; }
@@ -362,6 +453,14 @@ export function applyTheme(tokens = _tokens) {
362
453
  for (const [k, v] of Object.entries(KIOSK_VARS)) if (tokens[k]) root.style.setProperty("--" + v, tokens[k]);
363
454
  (tokens.roots || []).forEach((c, i) => root.style.setProperty(`--root-${i}`, c));
364
455
  if (_active) { const pin = pinTokensFor(_active); for (const k of PIN_VARS) root.style.setProperty("--pin-" + k, pin[k]); }
456
+ // behold#571: the state colours the graph frame draws as text and lines, legible on every ground (frameInks).
457
+ if (_active) {
458
+ const inks = frameInks(_active);
459
+ for (const k of FRAME_STATES) {
460
+ root.style.setProperty("--frame-" + k, inks.box[k]);
461
+ root.style.setProperty("--frame-card-" + k, inks.card[k]);
462
+ }
463
+ }
365
464
  root.style.setProperty("color-scheme", tokens.dark ? "dark" : "light");
366
465
  }
367
466
 
package/web/theme.test.js CHANGED
@@ -6,7 +6,7 @@
6
6
  // sweeps all 552 palettes for the same assertion; this pins the exact
7
7
  // palette the issue was filed against, with no browser involved.
8
8
  import { describe, it, expect } from "vitest";
9
- import { MIN_STEP, SOFT_CEILING, ZEBRA, contrast, desaturate, hexToOklch, mix, tokensFor } from "./theme.js";
9
+ import { FRAME_STATES, MIN_STEP, SOFT_CEILING, ZEBRA, contrast, desaturate, frameGrounds, frameInks, hexToOklch, mix, pinTokensFor, tokensFor } from "./theme.js";
10
10
  import { THEMES } from "./themes.js";
11
11
 
12
12
  describe("tokensFor — the --muted contrast floor (#240)", () => {
@@ -83,3 +83,58 @@ describe("tokensFor — the kiosk's surfaces (behold#571)", () => {
83
83
  expect(mocha.soft).toBe(THEMES["Catppuccin Mocha"].fg);
84
84
  });
85
85
  });
86
+
87
+ // behold#571: the graph frame's state colours, as text and thin lines, in every theme.
88
+ describe("the graph frame's state colours", () => {
89
+ const all = Object.values(THEMES);
90
+ const hueGap = (a, b) => Math.min(Math.abs(a - b), 360 - Math.abs(a - b));
91
+
92
+ it("read at WCAG AA (4.5:1) on the ground their words sit on, and 3:1 as a line on every other, in every theme", () => {
93
+ const short = [];
94
+ for (const th of all) {
95
+ const inks = frameInks(th);
96
+ const g = frameGrounds(th);
97
+ for (const side of ["box", "card"]) {
98
+ for (const s of FRAME_STATES) {
99
+ const c = inks[side][s];
100
+ for (const gr of g[side]) if (contrast(c, gr) < 4.5) short.push(`${th.name} ${side} ${s} ${c} on ${gr}: ${contrast(c, gr).toFixed(2)}`);
101
+ // And as a line, 3:1 on every ground of the frame.
102
+ for (const gr of [...g.box, ...g.card]) if (contrast(c, gr) < 3) short.push(`${th.name} ${side} ${s} line ${c} on ${gr}: ${contrast(c, gr).toFixed(2)}`);
103
+ }
104
+ }
105
+ }
106
+ expect(short).toEqual([]);
107
+ });
108
+
109
+ it("draw a status outline at 3:1 or better on the background and the wave box, in every theme", () => {
110
+ const short = [];
111
+ for (const th of all) {
112
+ const pin = pinTokensFor(th);
113
+ for (const k of ["accentStroke", "goodStroke", "warnStroke", "runtimeStroke", "selectedStroke"]) {
114
+ for (const g of [pin.bg0, pin.bg1]) if (contrast(pin[k], g) < 3) short.push(`${th.name} ${k} ${pin[k]} on ${g}: ${contrast(pin[k], g).toFixed(2)}`);
115
+ }
116
+ }
117
+ expect(short).toEqual([]);
118
+ });
119
+
120
+ it("keep each state's hue where it has one, moving its lightness", () => {
121
+ const off = [];
122
+ for (const th of all) {
123
+ const t = tokensFor(th);
124
+ const inks = frameInks(th);
125
+ for (const s of FRAME_STATES) for (const side of ["box", "card"]) {
126
+ const a = hexToOklch(t[s]);
127
+ const b = hexToOklch(inks[side][s]);
128
+ if (a.C < 0.04 || b.C < 0.04) continue;
129
+ if (hueGap(a.H, b.H) > 20) off.push(`${th.name} ${side} ${s} ${t[s]} -> ${inks[side][s]}`);
130
+ }
131
+ }
132
+ expect(off).toEqual([]);
133
+ });
134
+
135
+ it("fixes Sea Shells' planned text, which read dark blue on a dark card", () => {
136
+ const th = THEMES["Sea Shells"];
137
+ expect(contrast(tokensFor(th).pending, pinTokensFor(th).neutralFill)).toBeLessThan(2);
138
+ expect(contrast(frameInks(th).card.pending, pinTokensFor(th).neutralFill)).toBeGreaterThanOrEqual(4.5);
139
+ });
140
+ });