@behavioral-agentic-design-system/core 0.39.1 → 0.42.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.
- package/README.md +2 -0
- package/package.json +26 -5
- package/scripts/a11y-lint.cjs +88 -8
- package/scripts/bads-components.mjs +118 -0
- package/scripts/build-tokens.cjs +133 -12
- package/scripts/check-stories.mjs +1 -1
- package/scripts/health-report.mjs +16 -2
- package/scripts/lint-component-source.mjs +100 -0
- package/scripts/lint-microanimation.mjs +267 -0
- package/scripts/lint-slop.mjs +25 -1
- package/scripts/size-audit.cjs +79 -0
- package/scripts/source-of-truth.cjs +58 -0
- package/scripts/ux-smoke.mjs +438 -0
- package/scripts/wcag-audit.cjs +121 -6
- package/src/api/layers/file.ts +1 -0
- package/src/app/opengraph-image.tsx +5 -0
- package/src/app/preview/components/page.tsx +2237 -2
- package/src/app/shell.tsx +17 -16
- package/src/components/Foundations/Motion.stories.tsx +1 -0
- package/src/components/customize/brand-mark-section.tsx +4 -2
- package/src/components/customize/design-controls.tsx +17 -2
- package/src/components/customize/discipline-section.tsx +3 -6
- package/src/components/customize/font-pickers.tsx +1 -1
- package/src/components/customize/letter-spacing.tsx +1 -1
- package/src/components/customize/save-bar.tsx +2 -2
- package/src/components/customize/theme-io.tsx +7 -7
- package/src/components/customize/type-scale.tsx +1 -1
- package/src/components/customize-tab.tsx +7 -4
- package/src/components/home-tab.tsx +3 -0
- package/src/components/studio/studio.tsx +153 -0
- package/src/components/ui/accordion.tsx +7 -0
- package/src/components/ui/alert.tsx +1 -0
- package/src/components/ui/anchor.tsx +37 -3
- package/src/components/ui/announcement-bar.tsx +256 -0
- package/src/components/ui/attachment.tsx +211 -0
- package/src/components/ui/badge.tsx +1 -0
- package/src/components/ui/callout.tsx +218 -0
- package/src/components/ui/chart.tsx +5 -14
- package/src/components/ui/code.tsx +1 -1
- package/src/components/ui/color-picker.tsx +2 -2
- package/src/components/ui/format-relative-time.tsx +139 -0
- package/src/components/ui/gauge-chart.tsx +238 -0
- package/src/components/ui/grid.tsx +255 -0
- package/src/components/ui/heatmap.tsx +256 -0
- package/src/components/ui/icon.tsx +108 -0
- package/src/components/ui/index.ts +17 -0
- package/src/components/ui/infinite-scroll.tsx +103 -0
- package/src/components/ui/json-input.tsx +351 -0
- package/src/components/ui/navigation-progress.tsx +281 -0
- package/src/components/ui/number-input.tsx +1 -4
- package/src/components/ui/page-header.tsx +63 -0
- package/src/components/ui/password-input.tsx +2 -1
- package/src/components/ui/password-strength-input.tsx +288 -0
- package/src/components/ui/pill.tsx +140 -0
- package/src/components/ui/popover.tsx +27 -4
- package/src/components/ui/portal.tsx +111 -0
- package/src/components/ui/presence.tsx +172 -0
- package/src/components/ui/progress-stack.tsx +258 -0
- package/src/components/ui/scroll-progress.tsx +100 -0
- package/src/components/ui/select.tsx +89 -4
- package/src/components/ui/separator.tsx +1 -0
- package/src/components/ui/slider.tsx +83 -3
- package/src/components/ui/snackbar.tsx +393 -0
- package/src/components/ui/sortable-list.tsx +342 -0
- package/src/components/ui/sparkline.tsx +2 -14
- package/src/components/ui/squircle.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/textarea.tsx +28 -1
- package/src/components/ui/tour.tsx +1 -3
- package/src/data/docs-index.ts +25 -0
- package/src/hooks/use-reduced-motion.ts +6 -0
- package/src/lib/clamp.ts +2 -0
- package/src/stories/Accordion.stories.tsx +59 -0
- package/src/stories/Alert.stories.tsx +3 -1
- package/src/stories/Anchor.stories.tsx +54 -0
- package/src/stories/AnnouncementBar.stories.tsx +261 -0
- package/src/stories/Attachment.stories.tsx +189 -0
- package/src/stories/Badge.stories.tsx +3 -0
- package/src/stories/Calendar.stories.tsx +1 -1
- package/src/stories/Callout.stories.tsx +219 -0
- package/src/stories/Chart.stories.tsx +8 -0
- package/src/stories/Code.stories.tsx +1 -0
- package/src/stories/ColorPicker.stories.tsx +24 -0
- package/src/stories/FormatRelativeTime.stories.tsx +116 -0
- package/src/stories/GaugeChart.stories.tsx +163 -0
- package/src/stories/Grid.stories.tsx +197 -0
- package/src/stories/Heatmap.stories.tsx +172 -0
- package/src/stories/Icon.stories.tsx +175 -0
- package/src/stories/InfiniteScroll.stories.tsx +225 -0
- package/src/stories/JsonInput.stories.tsx +212 -0
- package/src/stories/MultiSelect.stories.tsx +1 -1
- package/src/stories/NavigationProgress.stories.tsx +159 -0
- package/src/stories/NumberInput.stories.tsx +1 -0
- package/src/stories/PageHeader.stories.tsx +102 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
- package/src/stories/Pill.stories.tsx +201 -0
- package/src/stories/Popover.stories.tsx +29 -1
- package/src/stories/Portal.stories.tsx +191 -0
- package/src/stories/Presence.stories.tsx +228 -0
- package/src/stories/ProgressStack.stories.tsx +287 -0
- package/src/stories/ScrollProgress.stories.tsx +117 -0
- package/src/stories/Select.stories.tsx +25 -0
- package/src/stories/Separator.stories.tsx +3 -0
- package/src/stories/Slider.stories.tsx +54 -5
- package/src/stories/Snackbar.stories.tsx +315 -0
- package/src/stories/SortableList.stories.tsx +263 -0
- package/src/stories/Sparkline.stories.tsx +3 -0
- package/src/stories/Squircle.stories.tsx +1 -0
- package/src/stories/Table.stories.tsx +1 -0
- package/src/stories/Textarea.stories.tsx +18 -0
- package/src/stories/Tour.stories.tsx +1 -0
- package/src/stories/story-groups.json +26 -6
- package/src/styles.css +133 -12
- package/LICENSE +0 -21
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* ux-smoke — deterministic, browser-driven UX smoke gate for the Night Shift
|
|
4
|
+
* persona UX-test pass (scripts/prompts/night-shift.md → step 3d).
|
|
5
|
+
*
|
|
6
|
+
* Drives headless Chromium over one or more showcase anchors on a RUNNING
|
|
7
|
+
* preview server, IN BOTH LIGHT AND DARK THEMES, and runs the checks that a
|
|
8
|
+
* screenshot and the per-story CI axe run both miss:
|
|
9
|
+
*
|
|
10
|
+
* 1. axe (scoped to the anchor) — critical/serious => BLOCKER
|
|
11
|
+
* 2. rendered contrast (fg vs real bg) — < 4.5:1 => BLOCKER, < 7:1 (AAA) => HIGH
|
|
12
|
+
* 3. sub-14px rendered text (the floor) — computed font-size < 14px => HIGH
|
|
13
|
+
* 4. reduced-motion halt — any animation not collapsed => BLOCKER
|
|
14
|
+
* 5. anchor horizontal overflow — content wider than its box => BLOCKER
|
|
15
|
+
* 6. keyboard focus indicator — focusable el with no ring => WARN
|
|
16
|
+
*
|
|
17
|
+
* Running every check in BOTH themes is the point: it catches the "fixed in
|
|
18
|
+
* light, still broken in dark" asymmetry and the dark-on-dark / light-on-white
|
|
19
|
+
* text the token-pair audit can't see (that audit checks token pairs; this
|
|
20
|
+
* checks what actually paints on the assembled page). Each anchor is also
|
|
21
|
+
* screenshotted in both themes so the report can show the flow.
|
|
22
|
+
*
|
|
23
|
+
* Usage:
|
|
24
|
+
* pnpm ux:smoke <anchor> [anchor...]
|
|
25
|
+
* BASE_URL=http://localhost:3000 ROUTE=/preview/components \
|
|
26
|
+
* UX_SCREENS_DIR=/tmp/ux-screens pnpm ux:smoke buttons separator
|
|
27
|
+
*
|
|
28
|
+
* Exit 1 if any BLOCKER is produced (0 otherwise). Every finding + screenshot
|
|
29
|
+
* path is printed as one JSON line for the calling agent to log + attach.
|
|
30
|
+
*/
|
|
31
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
32
|
+
|
|
33
|
+
const BASE_URL = process.env.BASE_URL || "http://localhost:3000";
|
|
34
|
+
// ROUTE takes a comma-separated LIST. The default is still the components page,
|
|
35
|
+
// so nothing that calls this today changes behaviour.
|
|
36
|
+
const ROUTES = (process.env.ROUTE || "/preview/components")
|
|
37
|
+
.split(",")
|
|
38
|
+
.map((r) => r.trim())
|
|
39
|
+
.filter(Boolean);
|
|
40
|
+
// Mutable: reassigned per route by the sweep loop, and read by openPage().
|
|
41
|
+
let ROUTE = ROUTES[0];
|
|
42
|
+
let URL = BASE_URL.replace(/\/$/, "") + ROUTE;
|
|
43
|
+
const SCREENS_DIR = process.env.UX_SCREENS_DIR || "/tmp/ux-screens";
|
|
44
|
+
const argv = process.argv.slice(2).filter(Boolean);
|
|
45
|
+
// `--page` scopes every check to the WHOLE route instead of a named anchor.
|
|
46
|
+
//
|
|
47
|
+
// Without it this gate can only ever check what somebody remembered to name, and
|
|
48
|
+
// a gate aimed at a fraction of a page reports green on a broken page. That is
|
|
49
|
+
// not hypothetical: in the Furnished Finder fork it was being invoked with two
|
|
50
|
+
// anchors against a route carrying 61k characters of component demos, and it
|
|
51
|
+
// passed six consecutive nightly runs while that page had unreadable banner
|
|
52
|
+
// text, a collapsed slider, a tab pill overlapping body copy and clipped select
|
|
53
|
+
// values. Whole-page mode is one pseudo-anchor whose selector is `body`, so every
|
|
54
|
+
// existing check runs unchanged over the entire route.
|
|
55
|
+
const WHOLE_PAGE = argv.includes("--page");
|
|
56
|
+
const anchors = argv.filter((a) => !a.startsWith("--"));
|
|
57
|
+
|
|
58
|
+
/** Filesystem-safe slug for a route, so per-route screenshots cannot collide. */
|
|
59
|
+
const routeSlug = (route) => route.replace(/^\//, "").replace(/[^a-z0-9]+/gi, "-") || "root";
|
|
60
|
+
|
|
61
|
+
// A 404 that is the POINT of a demo rather than a defect. Each entry states why,
|
|
62
|
+
// because an unexplained allowlist is how a real defect gets waved through later.
|
|
63
|
+
// Empty here: BADS itself has no such demo. Forks add entries with a reason.
|
|
64
|
+
const MISSING_ASSET_ALLOWLIST = [];
|
|
65
|
+
const THEMES = ["light", "dark"];
|
|
66
|
+
// AAA is BADS's bar; BLOCKER only on a true AA failure (unreadable), HIGH on
|
|
67
|
+
// an AAA (7:1) miss so the brief can surface it without flooding.
|
|
68
|
+
const AAA = 7,
|
|
69
|
+
AA = 4.5,
|
|
70
|
+
AA_LARGE = 3;
|
|
71
|
+
|
|
72
|
+
if (anchors.length === 0 && !WHOLE_PAGE) {
|
|
73
|
+
console.error("ux-smoke: pass at least one showcase anchor, e.g. `pnpm ux:smoke buttons separator`");
|
|
74
|
+
console.error(" or `pnpm ux:smoke --page` to check the whole route.");
|
|
75
|
+
process.exit(2);
|
|
76
|
+
}
|
|
77
|
+
mkdirSync(SCREENS_DIR, { recursive: true });
|
|
78
|
+
|
|
79
|
+
function chromiumExecutable() {
|
|
80
|
+
if (process.env.PW_CHROMIUM && existsSync(process.env.PW_CHROMIUM)) return process.env.PW_CHROMIUM;
|
|
81
|
+
for (const c of [
|
|
82
|
+
"/opt/pw-browsers/chromium-1194/chrome-linux/chrome",
|
|
83
|
+
"/opt/pw-browsers/chromium/chrome-linux/chrome",
|
|
84
|
+
]) if (existsSync(c)) return c;
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let chromium, injectAxe, getViolations;
|
|
89
|
+
try {
|
|
90
|
+
({ chromium } = await import("playwright"));
|
|
91
|
+
({ injectAxe, getViolations } = await import("axe-playwright"));
|
|
92
|
+
} catch (e) {
|
|
93
|
+
console.error("ux-smoke: playwright / axe-playwright not installed — run `pnpm install`.", e.message);
|
|
94
|
+
process.exit(2);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const findings = [];
|
|
98
|
+
const screenshots = [];
|
|
99
|
+
const add = (f) => { findings.push(f); console.log(JSON.stringify({ type: "finding", ...f })); };
|
|
100
|
+
|
|
101
|
+
const exe = chromiumExecutable();
|
|
102
|
+
const browser = await chromium.launch(exe ? { executablePath: exe } : {});
|
|
103
|
+
|
|
104
|
+
async function openPage(theme, opts = {}) {
|
|
105
|
+
const ctx = await browser.newContext({ viewport: { width: 1280, height: 1400 }, deviceScaleFactor: 2, ...opts });
|
|
106
|
+
const page = await ctx.newPage();
|
|
107
|
+
// Track subresources that never arrived. A missing image does not throw; it
|
|
108
|
+
// degrades into whatever is painted underneath, and no contrast gate can
|
|
109
|
+
// attribute the resulting reading to the asset that is missing.
|
|
110
|
+
page.__failedRequests = [];
|
|
111
|
+
page.on("response", (r) => {
|
|
112
|
+
const st = r.status();
|
|
113
|
+
if (st >= 400) page.__failedRequests.push(`${st} ${r.url()}`);
|
|
114
|
+
});
|
|
115
|
+
page.on("requestfailed", (r) => {
|
|
116
|
+
page.__failedRequests.push(`FAILED ${r.url()} (${r.failure()?.errorText || "unknown"})`);
|
|
117
|
+
});
|
|
118
|
+
// The preview app toggles dark via the `?dark=1` query param (dark-mode-client.tsx),
|
|
119
|
+
// NOT localStorage — use the app's real mechanism so the theme is deterministic.
|
|
120
|
+
const dark = theme === "dark";
|
|
121
|
+
const url = dark ? URL + (URL.includes("?") ? "&" : "?") + "dark=1" : URL;
|
|
122
|
+
const res = await page.goto(url, { waitUntil: "networkidle", timeout: 60000 }).catch(() => null);
|
|
123
|
+
if (!res || !res.ok()) { await ctx.close(); throw new Error(`could not load ${url} (is the preview server running?)`); }
|
|
124
|
+
// Verify the theme actually took (the toggle runs in a useEffect). Retry a few
|
|
125
|
+
// times, force the class as a fallback, and confirm the painted body bg matches
|
|
126
|
+
// the expected theme before any probe reads colors — a flaky theme = a flaky gate.
|
|
127
|
+
for (let i = 0; i < 6; i++) {
|
|
128
|
+
const ok = await page.evaluate((wantDark) => {
|
|
129
|
+
const r = document.documentElement;
|
|
130
|
+
const has = r.classList.contains("dark");
|
|
131
|
+
if (has !== wantDark) { r.classList.toggle("dark", wantDark); r.style.colorScheme = wantDark ? "dark" : "light"; return false; }
|
|
132
|
+
// confirm it actually painted: body bg luminance should match the theme
|
|
133
|
+
const cv = document.createElement("canvas").getContext("2d", { willReadFrequently: true });
|
|
134
|
+
cv.fillStyle = getComputedStyle(document.body).backgroundColor; cv.fillRect(0, 0, 1, 1);
|
|
135
|
+
const d = cv.getImageData(0, 0, 1, 1).data;
|
|
136
|
+
const L = (0.2126 * d[0] + 0.7152 * d[1] + 0.0722 * d[2]) / 255;
|
|
137
|
+
return wantDark ? L < 0.4 : L > 0.6;
|
|
138
|
+
}, dark);
|
|
139
|
+
if (ok) break;
|
|
140
|
+
await page.waitForTimeout(200);
|
|
141
|
+
}
|
|
142
|
+
await page.waitForTimeout(200);
|
|
143
|
+
return { ctx, page };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// In-page contrast helpers, injected as a string so they run in the browser.
|
|
147
|
+
const CONTRAST_PROBE = `(sel, AAA, AA, AA_LARGE) => {
|
|
148
|
+
const root = document.querySelector(sel);
|
|
149
|
+
if (!root) return [];
|
|
150
|
+
// Normalize ANY computed color (oklch/oklab/hsl/named/hex/rgb) to sRGB by
|
|
151
|
+
// rasterizing one pixel — getComputedStyle preserves oklch (which every BADS
|
|
152
|
+
// token uses), so string-parsing rgb() alone silently misreads everything.
|
|
153
|
+
const _cv = document.createElement('canvas'); _cv.width = 1; _cv.height = 1;
|
|
154
|
+
const _ctx = _cv.getContext('2d', { willReadFrequently: true });
|
|
155
|
+
const parse = (c) => {
|
|
156
|
+
if (!c) return null;
|
|
157
|
+
try {
|
|
158
|
+
_ctx.clearRect(0, 0, 1, 1);
|
|
159
|
+
_ctx.fillStyle = '#000000';
|
|
160
|
+
_ctx.fillStyle = c;
|
|
161
|
+
_ctx.fillRect(0, 0, 1, 1);
|
|
162
|
+
const d = _ctx.getImageData(0, 0, 1, 1).data;
|
|
163
|
+
return { r: d[0], g: d[1], b: d[2], a: d[3] / 255 };
|
|
164
|
+
} catch { return null; }
|
|
165
|
+
};
|
|
166
|
+
const lin = (v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4); };
|
|
167
|
+
const lum = (c) => 0.2126 * lin(c.r) + 0.7152 * lin(c.g) + 0.0722 * lin(c.b);
|
|
168
|
+
const ratio = (f, b) => { const L1 = lum(f), L2 = lum(b); const hi = Math.max(L1, L2), lo = Math.min(L1, L2); return (hi + 0.05) / (lo + 0.05); };
|
|
169
|
+
const over = (fg, bg) => ({ // source-over composite fg (with alpha) onto opaque bg
|
|
170
|
+
r: fg.r * fg.a + bg.r * (1 - fg.a),
|
|
171
|
+
g: fg.g * fg.a + bg.g * (1 - fg.a),
|
|
172
|
+
b: fg.b * fg.a + bg.b * (1 - fg.a),
|
|
173
|
+
a: 1,
|
|
174
|
+
});
|
|
175
|
+
// True painted background: composite every semi-transparent bg layer from the
|
|
176
|
+
// element up to the root, in paint order. A naive "first opaque ancestor"
|
|
177
|
+
// walk misreads bg-*/10 tints (bg-destructive/10 over a dark card) — the exact
|
|
178
|
+
// case that produces false red-on-red readings.
|
|
179
|
+
//
|
|
180
|
+
// Second rule, added after a measured false positive: a layer only counts if it
|
|
181
|
+
// actually SITS BEHIND THE TEXT. An ancestor paints its own box, not its
|
|
182
|
+
// descendants boxes, and an absolutely-positioned child can sit entirely
|
|
183
|
+
// outside its parent rect.
|
|
184
|
+
//
|
|
185
|
+
// The case, from the Furnished Finder fork: a Slider step label is positioned
|
|
186
|
+
// below its own 4x4px brand-blue dot, so the walk composited the dot and
|
|
187
|
+
// reported the label as blue-on-blue at 1:1. Zero rect overlap; a pixel sample
|
|
188
|
+
// of the glyph area was 913 of 1092 pure white, and the real ratio was 8.88:1.
|
|
189
|
+
//
|
|
190
|
+
// A false BLOCKER is not a cheap mistake: it sends someone to fix a component
|
|
191
|
+
// that is already correct, and a gate that cries wolf gets bypassed rather than
|
|
192
|
+
// obeyed. So intersect first, composite second.
|
|
193
|
+
const intersects = (a, b) => a.right > b.left && a.left < b.right && a.bottom > b.top && a.top < b.bottom;
|
|
194
|
+
const effectiveBg = (el) => {
|
|
195
|
+
const layers = [];
|
|
196
|
+
const target = el.getBoundingClientRect();
|
|
197
|
+
let n = el, untrusted = false;
|
|
198
|
+
while (n && n !== document.documentElement) {
|
|
199
|
+
const cs = getComputedStyle(n);
|
|
200
|
+
// Skip a layer whose painted box does not cover the text at all.
|
|
201
|
+
if (n !== el && !intersects(target, n.getBoundingClientRect())) { n = n.parentElement; continue; }
|
|
202
|
+
if (cs.backgroundImage && cs.backgroundImage !== "none") untrusted = true; // gradient/image — can't know the pixel
|
|
203
|
+
if (cs.backdropFilter && cs.backdropFilter !== "none") untrusted = true;
|
|
204
|
+
const bg = parse(cs.backgroundColor);
|
|
205
|
+
if (bg && bg.a > 0.001) layers.push(bg);
|
|
206
|
+
n = n.parentElement;
|
|
207
|
+
}
|
|
208
|
+
let base = parse(getComputedStyle(document.body).backgroundColor);
|
|
209
|
+
if (!base || base.a < 0.99) base = parse(getComputedStyle(document.documentElement).backgroundColor);
|
|
210
|
+
if (!base || base.a < 0.99) base = { r: 255, g: 255, b: 255, a: 1 };
|
|
211
|
+
// composite from the root layer (last collected) down to the element (first)
|
|
212
|
+
let acc = { r: base.r, g: base.g, b: base.b, a: 1 };
|
|
213
|
+
for (let i = layers.length - 1; i >= 0; i--) acc = over(layers[i], acc);
|
|
214
|
+
acc.untrusted = untrusted;
|
|
215
|
+
return acc;
|
|
216
|
+
};
|
|
217
|
+
const isDisabled = (el) => !!el.closest('[disabled],[aria-disabled="true"],[data-disabled]') ||
|
|
218
|
+
/opacity-[0-5]0\\b/.test(el.className || "");
|
|
219
|
+
const out = [];
|
|
220
|
+
const seen = new Set();
|
|
221
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
222
|
+
let node;
|
|
223
|
+
while ((node = walker.nextNode())) {
|
|
224
|
+
const text = node.textContent.trim();
|
|
225
|
+
if (!text || text.length < 2) continue;
|
|
226
|
+
const el = node.parentElement;
|
|
227
|
+
if (!el) continue;
|
|
228
|
+
const s = getComputedStyle(el);
|
|
229
|
+
if (s.visibility === "hidden" || s.display === "none" || parseFloat(s.opacity) < 0.7) continue;
|
|
230
|
+
const rect = el.getBoundingClientRect();
|
|
231
|
+
if (rect.width < 2 || rect.height < 2) continue;
|
|
232
|
+
if (isDisabled(el)) continue;
|
|
233
|
+
let fg = parse(s.color);
|
|
234
|
+
if (!fg || fg.a < 0.3) continue;
|
|
235
|
+
const bg = effectiveBg(el);
|
|
236
|
+
if (fg.a < 1) fg = over(fg, bg); // composite translucent text onto its real bg
|
|
237
|
+
const r = ratio(fg, bg);
|
|
238
|
+
const fs = parseFloat(s.fontSize);
|
|
239
|
+
const large = fs >= 24 || (fs >= 18.66 && parseInt(s.fontWeight) >= 700);
|
|
240
|
+
const blockAt = large ? AA_LARGE : AA;
|
|
241
|
+
const aaaAt = large ? AA : AAA;
|
|
242
|
+
const key = Math.round(fg.r) + "," + Math.round(fg.g) + "," + Math.round(fg.b) + "|" + Math.round(bg.r) + "," + Math.round(bg.g) + "," + Math.round(bg.b);
|
|
243
|
+
if (seen.has(key)) continue;
|
|
244
|
+
seen.add(key);
|
|
245
|
+
if (r < aaaAt) {
|
|
246
|
+
// BLOCKER only for a confident AA failure on a fully-determinable bg.
|
|
247
|
+
// Over a gradient/image/backdrop-filter (untrusted) we can't know the
|
|
248
|
+
// painted pixel, so cap at HIGH for the agent to eyeball in the shot.
|
|
249
|
+
const sev = r < blockAt ? (bg.untrusted ? "HIGH" : "BLOCKER") : "HIGH";
|
|
250
|
+
out.push({
|
|
251
|
+
ratio: Math.round(r * 100) / 100,
|
|
252
|
+
severity: sev,
|
|
253
|
+
untrusted: !!bg.untrusted,
|
|
254
|
+
fontSizePx: fs, large,
|
|
255
|
+
fg: 'rgb(' + Math.round(fg.r) + ',' + Math.round(fg.g) + ',' + Math.round(fg.b) + ')',
|
|
256
|
+
bg: 'rgb(' + Math.round(bg.r) + ',' + Math.round(bg.g) + ',' + Math.round(bg.b) + ')',
|
|
257
|
+
sample: text.slice(0, 40),
|
|
258
|
+
tag: el.tagName.toLowerCase(),
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
return out.sort((a, b) => a.ratio - b.ratio).slice(0, 12);
|
|
263
|
+
}`;
|
|
264
|
+
|
|
265
|
+
const SUBFLOOR_PROBE = `(sel) => {
|
|
266
|
+
const root = document.querySelector(sel);
|
|
267
|
+
if (!root) return [];
|
|
268
|
+
const out = [];
|
|
269
|
+
const seen = new Set();
|
|
270
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
271
|
+
let node;
|
|
272
|
+
while ((node = walker.nextNode())) {
|
|
273
|
+
const text = node.textContent.trim();
|
|
274
|
+
if (!text) continue;
|
|
275
|
+
const el = node.parentElement;
|
|
276
|
+
const s = getComputedStyle(el);
|
|
277
|
+
if (s.visibility === "hidden" || s.display === "none") continue;
|
|
278
|
+
const fs = parseFloat(s.fontSize);
|
|
279
|
+
if (fs && fs < 14) {
|
|
280
|
+
const key = fs + "|" + el.tagName + "|" + text.slice(0, 20);
|
|
281
|
+
if (seen.has(key)) continue;
|
|
282
|
+
seen.add(key);
|
|
283
|
+
out.push({ fontSizePx: fs, sample: text.slice(0, 40), tag: el.tagName.toLowerCase() });
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return out.slice(0, 8);
|
|
287
|
+
}`;
|
|
288
|
+
|
|
289
|
+
// Whole-page mode checks one pseudo-anchor whose selector is `body`.
|
|
290
|
+
if (WHOLE_PAGE) anchors.push("__page__");
|
|
291
|
+
|
|
292
|
+
for (const __route of ROUTES) {
|
|
293
|
+
ROUTE = __route;
|
|
294
|
+
URL = BASE_URL.replace(/\/$/, "") + ROUTE;
|
|
295
|
+
if (ROUTES.length > 1) console.log(JSON.stringify({ type: "route", route: ROUTE }));
|
|
296
|
+
|
|
297
|
+
for (const anchor of anchors) {
|
|
298
|
+
const sel = anchor === "__page__" ? "body" : `#${anchor}`;
|
|
299
|
+
|
|
300
|
+
for (const theme of THEMES) {
|
|
301
|
+
// Reduced motion on the MEASURING pass, deliberately.
|
|
302
|
+
//
|
|
303
|
+
// Without it axe samples elements mid-animation: a skeleton using animate-pulse
|
|
304
|
+
// interpolates opacity 1 to 0.5, so the reading is whatever phase the frame
|
|
305
|
+
// landed on, which is not a design value and differs run to run. Measured in a
|
|
306
|
+
// fork carrying the same code: eight consecutive loads of an UNCHANGED page gave
|
|
307
|
+
// 3, 3, 1, 0, 3, 3, 1, 0 findings, with the same heading reading #919191, #888888
|
|
308
|
+
// and #868686 on different runs. Under reduced motion the same page is clean on
|
|
309
|
+
// four consecutive runs.
|
|
310
|
+
//
|
|
311
|
+
// A gate that reports a different number each night teaches people to re-run it
|
|
312
|
+
// until it is green, which is worse than not having it. check-rendered-contrast
|
|
313
|
+
// already measures this way for the same reason. The dedicated reduced-motion
|
|
314
|
+
// check below opens its own context and is unaffected.
|
|
315
|
+
const { ctx, page } = await openPage(theme, { reducedMotion: "reduce" });
|
|
316
|
+
const el = await page.$(sel);
|
|
317
|
+
if (!el) {
|
|
318
|
+
if (theme === "light") add({ anchor, theme, check: "anchor", severity: "BLOCKER", detail: `anchor ${sel} not found on ${ROUTE}` });
|
|
319
|
+
await ctx.close();
|
|
320
|
+
continue;
|
|
321
|
+
}
|
|
322
|
+
await el.scrollIntoViewIfNeeded();
|
|
323
|
+
await page.waitForTimeout(200);
|
|
324
|
+
|
|
325
|
+
// screenshot this theme
|
|
326
|
+
const shot = `${SCREENS_DIR}/${ROUTES.length > 1 ? routeSlug(ROUTE) + "-" : ""}${anchor}-${theme}.png`;
|
|
327
|
+
await el.screenshot({ path: shot }).catch(() => {});
|
|
328
|
+
if (existsSync(shot)) { screenshots.push(shot); console.log(JSON.stringify({ type: "screenshot", anchor, theme, path: shot })); }
|
|
329
|
+
|
|
330
|
+
// 0. subresources that never arrived.
|
|
331
|
+
//
|
|
332
|
+
// Whole-page only: a per-anchor run cannot attribute a page-level request to
|
|
333
|
+
// the anchor it was scoped to, so reporting it there would blame the wrong
|
|
334
|
+
// section. A missing image does not throw — it degrades into whatever is
|
|
335
|
+
// painted underneath, and every contrast reading taken over it is a reading
|
|
336
|
+
// of the wrong thing.
|
|
337
|
+
if (anchor === "__page__") {
|
|
338
|
+
// Deduplicate: Next re-requests the same missing asset per render pass.
|
|
339
|
+
const uniq = [...new Set(page.__failedRequests || [])].filter(
|
|
340
|
+
(u) => !/\/_next\/(static|image)\/|hot-update|__nextjs/.test(u),
|
|
341
|
+
);
|
|
342
|
+
for (const u of uniq) {
|
|
343
|
+
const allowed = MISSING_ASSET_ALLOWLIST.find((a) => u.includes(a.match));
|
|
344
|
+
if (allowed) {
|
|
345
|
+
console.log(JSON.stringify({ type: "allowed", check: "missing-asset", url: u, reason: allowed.reason }));
|
|
346
|
+
continue;
|
|
347
|
+
}
|
|
348
|
+
add({
|
|
349
|
+
anchor, theme, check: "missing-asset", severity: "BLOCKER",
|
|
350
|
+
detail: `a subresource the page asks for never arrived: ${u} — a missing image does not throw, it degrades into whatever is painted underneath, which no contrast gate can attribute`,
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// 1. axe (scoped)
|
|
356
|
+
await injectAxe(page);
|
|
357
|
+
const violations = await getViolations(page, sel, { runOnly: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"] })
|
|
358
|
+
.catch((e) => { add({ anchor, theme, check: "axe", severity: "WARN", detail: `axe run failed: ${e.message}` }); return []; });
|
|
359
|
+
for (const v of violations) {
|
|
360
|
+
const blocker = v.impact === "critical" || v.impact === "serious";
|
|
361
|
+
add({ anchor, theme, check: "axe", severity: blocker ? "BLOCKER" : "WARN", rule: v.id, impact: v.impact, nodes: v.nodes.length, detail: v.help });
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
// 2. rendered contrast (the dark-on-dark / light-on-white catcher)
|
|
365
|
+
const contrast = await page.evaluate(`(${CONTRAST_PROBE})('${sel}', ${AAA}, ${AA}, ${AA_LARGE})`);
|
|
366
|
+
for (const c of contrast) {
|
|
367
|
+
add({ anchor, theme, check: "contrast", severity: c.severity, ratio: c.ratio, detail: `"${c.sample}" ${c.fg} on ${c.bg} = ${c.ratio}:1 (${c.large ? "large" : "normal"} text, needs ${c.large ? "4.5" : "7"}:1 AAA${c.severity === "BLOCKER" ? "; fails even AA — reads as unreadable" : ""}${c.untrusted ? "; over a gradient/image so bg is estimated — eyeball the screenshot" : ""})` });
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// 5. anchor horizontal overflow
|
|
371
|
+
const overflow = await el.evaluate((n) => ({ overflows: n.scrollWidth > n.clientWidth + 1, by: n.scrollWidth - n.clientWidth }));
|
|
372
|
+
if (overflow.overflows) add({ anchor, theme, check: "overflow-x", severity: "BLOCKER", detail: `anchor overflows its box by ${overflow.by}px (layout break / long-string risk)` });
|
|
373
|
+
|
|
374
|
+
// 6. keyboard focus indicator (WARN)
|
|
375
|
+
const focusables = await page.$$(`${sel} a[href], ${sel} button:not([disabled]), ${sel} [tabindex]:not([tabindex="-1"]), ${sel} input:not([disabled]), ${sel} select:not([disabled])`);
|
|
376
|
+
let noRing = 0;
|
|
377
|
+
for (const f of focusables.slice(0, 12)) {
|
|
378
|
+
const ring = await f.evaluate((n) => {
|
|
379
|
+
n.focus();
|
|
380
|
+
const s = getComputedStyle(n);
|
|
381
|
+
const outline = s.outlineStyle !== "none" && parseFloat(s.outlineWidth) > 0;
|
|
382
|
+
const shadow = s.boxShadow && s.boxShadow !== "none" && /rgb|hsl|oklch/.test(s.boxShadow);
|
|
383
|
+
const ringClass = /focus-visible:ring|focus-visible:outline|focus:ring/.test(n.className || "");
|
|
384
|
+
return outline || shadow || ringClass;
|
|
385
|
+
}).catch(() => true);
|
|
386
|
+
if (!ring) noRing++;
|
|
387
|
+
}
|
|
388
|
+
if (noRing > 0) add({ anchor, theme, check: "focus-ring", severity: "WARN", detail: `${noRing} focusable element(s) with no detectable focus indicator` });
|
|
389
|
+
|
|
390
|
+
await ctx.close();
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// 3. sub-14px rendered text (theme-independent — run once)
|
|
394
|
+
{
|
|
395
|
+
const { ctx, page } = await openPage("light");
|
|
396
|
+
const el = await page.$(sel);
|
|
397
|
+
if (el) {
|
|
398
|
+
await el.scrollIntoViewIfNeeded();
|
|
399
|
+
const tiny = await page.evaluate(`(${SUBFLOOR_PROBE})('${sel}')`);
|
|
400
|
+
for (const t of tiny) add({ anchor, theme: "both", check: "font-size", severity: "HIGH", detail: `"${t.sample}" renders at ${t.fontSizePx}px (below the 14px floor)` });
|
|
401
|
+
}
|
|
402
|
+
await ctx.close();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// 4. reduced-motion (dark theme happens to exercise the same rule; run once)
|
|
406
|
+
{
|
|
407
|
+
const { ctx, page } = await openPage("light", { reducedMotion: "reduce" });
|
|
408
|
+
const el = await page.$(sel);
|
|
409
|
+
if (el) {
|
|
410
|
+
await el.scrollIntoViewIfNeeded();
|
|
411
|
+
const running = await el.evaluate((root) => {
|
|
412
|
+
const bad = [];
|
|
413
|
+
for (const n of root.querySelectorAll("*")) {
|
|
414
|
+
const s = getComputedStyle(n);
|
|
415
|
+
if (s.animationName !== "none" && parseFloat(s.animationDuration) > 0.05) bad.push({ tag: n.tagName.toLowerCase(), dur: s.animationDuration });
|
|
416
|
+
}
|
|
417
|
+
return bad.slice(0, 5);
|
|
418
|
+
});
|
|
419
|
+
if (running.length) add({ anchor, theme: "both", check: "reduced-motion", severity: "BLOCKER", detail: `${running.length} animation(s) not halted under prefers-reduced-motion`, samples: running });
|
|
420
|
+
}
|
|
421
|
+
await ctx.close();
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
await browser.close();
|
|
427
|
+
|
|
428
|
+
const blockers = findings.filter((f) => f.severity === "BLOCKER");
|
|
429
|
+
const highs = findings.filter((f) => f.severity === "HIGH");
|
|
430
|
+
const warns = findings.filter((f) => f.severity === "WARN");
|
|
431
|
+
console.log(JSON.stringify({
|
|
432
|
+
type: "summary", routes: ROUTES, anchors, themes: THEMES,
|
|
433
|
+
blockers: blockers.length, highs: highs.length, warns: warns.length,
|
|
434
|
+
screenshots, screensDir: SCREENS_DIR,
|
|
435
|
+
verdict: blockers.length ? "FAIL" : "PASS",
|
|
436
|
+
}));
|
|
437
|
+
|
|
438
|
+
process.exit(blockers.length ? 1 : 0);
|
package/scripts/wcag-audit.cjs
CHANGED
|
@@ -118,6 +118,24 @@ const json = process.argv.includes('--json');
|
|
|
118
118
|
const NORMAL_FLOOR = aa ? 4.5 : 7.0;
|
|
119
119
|
const LARGE_FLOOR = aa ? 3.0 : 4.5;
|
|
120
120
|
|
|
121
|
+
// Client-owned mode (.client-identity.json → sourceOfTruth.components ===
|
|
122
|
+
// "client") downgrades AAA (7:1) token-pair failures to warnings — still
|
|
123
|
+
// printed, never failing the build — because a client's own component
|
|
124
|
+
// library is generally built to AA, not AAA, and a red pipeline over a
|
|
125
|
+
// palette BADS didn't choose is a bad way to open that conversation. See
|
|
126
|
+
// docs/superpowers/specs/2026-09-10-client-owned-components-design.md →
|
|
127
|
+
// "Accessibility floor: flag, do not enforce" and CLAUDE.md → Accessibility
|
|
128
|
+
// Floor. readSourceOfTruth() never throws and defaults to "bads" with no
|
|
129
|
+
// identity file, so upstream BADS and "bads"-owned forks are unaffected.
|
|
130
|
+
//
|
|
131
|
+
// Only the AAA invocation downgrades. `--aa` is an explicit request for the
|
|
132
|
+
// real WCAG AA standard (not a BADS house opinion), so it keeps blocking even
|
|
133
|
+
// on a client-owned fork.
|
|
134
|
+
const { readSourceOfTruth } = require('./source-of-truth.cjs');
|
|
135
|
+
const CLIENT_OWNED = readSourceOfTruth(process.cwd()).components === 'client';
|
|
136
|
+
const DOWNGRADE_AAA = CLIENT_OWNED && !aa;
|
|
137
|
+
const CLIENT_OWNED_NOTE = 'warned, not failed: components are client-owned';
|
|
138
|
+
|
|
121
139
|
// ---- color math (oklch → linear sRGB → relative luminance) -------------
|
|
122
140
|
|
|
123
141
|
function clamp(n, min, max) { return Math.min(max, Math.max(min, n)); }
|
|
@@ -218,13 +236,49 @@ function toHex([r, g, b]) {
|
|
|
218
236
|
|
|
219
237
|
const tokens = JSON.parse(fs.readFileSync(TOKENS, 'utf8'));
|
|
220
238
|
|
|
221
|
-
|
|
239
|
+
// Walk a dotted DTCG path ("theme.light.card", "color.semantic.action.primary")
|
|
240
|
+
// against the FULL tokens tree, not just the current mode — an alias can
|
|
241
|
+
// point anywhere in tokens.json, e.g. a dark-mode slot aliasing back to
|
|
242
|
+
// {theme.light.card}, or either mode aliasing a {color.semantic.*} value.
|
|
243
|
+
// Returns the node at that path (which may itself carry a $value to resolve
|
|
244
|
+
// further), or undefined if the path doesn't exist.
|
|
245
|
+
function resolveDottedPath(dotted) {
|
|
246
|
+
let node = tokens;
|
|
247
|
+
for (const part of dotted.split('.')) {
|
|
248
|
+
if (node == null || typeof node !== 'object') return undefined;
|
|
249
|
+
node = node[part];
|
|
250
|
+
}
|
|
251
|
+
return node;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// resolveValue is recursive (var(--x) can point at another var(--x); a
|
|
255
|
+
// {dotted.path} alias can point at another alias). A cycle in a broken
|
|
256
|
+
// consumer's tokens.json would recurse forever without a depth guard — this
|
|
257
|
+
// isn't a hypothetical, it's exactly the kind of malformed input a
|
|
258
|
+
// third-party fork's tokens.json can contain, and this script is not a
|
|
259
|
+
// build-time gate a bad tokens.json would ever get caught by first.
|
|
260
|
+
function resolveValue(value, modeTokens, depth) {
|
|
261
|
+
depth = depth || 0;
|
|
262
|
+
if (depth > 10) return null;
|
|
222
263
|
if (typeof value !== 'string') return null;
|
|
223
264
|
// var(--name) — look up in same-mode tokens
|
|
224
265
|
const varMatch = value.match(/^var\(--([^)]+)\)$/);
|
|
225
266
|
if (varMatch) {
|
|
226
267
|
const ref = modeTokens[varMatch[1]];
|
|
227
|
-
return ref ? resolveValue(ref.$value, modeTokens) : null;
|
|
268
|
+
return ref ? resolveValue(ref.$value, modeTokens, depth + 1) : null;
|
|
269
|
+
}
|
|
270
|
+
// {dotted.path} — DTCG alias syntax (see e.g. tokens.composites.surface.card.background
|
|
271
|
+
// -> {theme.light.card} for the convention already used elsewhere in tokens.json).
|
|
272
|
+
// theme.light/theme.dark never used this themselves in upstream BADS, which is exactly
|
|
273
|
+
// why this branch didn't exist until a consumer fork's tokens.json used one directly in
|
|
274
|
+
// a theme slot and every pair depending on it silently vanished from the audit instead
|
|
275
|
+
// of failing or being counted as skipped (found 2026-09-15, from a real client fork).
|
|
276
|
+
const aliasMatch = value.match(/^\{([\w.-]+)\}$/);
|
|
277
|
+
if (aliasMatch) {
|
|
278
|
+
const node = resolveDottedPath(aliasMatch[1]);
|
|
279
|
+
if (node === undefined) return null;
|
|
280
|
+
const nextValue = node && typeof node === 'object' ? node.$value : node;
|
|
281
|
+
return resolveValue(nextValue, modeTokens, depth + 1);
|
|
228
282
|
}
|
|
229
283
|
// oklch(from var(--x) calc(l + 0.1) c h) etc — too complex to evaluate, skip.
|
|
230
284
|
if (value.includes('oklch(from')) return null;
|
|
@@ -303,7 +357,10 @@ function audit(modeName, modeTokens) {
|
|
|
303
357
|
for (const [fgKey, bgKey, label, opts] of PAIRS) {
|
|
304
358
|
const fgTok = modeTokens[fgKey];
|
|
305
359
|
const bgTok = modeTokens[bgKey];
|
|
306
|
-
if (!fgTok || !bgTok)
|
|
360
|
+
if (!fgTok || !bgTok) {
|
|
361
|
+
results.push({ mode: modeName, fgKey, bgKey, label, status: 'skipped', reason: 'missing-token' });
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
307
364
|
const fgRaw = resolveValue(fgTok.$value, modeTokens);
|
|
308
365
|
const bgRaw = resolveValue(bgTok.$value, modeTokens);
|
|
309
366
|
if (!fgRaw || !bgRaw) {
|
|
@@ -334,10 +391,23 @@ function audit(modeName, modeTokens) {
|
|
|
334
391
|
for (const [fgKey, bgKey, label, opts] of NON_TEXT_PAIRS) {
|
|
335
392
|
const fgTok = modeTokens[fgKey];
|
|
336
393
|
const bgTok = modeTokens[bgKey];
|
|
337
|
-
if (!fgTok || !bgTok)
|
|
394
|
+
if (!fgTok || !bgTok) {
|
|
395
|
+
results.push({ mode: modeName, fgKey, bgKey, label, kind: 'non-text', status: 'skipped', reason: 'missing-token' });
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
338
398
|
const fgRaw = resolveValue(fgTok.$value, modeTokens);
|
|
339
399
|
const bgRaw = resolveValue(bgTok.$value, modeTokens);
|
|
340
|
-
if (!fgRaw || !bgRaw)
|
|
400
|
+
if (!fgRaw || !bgRaw) {
|
|
401
|
+
// Previously a bare `continue` here — non-text pairs (border/ring/chart
|
|
402
|
+
// colors) vanished from the report with NO trace at all when a value
|
|
403
|
+
// failed to resolve, unlike the PAIRS loop above which at least counted
|
|
404
|
+
// it as "skipped". This is the more severe half of the bug: not
|
|
405
|
+
// miscounted, just gone. Found 2026-09-15 alongside the {token.reference}
|
|
406
|
+
// alias-resolution gap — the two compounded, since an unresolved alias in
|
|
407
|
+
// a non-text slot (e.g. a border color) produced zero signal anywhere.
|
|
408
|
+
results.push({ mode: modeName, fgKey, bgKey, label, kind: 'non-text', status: 'skipped', reason: 'unresolvable' });
|
|
409
|
+
continue;
|
|
410
|
+
}
|
|
341
411
|
const bg = flattenOver(bgRaw, [1, 1, 1]);
|
|
342
412
|
const fg = flattenOver(fgRaw, bg);
|
|
343
413
|
const ratio = contrast(fg, bg);
|
|
@@ -480,9 +550,31 @@ for (const r of all) {
|
|
|
480
550
|
// it never matched a real row at all. Reported, never build-failing: see findStaleExceptions.
|
|
481
551
|
const staleExceptions = findStaleExceptions(exceptions, all);
|
|
482
552
|
|
|
553
|
+
// Client-owned degrade: recategorize AAA fails as warns before either output
|
|
554
|
+
// path (json or human-readable) reads `all`, so both report the same
|
|
555
|
+
// downgraded status and the same non-blocking exit code.
|
|
556
|
+
//
|
|
557
|
+
// TEXT pairs only. Non-text pairs are NOT downgraded, because they are not an
|
|
558
|
+
// AAA requirement: NORMAL_FLOOR and LARGE_FLOOR move with `--aa` (7.0/4.5 vs
|
|
559
|
+
// 4.5/3.0) but NON_TEXT_FLOOR is a flat 3.0 in both modes, since SC 1.4.11 is
|
|
560
|
+
// Level AA. Downgrading them would drop a client-owned fork below the real
|
|
561
|
+
// standard while claiming only to relax a BADS house preference — the same
|
|
562
|
+
// reason `--aa` itself is exempt from this block.
|
|
563
|
+
let clientDowngraded = 0;
|
|
564
|
+
if (DOWNGRADE_AAA) {
|
|
565
|
+
for (const r of all) {
|
|
566
|
+
if (r.status === 'fail' && r.kind !== 'non-text') {
|
|
567
|
+
r.status = 'warn';
|
|
568
|
+
r.clientOwned = true;
|
|
569
|
+
clientDowngraded++;
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
483
574
|
if (json) {
|
|
484
575
|
console.log(JSON.stringify({
|
|
485
576
|
floor: { normal: NORMAL_FLOOR, large: LARGE_FLOOR },
|
|
577
|
+
clientOwned: CLIENT_OWNED,
|
|
486
578
|
results: all,
|
|
487
579
|
runtimeMutated: brandResults,
|
|
488
580
|
staleExceptions,
|
|
@@ -497,6 +589,21 @@ if (json) {
|
|
|
497
589
|
for (const mode of ['light', 'dark']) {
|
|
498
590
|
console.log(`▸ ${mode}`);
|
|
499
591
|
for (const r of all.filter((x) => x.mode === mode)) {
|
|
592
|
+
// A skipped row never computed ratio/fgHex/bgHex — printing it through
|
|
593
|
+
// the normal line format below would render literal "undefined"s, which
|
|
594
|
+
// reads as broken output rather than as the diagnostic it should be.
|
|
595
|
+
// This was the second half of the {token.reference} bug: even the ONE
|
|
596
|
+
// loop that did push a `skipped` row (PAIRS) rendered it as garbage, so
|
|
597
|
+
// the tally at the bottom was the only intact signal — found 2026-09-15.
|
|
598
|
+
if (r.status === 'skipped') {
|
|
599
|
+
const kind = r.kind === 'non-text' ? ' [non-text]' : '';
|
|
600
|
+
const why = r.reason === 'missing-token'
|
|
601
|
+
? `token "${r.fgKey}" or "${r.bgKey}" not found in this mode`
|
|
602
|
+
: `"${r.fgKey}" or "${r.bgKey}" has a value this script can't resolve to a color ` +
|
|
603
|
+
`(check for a {dotted.path} alias pointing at a missing token, or an unsupported value shape)`;
|
|
604
|
+
console.log(` · ${r.label.padEnd(34)} skipped — ${why}${kind}`);
|
|
605
|
+
continue;
|
|
606
|
+
}
|
|
500
607
|
const mark =
|
|
501
608
|
r.status === 'pass' ? '✓' :
|
|
502
609
|
r.status === 'exception' ? '!' :
|
|
@@ -504,9 +611,10 @@ if (json) {
|
|
|
504
611
|
r.status === 'warn' ? '!' : '·';
|
|
505
612
|
const kind = r.kind === 'non-text' ? ' [non-text]' : '';
|
|
506
613
|
const brandNote = r.brand && r.status !== 'pass' ? ' (brand)' : '';
|
|
614
|
+
const clientNote = r.clientOwned ? ` (${CLIENT_OWNED_NOTE})` : '';
|
|
507
615
|
console.log(
|
|
508
616
|
` ${mark} ${r.label.padEnd(34)} ${String(r.ratio).padStart(5)}:1 ` +
|
|
509
|
-
`${r.fgKey} ${r.fgHex} on ${r.bgKey} ${r.bgHex}${kind}${brandNote}`
|
|
617
|
+
`${r.fgKey} ${r.fgHex} on ${r.bgKey} ${r.bgHex}${kind}${brandNote}${clientNote}`
|
|
510
618
|
);
|
|
511
619
|
}
|
|
512
620
|
console.log('');
|
|
@@ -547,5 +655,12 @@ if (json) {
|
|
|
547
655
|
` the same warning in-product (see CLAUDE.md → Accessibility Floor). Not blocking.`,
|
|
548
656
|
);
|
|
549
657
|
}
|
|
658
|
+
if (clientDowngraded) {
|
|
659
|
+
console.log(
|
|
660
|
+
`\n${clientDowngraded} pair${clientDowngraded === 1 ? '' : 's'} below the AAA floor ${clientDowngraded === 1 ? 'is' : 'are'} ` +
|
|
661
|
+
`${CLIENT_OWNED_NOTE} (sourceOfTruth.components === "client"). Your palette is being held to AA, ` +
|
|
662
|
+
`not AAA — see CLAUDE.md → Accessibility Floor. Not blocking.`,
|
|
663
|
+
);
|
|
664
|
+
}
|
|
550
665
|
if (failed.length) process.exit(1);
|
|
551
666
|
}
|
package/src/api/layers/file.ts
CHANGED
|
@@ -30,6 +30,8 @@ export default function OpengraphImage() {
|
|
|
30
30
|
return new ImageResponse(
|
|
31
31
|
(
|
|
32
32
|
<div
|
|
33
|
+
// allow-inline-style: Satori (next/og) can't resolve var(--token) —
|
|
34
|
+
// see the file-header note above. Literal colors are deliberate.
|
|
33
35
|
style={{
|
|
34
36
|
height: "100%",
|
|
35
37
|
width: "100%",
|
|
@@ -51,6 +53,7 @@ export default function OpengraphImage() {
|
|
|
51
53
|
background: accent,
|
|
52
54
|
}}
|
|
53
55
|
/>
|
|
56
|
+
{/* allow-inline-style: Satori rendering context, see the note above */}
|
|
54
57
|
<div
|
|
55
58
|
style={{
|
|
56
59
|
fontSize: "28px",
|
|
@@ -70,10 +73,12 @@ export default function OpengraphImage() {
|
|
|
70
73
|
gap: "28px",
|
|
71
74
|
}}
|
|
72
75
|
>
|
|
76
|
+
{/* allow-inline-style: Satori rendering context, see the note above */}
|
|
73
77
|
<div style={{ fontSize: "116px", lineHeight: 1, color: "#ffffff" }}>
|
|
74
78
|
{brand.name}
|
|
75
79
|
</div>
|
|
76
80
|
{description ? (
|
|
81
|
+
// allow-inline-style: Satori rendering context, see the note above
|
|
77
82
|
<div
|
|
78
83
|
style={{
|
|
79
84
|
fontSize: "40px",
|