@intentius/behold 0.29.22 → 0.29.23
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/package.json +1 -1
- package/web/app.js +10 -4
- package/web/frame-fill.js +16 -0
- package/web/frame-fill.test.js +34 -0
- package/web/theme.js +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intentius/behold",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.23",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "behold — a live control plane on chant. See your whole estate (every substrate in one graph), coloured by drift; act through delegated, gated Ops.",
|
package/web/app.js
CHANGED
|
@@ -21,6 +21,7 @@ import { renderLane } from "./terragucci-lifecycle.js";
|
|
|
21
21
|
import { renderReleases } from "./releases.js";
|
|
22
22
|
import { renderYodelLane } from "./sql-yodeler-lane.js";
|
|
23
23
|
import { initTerragucciEstate } from "./terragucci-estate.js";
|
|
24
|
+
import { noStateFill } from "./frame-fill.js";
|
|
24
25
|
import { componentMarks as tgComponentMarks, runsCommit as tgRunsCommit, waveOfKey as tgWaveOfKey } from "./terragucci-components-live.js";
|
|
25
26
|
import { FORGES, MARK, componentsForge, forgeOfName, iconSvg, markLink, markTitle, waveJobUrl } from "./forge-mark.js";
|
|
26
27
|
import { TOOLS, orderTools } from "./tool-mark.js";
|
|
@@ -32,7 +33,7 @@ import { edgeKey, edgeLabel, edgeLegend, edgeTitle, isCiKind, viaIndex } from ".
|
|
|
32
33
|
import { readCostLine } from "./read-cost.js";
|
|
33
34
|
import { mountHistoryPicker } from "./history-picker.js";
|
|
34
35
|
import { applyMemberFrame, pendingLine, stillPending } from "./pending.js";
|
|
35
|
-
import { initTheme, setTheme, mountThemePicker, readableOn, colorForCategory, onThemeChange, getTokens, getTheme, pinTokensFor } from "./theme.js";
|
|
36
|
+
import { initTheme, setTheme, mountThemePicker, readableOn, inkOn, colorForCategory, onThemeChange, getTokens, getTheme, pinTokensFor } from "./theme.js";
|
|
36
37
|
// #399 M2 / #401 M4 of #397: the colour-by modes' arithmetic and the
|
|
37
38
|
// provenance badge's wording — every decision the behaviour overlay makes,
|
|
38
39
|
// pure and unit-tested beside the file. This module owns the fetches, the SVG
|
|
@@ -203,9 +204,13 @@ function colourPlan(graphIr) {
|
|
|
203
204
|
// #569 review: a terragucci repo's view with no drift read draws each root's
|
|
204
205
|
// wave state on its box, so the cards wear the neutral ground: colour there
|
|
205
206
|
// means a wave's state, never a category hue that reads as an error.
|
|
206
|
-
|
|
207
|
+
// behold#571: in the kiosk's frame a card's state is its outline, bar and
|
|
208
|
+
// words, never its fill, so a card with no state yet (before the pull
|
|
209
|
+
// request's first plan, or reports that name another checkout) wears the
|
|
210
|
+
// same neutral ground, not a category hue that reads as an error.
|
|
211
|
+
if (mode === "drift" && tokens && (tgStatesDrawn(graphIr) || noStateFill({ frame: !!embedOpts.bare, live: graphIr.nodes.some((n) => n.attrs && n.attrs._status) }))) {
|
|
207
212
|
const neutral = theme ? pinTokensFor(theme).neutralFill : tokens.neutral;
|
|
208
|
-
return { mode, fillOf: () => ({ fill: neutral, unpriced: false }) };
|
|
213
|
+
return { mode, neutral: true, fillOf: () => ({ fill: neutral, unpriced: false }) };
|
|
209
214
|
}
|
|
210
215
|
if (mode === "drift" || !tokens) {
|
|
211
216
|
return { mode, fillOf: (id) => ({ fill: colorForCategory(kindOf.get(id)), unpriced: false }) };
|
|
@@ -242,7 +247,8 @@ function recolorNodesByCategory(ir) {
|
|
|
242
247
|
const kind = kindOf.get(id);
|
|
243
248
|
if (!kind) continue;
|
|
244
249
|
const paint = plan.fillOf(id);
|
|
245
|
-
|
|
250
|
+
// behold#571: on the neutral card ground, the ink that reads best on it (theme.js inkOn).
|
|
251
|
+
const cat = paint.fill, ink = plan.neutral ? inkOn(cat) : readableOn(cat);
|
|
246
252
|
// #399: an unpriced card is marked, not merely coloured — a hex cannot be
|
|
247
253
|
// read back out into "the engine did not price this", and the legend's
|
|
248
254
|
// unpriced count has to agree with what is on the canvas.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// behold#571: the kiosk frame's card fill. In the frame a card's state is its
|
|
2
|
+
// outline, its bar and its words (web/app.js drawTgReads), never its fill, so
|
|
3
|
+
// every card there wears the theme's neutral card ground (pinTokensFor's
|
|
4
|
+
// `neutralFill`, the ground frameInks makes each state's words readable on).
|
|
5
|
+
// That holds for a card with no state yet, too: before a pull request's first
|
|
6
|
+
// plan, or when the reports name another checkout. Left to the category
|
|
7
|
+
// palette, such a card took the theme's hue for its kind, which in Sea Shells
|
|
8
|
+
// and others is a crimson that reads as "broken".
|
|
9
|
+
//
|
|
10
|
+
// Outside the frame, and on a graph that carries a live read (`_status`),
|
|
11
|
+
// the fill stays the category hue it always was.
|
|
12
|
+
|
|
13
|
+
/** Whether the cards take the neutral fill: in the kiosk's frame, on a graph with no live read. */
|
|
14
|
+
export function noStateFill({ frame = false, live = false } = {}) {
|
|
15
|
+
return !!frame && !live;
|
|
16
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { noStateFill } from "./frame-fill.js";
|
|
3
|
+
import { contrast, frameInks, inkOn, pinTokensFor, tokensFor } from "./theme.js";
|
|
4
|
+
import { THEMES } from "./themes.js";
|
|
5
|
+
|
|
6
|
+
// behold#571: a card in the kiosk's frame with no state yet wears the neutral
|
|
7
|
+
// card ground, never its category hue (crimson in Sea Shells, which read as
|
|
8
|
+
// "broken"), and stays readable on it in every theme.
|
|
9
|
+
describe("the kiosk frame's card fill (behold#571)", () => {
|
|
10
|
+
it("is the neutral ground in the frame, on a graph with no live read", () => {
|
|
11
|
+
expect(noStateFill({ frame: true })).toBe(true);
|
|
12
|
+
expect(noStateFill({ frame: true, live: true })).toBe(false);
|
|
13
|
+
expect(noStateFill({ frame: false })).toBe(false);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("was Sea Shells' crimson before, and is its neutral card ground now", () => {
|
|
17
|
+
const th = THEMES["Sea Shells"];
|
|
18
|
+
const fill = pinTokensFor(th).neutralFill;
|
|
19
|
+
expect(fill).not.toBe(tokensFor(th).degraded);
|
|
20
|
+
expect(contrast(fill, "#b8304a")).toBeGreaterThan(1.5);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("keeps a card's name and every state's words readable on it, in every theme (frameInks)", () => {
|
|
24
|
+
const short = [];
|
|
25
|
+
for (const th of Object.values(THEMES)) {
|
|
26
|
+
const fill = pinTokensFor(th).neutralFill;
|
|
27
|
+
const name = inkOn(fill);
|
|
28
|
+
if (contrast(name, fill) < 4.5) short.push(`${th.name} name ${name} on ${fill}: ${contrast(name, fill).toFixed(2)}`);
|
|
29
|
+
const inks = frameInks(th).card;
|
|
30
|
+
for (const [s, c] of Object.entries(inks)) if (contrast(c, fill) < 4.5) short.push(`${th.name} ${s} ${c} on ${fill}`);
|
|
31
|
+
}
|
|
32
|
+
expect(short).toEqual([]);
|
|
33
|
+
});
|
|
34
|
+
});
|
package/web/theme.js
CHANGED
|
@@ -44,6 +44,10 @@ export function contrast(a, b) {
|
|
|
44
44
|
const A = relLuminance(a), B = relLuminance(b);
|
|
45
45
|
return (Math.max(A, B) + 0.05) / (Math.min(A, B) + 0.05);
|
|
46
46
|
}
|
|
47
|
+
// behold#571: white or black, whichever reads better on `bg` by the real ratio
|
|
48
|
+
// above. readableOn's quick coin-flip picks white on a mid-tone ground where
|
|
49
|
+
// black reads better (Grass's and Blue Dolphin's neutral card).
|
|
50
|
+
export function inkOn(bg) { return contrast("#ffffff", bg) >= contrast("#000000", bg) ? "#ffffff" : "#000000"; }
|
|
47
51
|
export function hexToOklch(hex) {
|
|
48
52
|
const [R, G, B] = hexToRgb(hex).map(s2l);
|
|
49
53
|
const l = Math.cbrt(0.4122214708 * R + 0.5363325363 * G + 0.0514459929 * B);
|