@behavioral-agentic-design-system/core 0.28.0 → 0.29.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/package.json +2 -2
- package/scripts/a11y-lint.cjs +78 -9
- package/scripts/build-tokens.cjs +273 -15
- package/scripts/wcag-audit.cjs +37 -7
- package/src/api/layers/file.ts +1 -0
- package/src/app/font-ready.tsx +6 -5
- package/src/app/layout.tsx +54 -3
- package/src/app/preview/components/page.tsx +5532 -3044
- package/src/app/preview/layout.tsx +4 -1
- package/src/app/preview/showcase-filter.tsx +66 -0
- package/src/app/preview/tab-replay.tsx +63 -0
- package/src/app/shell.tsx +74 -18
- package/src/components/customize/save-bar.tsx +19 -6
- package/src/components/docs-tab.tsx +36 -24
- package/src/components/layers-tab.tsx +37 -5
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/close-button.tsx +71 -0
- package/src/components/ui/combobox.tsx +62 -3
- package/src/components/ui/container.tsx +65 -0
- package/src/components/ui/date-field.tsx +368 -0
- package/src/components/ui/drawer.tsx +334 -0
- package/src/components/ui/file-button.tsx +145 -0
- package/src/components/ui/floating-indicator.tsx +217 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +21 -0
- package/src/components/ui/input.tsx +38 -3
- package/src/components/ui/keyboard-shortcut.tsx +146 -0
- package/src/components/ui/loading-dots.tsx +99 -0
- package/src/components/ui/month-picker.tsx +296 -0
- package/src/components/ui/multi-select.tsx +15 -13
- package/src/components/ui/nav-link.tsx +200 -0
- package/src/components/ui/navigation-rail.tsx +256 -0
- package/src/components/ui/notification.tsx +20 -0
- package/src/components/ui/password-input.tsx +34 -1
- package/src/components/ui/progress.tsx +15 -1
- package/src/components/ui/prose.tsx +62 -0
- package/src/components/ui/result.tsx +151 -0
- package/src/components/ui/rolling-number.tsx +1 -0
- package/src/components/ui/simple-grid.tsx +110 -0
- package/src/components/ui/skeleton.tsx +52 -3
- package/src/components/ui/squircle.tsx +274 -0
- package/src/components/ui/stack.tsx +105 -0
- package/src/components/ui/status-badge.tsx +93 -0
- package/src/components/ui/tabs.tsx +34 -7
- package/src/components/ui/tag.tsx +46 -5
- package/src/components/ui/theme-icon.tsx +138 -0
- package/src/components/ui/timeline.tsx +27 -10
- package/src/components/ui/tooltip.tsx +12 -1
- package/src/components/ui/tree-select.tsx +386 -0
- package/src/components/ui/year-picker.tsx +307 -0
- package/src/data/docs-index.ts +10 -0
- package/src/hooks/use-global-primary-color.ts +57 -6
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/CloseButton.stories.tsx +65 -0
- package/src/stories/Combobox.stories.tsx +74 -3
- package/src/stories/Container.stories.tsx +134 -0
- package/src/stories/DateField.stories.tsx +114 -0
- package/src/stories/Drawer.stories.tsx +211 -0
- package/src/stories/FileButton.stories.tsx +117 -0
- package/src/stories/FloatingIndicator.stories.tsx +343 -0
- package/src/stories/FormatByte.stories.tsx +142 -0
- package/src/stories/Input.stories.tsx +91 -0
- package/src/stories/KeyboardShortcut.stories.tsx +87 -0
- package/src/stories/LoadingDots.stories.tsx +73 -0
- package/src/stories/MonthPicker.stories.tsx +99 -0
- package/src/stories/MultiSelect.stories.tsx +3 -1
- package/src/stories/NavLink.stories.tsx +213 -0
- package/src/stories/NavigationRail.stories.tsx +413 -0
- package/src/stories/Notification.stories.tsx +53 -0
- package/src/stories/PasswordInput.stories.tsx +21 -0
- package/src/stories/Progress.stories.tsx +38 -0
- package/src/stories/Prose.stories.tsx +232 -0
- package/src/stories/Result.stories.tsx +145 -0
- package/src/stories/RollingNumber.stories.tsx +1 -1
- package/src/stories/SimpleGrid.stories.tsx +130 -0
- package/src/stories/Skeleton.stories.tsx +62 -1
- package/src/stories/Squircle.stories.tsx +127 -0
- package/src/stories/Stack.stories.tsx +139 -0
- package/src/stories/StatusBadge.stories.tsx +125 -0
- package/src/stories/Tabs.stories.tsx +56 -1
- package/src/stories/Tag.stories.tsx +31 -0
- package/src/stories/ThemeIcon.stories.tsx +97 -0
- package/src/stories/Timeline.stories.tsx +69 -0
- package/src/stories/Tooltip.stories.tsx +18 -0
- package/src/stories/TreeSelect.stories.tsx +222 -0
- package/src/stories/YearPicker.stories.tsx +100 -0
- package/src/styles.css +289 -15
- package/src/tokens.json +96 -1
- package/LICENSE +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
},
|
|
107
107
|
"dependencies": {
|
|
108
108
|
"@radix-ui/react-alert-dialog": "^1.1.23",
|
|
109
|
-
"@xmldom/xmldom": "^0.9.
|
|
109
|
+
"@xmldom/xmldom": "^0.9.11",
|
|
110
110
|
"cheerio": "^1.0.0",
|
|
111
111
|
"class-variance-authority": "^0.7.0",
|
|
112
112
|
"clsx": "^2.1.0",
|
package/scripts/a11y-lint.cjs
CHANGED
|
@@ -75,11 +75,67 @@ const INLINE_PX_FONT = /fontSize:\s*['"]\d+px['"]/;
|
|
|
75
75
|
const ARBITRARY_TEXT_PX = /text-\[(\d+)px\]/g;
|
|
76
76
|
const FOCUS_OUTLINE_NONE = /(?:focus(?:-visible)?:)?outline-none(?!\s*[\w-]*(focus-visible:|ring-|outline-)|.*ring-)/;
|
|
77
77
|
const ANIMATE_NO_MOTION_SAFE = /(?<!motion-safe:)\banimate-(?:bounce|ping|pulse|spin|in|out)\b/;
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
78
|
+
// The named type scale, resolved to px — per scope.
|
|
79
|
+
//
|
|
80
|
+
// Which px a named step means is not a constant, and not even a per-repo constant: text-xs is
|
|
81
|
+
// 14px under BADS' own scale and 12px under a consuming fork's, and a fork may render both, with
|
|
82
|
+
// a fork's geometry scoped to a class rather than applied globally. Hardcoding one scale makes this
|
|
83
|
+
// lint wrong for the other half — and wrong in the silent direction, passing sub-floor text while
|
|
84
|
+
// advising authors to "use text-xs (14px)".
|
|
85
|
+
//
|
|
86
|
+
// scripts/gen-ff-theme.mjs writes .type-scale.json from the geometry it generates, including the
|
|
87
|
+
// paths that scale applies to. With no such file we use BADS' scale everywhere, so upstream
|
|
88
|
+
// behaviour is unchanged.
|
|
89
|
+
const DEFAULT_TYPE_SCALE = { 'text-xs': 14, 'text-sm': 16, 'text-base': 18, 'text-lg': 20 };
|
|
90
|
+
const TEXT_FLOOR_PX = 14;
|
|
91
|
+
const WEIGHT_FLOOR_PX = 18;
|
|
92
|
+
|
|
93
|
+
let SCOPED_SCALES = [];
|
|
94
|
+
try {
|
|
95
|
+
const parsed = JSON.parse(fs.readFileSync(path.join(ROOT, '.type-scale.json'), 'utf8'));
|
|
96
|
+
SCOPED_SCALES = (parsed.scopes || []).map((s) => ({
|
|
97
|
+
paths: s.paths || [],
|
|
98
|
+
label: s.label || 'scoped',
|
|
99
|
+
scale: { ...DEFAULT_TYPE_SCALE, ...s.scale },
|
|
100
|
+
}));
|
|
101
|
+
} catch { /* no generated scale in this repo — the default stands everywhere */ }
|
|
102
|
+
|
|
103
|
+
/** Compile the floor checks for one scale. Cached, since most files share a scale. */
|
|
104
|
+
const compileScale = (() => {
|
|
105
|
+
const cache = new Map();
|
|
106
|
+
return (scale, label) => {
|
|
107
|
+
const key = label + JSON.stringify(scale);
|
|
108
|
+
if (cache.has(key)) return cache.get(key);
|
|
109
|
+
const belowFloor = Object.keys(scale).filter((k) => scale[k] < TEXT_FLOOR_PX);
|
|
110
|
+
const belowWeightFloor = Object.keys(scale).filter((k) => scale[k] < WEIGHT_FLOOR_PX);
|
|
111
|
+
const lightWeights = 'font-normal|font-light|font-thin|font-extralight';
|
|
112
|
+
const smallSteps = belowWeightFloor.join('|');
|
|
113
|
+
const compiled = {
|
|
114
|
+
scale,
|
|
115
|
+
label,
|
|
116
|
+
namedBelowFloor: belowFloor.length ? new RegExp(`\\b(${belowFloor.join('|')})\\b`) : null,
|
|
117
|
+
smallTextLightWeight: smallSteps
|
|
118
|
+
? new RegExp(`\\b(${smallSteps})\\b.+\\b(${lightWeights})\\b|\\b(${lightWeights})\\b.+\\b(${smallSteps})\\b`)
|
|
119
|
+
: null,
|
|
120
|
+
smallStepsDesc: belowWeightFloor.map((k) => `${k}=${scale[k]}px`).join(', '),
|
|
121
|
+
smallestCompliant: Object.keys(scale)
|
|
122
|
+
.filter((k) => scale[k] >= TEXT_FLOOR_PX)
|
|
123
|
+
.sort((a, b) => scale[a] - scale[b])[0] || 'a larger step',
|
|
124
|
+
};
|
|
125
|
+
cache.set(key, compiled);
|
|
126
|
+
return compiled;
|
|
127
|
+
};
|
|
128
|
+
})();
|
|
129
|
+
|
|
130
|
+
const DEFAULT_COMPILED = compileScale(DEFAULT_TYPE_SCALE, 'default');
|
|
131
|
+
|
|
132
|
+
function scaleFor(file) {
|
|
133
|
+
const rel = path.relative(ROOT, file).split(path.sep).join('/');
|
|
134
|
+
for (const s of SCOPED_SCALES) {
|
|
135
|
+
if (s.paths.some((p) => rel.startsWith(p))) return compileScale(s.scale, s.label);
|
|
136
|
+
}
|
|
137
|
+
return DEFAULT_COMPILED;
|
|
138
|
+
}
|
|
83
139
|
|
|
84
140
|
const HEADING_REGEX = /<(h[1-6])([^>]*)>([^<]*)/g;
|
|
85
141
|
const IMG_REGEX = /<(?:img|Image|AvatarImage)\b([^>]*)\/?>/;
|
|
@@ -100,6 +156,8 @@ for (const file of files) {
|
|
|
100
156
|
// Skip story files except for headline checks (they're fine to be terse).
|
|
101
157
|
const isStory = file.endsWith('.stories.tsx');
|
|
102
158
|
|
|
159
|
+
const TS = scaleFor(file);
|
|
160
|
+
|
|
103
161
|
const lines = src.split('\n');
|
|
104
162
|
for (let i = 0; i < lines.length; i++) {
|
|
105
163
|
const line = lines[i];
|
|
@@ -119,18 +177,29 @@ for (const file of files) {
|
|
|
119
177
|
ARBITRARY_TEXT_PX.lastIndex = 0;
|
|
120
178
|
while ((match = ARBITRARY_TEXT_PX.exec(line))) {
|
|
121
179
|
const px = parseInt(match[1], 10);
|
|
122
|
-
if (px <
|
|
180
|
+
if (px < TEXT_FLOOR_PX) {
|
|
123
181
|
flag(file, lineNum, '1.4.4', 'tiny-text',
|
|
124
|
-
`text-[${px}px] is below the
|
|
182
|
+
`text-[${px}px] is below the ${TEXT_FLOOR_PX}px AAA accessibility floor. Use ${TS.smallestCompliant} or larger.`);
|
|
125
183
|
}
|
|
126
184
|
}
|
|
127
185
|
|
|
186
|
+
// Named steps that resolve below the floor in THIS repo's scale. Escape hatch matches the
|
|
187
|
+
// weight-floor one: some vendored components legitimately ship a smaller step, and that
|
|
188
|
+
// belongs in an upstream finding rather than a local edit.
|
|
189
|
+
if (TS.namedBelowFloor && TS.namedBelowFloor.test(line)
|
|
190
|
+
&& !/\/\/\s*allow-small-text/.test(line)
|
|
191
|
+
&& !(i > 0 && /allow-small-text/.test(lines[i - 1]))) {
|
|
192
|
+
const step = TS.namedBelowFloor.exec(line)[1];
|
|
193
|
+
flag(file, lineNum, '1.4.4', 'tiny-text',
|
|
194
|
+
`${step} resolves to ${TS.scale[step]}px under ${TS.label}, below the ${TEXT_FLOOR_PX}px AAA floor. Use ${TS.smallestCompliant} or larger, or add "// allow-small-text" above if a vendored component forces it.`);
|
|
195
|
+
}
|
|
196
|
+
|
|
128
197
|
// SADS-1 — small text (text-xs/text-sm, <18px) must be font-medium (500) or heavier.
|
|
129
|
-
if (
|
|
198
|
+
if (TS.smallTextLightWeight && TS.smallTextLightWeight.test(line)
|
|
130
199
|
&& !/\/\/\s*allow-font-normal-small/.test(line)
|
|
131
200
|
&& !(i > 0 && /allow-font-normal-small/.test(lines[i - 1]))) {
|
|
132
201
|
flag(file, lineNum, 'SADS-1', 'small-text-light-weight',
|
|
133
|
-
|
|
202
|
+
`font-normal (or lighter) on a step below ${WEIGHT_FLOOR_PX}px (${TS.smallStepsDesc}). SADS weight floor: font-medium (500) minimum. Add "// allow-font-normal-small" above to intentionally bypass.`);
|
|
134
203
|
}
|
|
135
204
|
|
|
136
205
|
if (FOCUS_OUTLINE_NONE.test(line) && !/ring-|outline-|focus-visible:/.test(line)) {
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -91,6 +91,7 @@ const fontSerif = tokens.fontFamily.serif.$value;
|
|
|
91
91
|
// Variable ships as the default). Forks tune type here without code change.
|
|
92
92
|
const fontVariationSettings = tokens.fontVariationSettings?.$value ?? 'normal';
|
|
93
93
|
const radius = tokens.borderRadius?.lg?.$value ?? '0.625rem';
|
|
94
|
+
const cornerSmoothing = tokens.cornerSmoothing?.$value ?? 0.6;
|
|
94
95
|
const spacing = tokens.theme?.light?.spacing?.$value ?? '0.25rem';
|
|
95
96
|
|
|
96
97
|
// Animation token layer. Components use `transition-[var(--duration-base)]`
|
|
@@ -291,6 +292,18 @@ const themeInline = `@theme inline {
|
|
|
291
292
|
--color-accent-foreground: var(--accent-foreground);
|
|
292
293
|
--color-destructive: var(--destructive);
|
|
293
294
|
--color-destructive-foreground: var(--destructive-foreground);
|
|
295
|
+
--color-success: var(--success);
|
|
296
|
+
--color-warning: var(--warning);
|
|
297
|
+
--color-info: var(--info);
|
|
298
|
+
--color-icon-default: var(--icon-default);
|
|
299
|
+
--color-icon-muted: var(--icon-muted);
|
|
300
|
+
--color-icon-primary: var(--icon-primary);
|
|
301
|
+
--color-icon-success: var(--icon-success);
|
|
302
|
+
--color-icon-warning: var(--icon-warning);
|
|
303
|
+
--color-icon-error: var(--icon-error);
|
|
304
|
+
--color-icon-info: var(--icon-info);
|
|
305
|
+
--color-icon-inverse: var(--icon-inverse);
|
|
306
|
+
--color-icon-disabled: var(--icon-disabled);
|
|
294
307
|
--color-border: var(--border);
|
|
295
308
|
--color-input: var(--input);
|
|
296
309
|
--color-ring: var(--ring);
|
|
@@ -390,13 +403,18 @@ const themeInline = `@theme inline {
|
|
|
390
403
|
|
|
391
404
|
/* Tracking — every Tailwind tracking-* utility folds in the runtime
|
|
392
405
|
--tracking-offset offset, so the Customize tab slider moves the
|
|
393
|
-
entire app (headlines included), not just unstyled text.
|
|
406
|
+
entire app (headlines included), not just unstyled text.
|
|
407
|
+
Semantic aliases: --tracking-display for hero/display text (4xl–8xl),
|
|
408
|
+
--tracking-heading for section-head text (xl–3xl). Forks use these
|
|
409
|
+
instead of hardcoding em values. */
|
|
394
410
|
--tracking-tighter: calc(-0.05em + var(--tracking-offset, 0em));
|
|
395
411
|
--tracking-tight: calc(-0.025em + var(--tracking-offset, 0em));
|
|
396
412
|
--tracking-normal: var(--tracking-offset, 0em);
|
|
397
413
|
--tracking-wide: calc(0.025em + var(--tracking-offset, 0em));
|
|
398
414
|
--tracking-wider: calc(0.05em + var(--tracking-offset, 0em));
|
|
399
415
|
--tracking-widest: calc(0.1em + var(--tracking-offset, 0em));
|
|
416
|
+
--tracking-display: calc(-0.022em + var(--tracking-offset, 0em));
|
|
417
|
+
--tracking-heading: calc(-0.01em + var(--tracking-offset, 0em));
|
|
400
418
|
}`;
|
|
401
419
|
|
|
402
420
|
const baseLayer = `@layer base {
|
|
@@ -622,16 +640,25 @@ html, body {
|
|
|
622
640
|
}
|
|
623
641
|
|
|
624
642
|
/* Theme toggle: iris reveal via View Transitions API. The click coords are
|
|
625
|
-
written to --x / --y on <html> before startViewTransition fires
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
643
|
+
written to --x / --y on <html> before startViewTransition fires, and the
|
|
644
|
+
trigger also writes --r: the exact click-to-farthest-corner distance times
|
|
645
|
+
a small buffer (see shell.tsx toggleDark).
|
|
646
|
+
|
|
647
|
+
Three deliberate choices, all learned the hard way (a client fork 2026-06;
|
|
648
|
+
ultrawide end-of-wipe pop 2026-08):
|
|
649
|
+
1. Radius is JS-computed per click (--r), with a 150vmax FALLBACK — never a
|
|
650
|
+
percentage. Two failure modes bracketed here:
|
|
651
|
+
- circle(150%) resolves against the snapshot box, so on a large/wide
|
|
652
|
+
desktop the wipe can finish before covering the viewport — a glitch at
|
|
653
|
+
the END of the animation that only shows on big displays.
|
|
654
|
+
- A blanket viewport unit (the old 150vmax) always covers, but on wide
|
|
655
|
+
screens it overshoots the needed radius by ~40%, so the eased timeline
|
|
656
|
+
spends its whole tail growing an invisible circle: the last visible
|
|
657
|
+
sweep (the far side of the screen) compresses into ~2 frames and reads
|
|
658
|
+
as a pop/glitch. The exact --r makes the visual sweep own the full
|
|
659
|
+
duration, so the deceleration tail lands where the eye is looking.
|
|
660
|
+
150vmax stays as the no-JS fallback and keeps old forks' behavior. Both
|
|
661
|
+
values are box-independent, so if a fork names sticky chrome as its own
|
|
635
662
|
view-transition group the radius matches the root exactly (no seam).
|
|
636
663
|
2. PURE clip-path reveal, no opacity fade. A 0.7->1 opacity blend makes the
|
|
637
664
|
growing edge translucent, showing the old theme through the new — which
|
|
@@ -656,10 +683,33 @@ html, body {
|
|
|
656
683
|
clip-path: circle(0 at var(--x, 50%) var(--y, 50%));
|
|
657
684
|
}
|
|
658
685
|
to {
|
|
659
|
-
clip-path: circle(150vmax at var(--x, 50%) var(--y, 50%));
|
|
686
|
+
clip-path: circle(var(--r, 150vmax) at var(--x, 50%) var(--y, 50%));
|
|
660
687
|
}
|
|
661
688
|
}
|
|
662
689
|
|
|
690
|
+
/* Tail-guard against the 1-frame old-theme flash at the end of the wipe.
|
|
691
|
+
Measured on prod builds at 3440x1440 (2026-08-19, frame-by-frame video):
|
|
692
|
+
right at the animation boundary the compositor occasionally renders one
|
|
693
|
+
frame where the NEW snapshot misses and the opaque OLD snapshot (z-index 0)
|
|
694
|
+
shows through — an old-theme flash over the just-revealed far side of the
|
|
695
|
+
screen. Direction-agnostic; only conspicuous against the opposite theme.
|
|
696
|
+
Two-part guard, both invisible in correct rendering:
|
|
697
|
+
1. theme-old-out drops the old snapshot to opacity 0 over the final 8% of
|
|
698
|
+
the timeline. The circle fully covers the viewport by ~t=0.91 (the --r
|
|
699
|
+
x1.03 buffer, see shell.tsx), so the old layer is already occluded when
|
|
700
|
+
it fades — this is NOT the forbidden opacity cross-fade (that objection
|
|
701
|
+
is about fading DURING the sweep, which smears the edge grey).
|
|
702
|
+
2. The ::view-transition canvas (beneath both snapshots) paints with the
|
|
703
|
+
live NEW-theme --background, so a frame where BOTH snapshots miss shows
|
|
704
|
+
the new background color instead of the UA canvas. */
|
|
705
|
+
::view-transition {
|
|
706
|
+
background-color: var(--background);
|
|
707
|
+
}
|
|
708
|
+
@keyframes theme-old-out {
|
|
709
|
+
0%, 92% { opacity: 1; }
|
|
710
|
+
98%, 100% { opacity: 0; }
|
|
711
|
+
}
|
|
712
|
+
|
|
663
713
|
/* Accordion disclosure keyframes — used by Radix-based AccordionContent.
|
|
664
714
|
Radix injects the actual content height as \`--radix-accordion-content-height\`
|
|
665
715
|
at runtime, which these keyframes interpolate against. Duration + timing
|
|
@@ -737,17 +787,221 @@ html, body {
|
|
|
737
787
|
30% { transform: translateY(-4px); opacity: 1; }
|
|
738
788
|
}
|
|
739
789
|
|
|
790
|
+
/* Skeleton wave shimmer — left-to-right highlight sweep, the alternative to
|
|
791
|
+
the default opacity pulse (Skeleton's \`animation="wave"\`). Same pattern-(b)
|
|
792
|
+
delivery as accordion/marquee: plain CSS keyed off data-slot +
|
|
793
|
+
data-animation, no Tailwind utility generation in the path. The attribute
|
|
794
|
+
lands on the bg-carrying elements only (single skeleton div, or each
|
|
795
|
+
skeleton-line in a multi-line text stack) — never the transparent wrapper,
|
|
796
|
+
so the gradient can't paint on a bg-less container.
|
|
797
|
+
- Highlight mixes 8% foreground into the accent base via color-mix, so it
|
|
798
|
+
tracks light/dark and fork brand tokens with no hardcoded colors.
|
|
799
|
+
- "linear" timing: the sweep is an ambient loop; easing would make it
|
|
800
|
+
lurch (same seamless-loop reasoning as marquee-scroll above).
|
|
801
|
+
- --skeleton-wave-duration is the consumer tunable (default 2s). The
|
|
802
|
+
duration.* tokens top out at 300ms — interaction-scale, not
|
|
803
|
+
ambient-loop-scale — same reasoning as --marquee-duration.
|
|
804
|
+
- Reduced motion: the base layer forces animation-duration to 0.01ms with
|
|
805
|
+
iteration-count 1, so the wave collapses to a static block. */
|
|
806
|
+
@keyframes skeleton-wave {
|
|
807
|
+
from { background-position: 200% 0; }
|
|
808
|
+
to { background-position: -200% 0; }
|
|
809
|
+
}
|
|
810
|
+
[data-slot="skeleton"][data-animation="wave"],
|
|
811
|
+
[data-slot="skeleton-line"][data-animation="wave"] {
|
|
812
|
+
background-image: linear-gradient(
|
|
813
|
+
90deg,
|
|
814
|
+
var(--accent) 25%,
|
|
815
|
+
color-mix(in oklab, var(--accent), var(--foreground) 8%) 50%,
|
|
816
|
+
var(--accent) 75%
|
|
817
|
+
);
|
|
818
|
+
background-size: 200% 100%;
|
|
819
|
+
animation: skeleton-wave var(--skeleton-wave-duration, 2s) linear infinite;
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
/* Prose — long-form typographic rhythm for arbitrary HTML descendants
|
|
823
|
+
(MDX output, CMS articles, rendered markdown). Keyed off the .prose
|
|
824
|
+
class the Prose primitive (data-slot="prose") applies — same
|
|
825
|
+
design-system-CSS delivery as the accordion/marquee blocks above.
|
|
826
|
+
Deliberately OUTSIDE @layer base so these rules beat the base layer's
|
|
827
|
+
element defaults (p margins, etc.) without specificity games, while any
|
|
828
|
+
consumer utility class on a descendant still wins per the cascade.
|
|
829
|
+
|
|
830
|
+
Type sizes can't use var(--text-*): those live in @theme inline, which
|
|
831
|
+
inlines values into utilities WITHOUT emitting :root custom properties —
|
|
832
|
+
a plain-CSS var() lookup would go invalid at computed-value time and
|
|
833
|
+
silently inherit. Instead each font-size repeats the theme's exact
|
|
834
|
+
calc( var(--text-*-size, <token>) * var(--font-size-scale, 1) ) form,
|
|
835
|
+
interpolated from tokens.json here, so the Customize-tab type-scale
|
|
836
|
+
slider moves prose content too and tokens stay the single source.
|
|
837
|
+
|
|
838
|
+
Block rhythm is em-based (matching the base layer's 1.5em paragraph
|
|
839
|
+
rule) so SC 1.4.8 paragraph spacing holds at every font scale; fixed
|
|
840
|
+
spacing uses the --spacing token. Colors/borders/radii/motion resolve
|
|
841
|
+
through :root tokens. Heading scale mirrors the Heading primitive:
|
|
842
|
+
h1 = heading-lg (text-2xl 700), h2 = heading-md (text-xl 700),
|
|
843
|
+
h3 = heading-sm (text-lg 500). Don't nest app UI (buttons, forms)
|
|
844
|
+
inside a Prose region — see the registry antiPatterns. */
|
|
845
|
+
.prose {
|
|
846
|
+
color: var(--foreground);
|
|
847
|
+
font-size: calc(var(--text-base-size, ${textBase}) * var(--font-size-scale, 1));
|
|
848
|
+
line-height: 1.75;
|
|
849
|
+
min-width: 0;
|
|
850
|
+
overflow-wrap: break-word;
|
|
851
|
+
}
|
|
852
|
+
/* Zero p margins inside prose so the owl below owns ALL rhythm — this
|
|
853
|
+
neutralizes both the base layer's p:not(:last-child) margin and its
|
|
854
|
+
flex/grid carve-out, which otherwise make prose spacing depend on
|
|
855
|
+
whether an ancestor happens to be a flex container. :where() keeps
|
|
856
|
+
this at specificity 0,1,0 so the owl (also 0,1,0, later in source)
|
|
857
|
+
wins margin-block-start on following-sibling paragraphs. */
|
|
858
|
+
.prose :where(p) {
|
|
859
|
+
margin-block: 0;
|
|
860
|
+
}
|
|
861
|
+
/* Lobotomized-owl rhythm: space between sibling blocks, never above the
|
|
862
|
+
first. 1.5em keeps SC 1.4.8 paragraph spacing at every font scale. */
|
|
863
|
+
.prose > * + * {
|
|
864
|
+
margin-block-start: 1.5em;
|
|
865
|
+
}
|
|
866
|
+
/* Headings get extra air above when they follow content; the content a
|
|
867
|
+
heading introduces sits close beneath it. */
|
|
868
|
+
.prose > * + :is(h1, h2, h3, h4) {
|
|
869
|
+
margin-block-start: 2em;
|
|
870
|
+
}
|
|
871
|
+
.prose > :is(h1, h2, h3, h4) + * {
|
|
872
|
+
margin-block-start: calc(var(--spacing) * 3);
|
|
873
|
+
}
|
|
874
|
+
.prose h1 {
|
|
875
|
+
font-size: calc(var(--text-2xl-size, ${text2xl}) * var(--font-size-scale, 1));
|
|
876
|
+
font-weight: 700;
|
|
877
|
+
line-height: 1.375;
|
|
878
|
+
}
|
|
879
|
+
.prose h2 {
|
|
880
|
+
font-size: calc(var(--text-xl-size, ${textXl}) * var(--font-size-scale, 1));
|
|
881
|
+
font-weight: 700;
|
|
882
|
+
line-height: 1.375;
|
|
883
|
+
}
|
|
884
|
+
.prose h3 {
|
|
885
|
+
font-size: calc(var(--text-lg-size, ${textLg}) * var(--font-size-scale, 1));
|
|
886
|
+
font-weight: 500;
|
|
887
|
+
line-height: 1.5;
|
|
888
|
+
}
|
|
889
|
+
.prose h4 {
|
|
890
|
+
font-size: calc(var(--text-base-size, ${textBase}) * var(--font-size-scale, 1));
|
|
891
|
+
font-weight: 700;
|
|
892
|
+
line-height: 1.5;
|
|
893
|
+
}
|
|
894
|
+
/* Inner spacing for multi-paragraph list items / quotes (not direct
|
|
895
|
+
children of .prose, so the owl can't reach them). */
|
|
896
|
+
.prose :is(li, blockquote) > p + p {
|
|
897
|
+
margin-block-start: 1em;
|
|
898
|
+
}
|
|
899
|
+
.prose ul {
|
|
900
|
+
list-style-type: disc;
|
|
901
|
+
padding-inline-start: calc(var(--spacing) * 6);
|
|
902
|
+
}
|
|
903
|
+
.prose ol {
|
|
904
|
+
list-style-type: decimal;
|
|
905
|
+
padding-inline-start: calc(var(--spacing) * 6);
|
|
906
|
+
}
|
|
907
|
+
.prose li {
|
|
908
|
+
margin-block-start: calc(var(--spacing) * 2);
|
|
909
|
+
}
|
|
910
|
+
.prose li::marker {
|
|
911
|
+
color: var(--muted-foreground);
|
|
912
|
+
}
|
|
913
|
+
/* Mirrors the Blockquote primitive's default variant (border-l-2
|
|
914
|
+
border-border pl-4) so hand-authored quotes and markdown quotes match. */
|
|
915
|
+
.prose blockquote {
|
|
916
|
+
border-inline-start: 2px solid var(--border);
|
|
917
|
+
padding-inline-start: calc(var(--spacing) * 4);
|
|
918
|
+
color: var(--muted-foreground);
|
|
919
|
+
}
|
|
920
|
+
.prose code {
|
|
921
|
+
font-family: var(--font-mono);
|
|
922
|
+
font-size: 0.875em;
|
|
923
|
+
background-color: var(--muted);
|
|
924
|
+
border-radius: calc(var(--radius) - 4px);
|
|
925
|
+
padding: calc(var(--spacing) * 0.5) calc(var(--spacing) * 1.5);
|
|
926
|
+
}
|
|
927
|
+
.prose pre {
|
|
928
|
+
font-family: var(--font-mono);
|
|
929
|
+
font-size: calc(var(--text-sm-size, ${textSm}) * var(--font-size-scale, 1));
|
|
930
|
+
line-height: 1.7;
|
|
931
|
+
background-color: var(--muted);
|
|
932
|
+
border: 1px solid var(--border);
|
|
933
|
+
border-radius: calc(var(--radius) - 2px);
|
|
934
|
+
padding: calc(var(--spacing) * 4);
|
|
935
|
+
overflow-x: auto;
|
|
936
|
+
}
|
|
937
|
+
.prose pre code {
|
|
938
|
+
background-color: transparent;
|
|
939
|
+
border-radius: 0;
|
|
940
|
+
padding: 0;
|
|
941
|
+
font-size: inherit;
|
|
942
|
+
}
|
|
943
|
+
/* Links: --link is the wcag:audit-enforced AAA link color. Hover thickens
|
|
944
|
+
the underline on motion tokens (spec §4 pattern (b): design-system CSS,
|
|
945
|
+
no Tailwind utility generation in the path). Focus-visible stays on the
|
|
946
|
+
base layer's non-animated outline. */
|
|
947
|
+
.prose a {
|
|
948
|
+
color: var(--link);
|
|
949
|
+
font-weight: 500;
|
|
950
|
+
text-decoration-line: underline;
|
|
951
|
+
text-decoration-thickness: 1px;
|
|
952
|
+
text-underline-offset: 0.2em;
|
|
953
|
+
transition: text-decoration-thickness var(--duration-fast) var(--ease-out);
|
|
954
|
+
}
|
|
955
|
+
.prose a:hover {
|
|
956
|
+
text-decoration-thickness: 2px;
|
|
957
|
+
}
|
|
958
|
+
.prose hr {
|
|
959
|
+
border: 0;
|
|
960
|
+
border-top: 1px solid var(--border);
|
|
961
|
+
margin-block: 2em;
|
|
962
|
+
}
|
|
963
|
+
.prose table {
|
|
964
|
+
width: 100%;
|
|
965
|
+
border-collapse: collapse;
|
|
966
|
+
font-size: calc(var(--text-sm-size, ${textSm}) * var(--font-size-scale, 1));
|
|
967
|
+
line-height: 1.6;
|
|
968
|
+
}
|
|
969
|
+
.prose th {
|
|
970
|
+
text-align: start;
|
|
971
|
+
font-weight: 600;
|
|
972
|
+
border-bottom: 1px solid var(--border);
|
|
973
|
+
padding: calc(var(--spacing) * 2) calc(var(--spacing) * 3);
|
|
974
|
+
}
|
|
975
|
+
.prose td {
|
|
976
|
+
border-bottom: 1px solid var(--border);
|
|
977
|
+
padding: calc(var(--spacing) * 2) calc(var(--spacing) * 3);
|
|
978
|
+
}
|
|
979
|
+
.prose img {
|
|
980
|
+
max-width: 100%;
|
|
981
|
+
height: auto;
|
|
982
|
+
border-radius: calc(var(--radius) - 2px);
|
|
983
|
+
}
|
|
984
|
+
|
|
740
985
|
::view-transition-new(root) {
|
|
741
986
|
animation: theme-reveal 0.4s ease-in-out forwards;
|
|
742
987
|
}
|
|
988
|
+
/* Same duration/easing as theme-reveal so the 92%/98% offsets line up with
|
|
989
|
+
the reveal's coverage math. */
|
|
990
|
+
::view-transition-old(root) {
|
|
991
|
+
animation: theme-old-out 0.4s ease-in-out forwards;
|
|
992
|
+
}
|
|
743
993
|
|
|
744
994
|
/* Honor the app-level MotionToggle for the iris wipe too (same three-state
|
|
745
995
|
model as the global kill-all). "reduce" snaps the theme swap instantly;
|
|
746
996
|
"full" keeps the wipe even under an OS reduce preference; absent = OS
|
|
747
|
-
query governs. \`animation: none\` on the pseudo just does an instant swap.
|
|
748
|
-
|
|
997
|
+
query governs. \`animation: none\` on the pseudo just does an instant swap.
|
|
998
|
+
Old + new both reset — leaving theme-old-out running would turn the
|
|
999
|
+
instant swap into a 0.4s crossfade for reduced-motion users. */
|
|
1000
|
+
html[data-motion="reduce"]::view-transition-new(root),
|
|
1001
|
+
html[data-motion="reduce"]::view-transition-old(root) { animation: none; }
|
|
749
1002
|
@media (prefers-reduced-motion: reduce) {
|
|
750
|
-
html:not([data-motion="full"])::view-transition-new(root)
|
|
1003
|
+
html:not([data-motion="full"])::view-transition-new(root),
|
|
1004
|
+
html:not([data-motion="full"])::view-transition-old(root) { animation: none; }
|
|
751
1005
|
}`;
|
|
752
1006
|
|
|
753
1007
|
// ---- Border-color utilities (workaround for a TURBOPACK bug) --------------
|
|
@@ -852,6 +1106,8 @@ const pkgCss = `${banner}
|
|
|
852
1106
|
@custom-variant dark (&:is(.dark *));
|
|
853
1107
|
|
|
854
1108
|
:root {
|
|
1109
|
+
color-scheme: light dark;
|
|
1110
|
+
|
|
855
1111
|
/* Brand sans from tokens.json leads. Atkinson Hyperlegible (loaded via the
|
|
856
1112
|
Google Fonts @import above) is the canonical fallback so unbranded
|
|
857
1113
|
consumers still get a high-legibility face out of the box. */
|
|
@@ -864,6 +1120,7 @@ const pkgCss = `${banner}
|
|
|
864
1120
|
${lightVars}
|
|
865
1121
|
|
|
866
1122
|
--radius: ${radius};
|
|
1123
|
+
--corner-smoothing: ${cornerSmoothing};
|
|
867
1124
|
${shadowBlock}
|
|
868
1125
|
${motionBlock}
|
|
869
1126
|
${motionSemanticBlock}
|
|
@@ -941,6 +1198,7 @@ const appCss = `${banner}
|
|
|
941
1198
|
${lightVars}
|
|
942
1199
|
|
|
943
1200
|
--radius: ${radius};
|
|
1201
|
+
--corner-smoothing: ${cornerSmoothing};
|
|
944
1202
|
${shadowBlock}
|
|
945
1203
|
${motionBlock}
|
|
946
1204
|
${motionSemanticBlock}
|
package/scripts/wcag-audit.cjs
CHANGED
|
@@ -341,12 +341,26 @@ function simulateBrand(brand, modeName, modeTokens) {
|
|
|
341
341
|
return tok ? resolveValue(tok.$value, modeTokens) : null;
|
|
342
342
|
};
|
|
343
343
|
|
|
344
|
+
// applyColor no longer writes --primary unconditionally. In dark mode it first checks the brand
|
|
345
|
+
// colour against the live background and, if it fails, removes the override so the stylesheet's
|
|
346
|
+
// luminance-tuned dark value rides instead (see shouldWritePrimary in
|
|
347
|
+
// use-global-primary-color.ts). Mirror that here, or this section reports warnings for a write
|
|
348
|
+
// that never happens — 21 of them for a dark brand colour, which is exactly the kind of stale
|
|
349
|
+
// noise that teaches people to stop reading the audit.
|
|
350
|
+
const PRIMARY_DARK_FLOOR = 4.5;
|
|
351
|
+
const bgSurface = surface('background');
|
|
352
|
+
const writesPrimary =
|
|
353
|
+
modeName !== 'dark' || !bgSurface || contrast(primaryRgb, bgSurface) >= PRIMARY_DARK_FLOOR;
|
|
354
|
+
const effPrimary = writesPrimary ? primaryRgb : surface('primary');
|
|
355
|
+
const effForeground = writesPrimary ? foregroundRgb : surface('primary-foreground');
|
|
356
|
+
const declined = writesPrimary ? '' : ' (runtime declines the override; stylesheet dark value)';
|
|
357
|
+
|
|
344
358
|
const pairs = [
|
|
345
|
-
['primary-foreground', 'primary',
|
|
346
|
-
['primary', 'background',
|
|
347
|
-
['primary', 'card',
|
|
348
|
-
['ring', 'background',
|
|
349
|
-
['ring', 'card',
|
|
359
|
+
['primary-foreground', 'primary', `text on primary action${declined}`, effForeground, effPrimary, NORMAL_FLOOR, false],
|
|
360
|
+
['primary', 'background', `primary button on page${declined}`, effPrimary, bgSurface, NON_TEXT_FLOOR, true],
|
|
361
|
+
['primary', 'card', `primary button on card${declined}`, effPrimary, surface('card'), NON_TEXT_FLOOR, true],
|
|
362
|
+
['ring', 'background', `focus ring on page${declined}`, effPrimary, bgSurface, NON_TEXT_FLOOR, true],
|
|
363
|
+
['ring', 'card', `focus ring on card${declined}`, effPrimary, surface('card'), NON_TEXT_FLOOR, true],
|
|
350
364
|
// accent-foreground now picks the higher-contrast of primary / primaryForeground
|
|
351
365
|
// against --accent (see applyColor in use-global-primary-color.ts). Mirror
|
|
352
366
|
// that logic here so the audit reports what the runtime will actually do.
|
|
@@ -360,7 +374,7 @@ function simulateBrand(brand, modeName, modeTokens) {
|
|
|
360
374
|
if (!picked) return [['accent-foreground', 'accent', 'accent-foreground on accent (no AAA candidate — falls back to stylesheet)', null, accent, NORMAL_FLOOR, false]];
|
|
361
375
|
return [['accent-foreground', 'accent', `accent-foreground on accent (runtime picks ${picked.name})`, picked.rgb, accent, NORMAL_FLOOR, false]];
|
|
362
376
|
})(),
|
|
363
|
-
['sidebar-primary-foreground', 'sidebar-primary',
|
|
377
|
+
['sidebar-primary-foreground', 'sidebar-primary', `sidebar primary text${declined}`, effForeground, effPrimary, NORMAL_FLOOR, false],
|
|
364
378
|
];
|
|
365
379
|
|
|
366
380
|
return pairs.map(([fgKey, bgKey, label, fg, bg, floor, isNonText]) => {
|
|
@@ -395,6 +409,15 @@ if (json) {
|
|
|
395
409
|
runtimeMutated: brandResults,
|
|
396
410
|
}, null, 2));
|
|
397
411
|
} else {
|
|
412
|
+
// Documented exceptions live in tokens.json next to the tokens they concern, each with a
|
|
413
|
+
// required reason. A pair listed there is reported as an exception rather than failing the
|
|
414
|
+
// build — the point is that it stays visible, not that it disappears.
|
|
415
|
+
const exceptions = (tokens.wcagExceptions && tokens.wcagExceptions.pairs) || [];
|
|
416
|
+
const exceptionFor = (r) => exceptions.find((e) => e.fgKey === r.fgKey && e.bgKey === r.bgKey && e.reason);
|
|
417
|
+
for (const r of all) {
|
|
418
|
+
if (r.status === 'fail' && exceptionFor(r)) r.status = 'exception';
|
|
419
|
+
}
|
|
420
|
+
const excepted = all.filter((r) => r.status === 'exception');
|
|
398
421
|
const failed = all.filter((r) => r.status === 'fail');
|
|
399
422
|
const warned = all.filter((r) => r.status === 'warn');
|
|
400
423
|
const passed = all.filter((r) => r.status === 'pass');
|
|
@@ -405,6 +428,7 @@ if (json) {
|
|
|
405
428
|
for (const r of all.filter((x) => x.mode === mode)) {
|
|
406
429
|
const mark =
|
|
407
430
|
r.status === 'pass' ? '✓' :
|
|
431
|
+
r.status === 'exception' ? '!' :
|
|
408
432
|
r.status === 'fail' ? '✗' :
|
|
409
433
|
r.status === 'warn' ? '!' : '·';
|
|
410
434
|
const kind = r.kind === 'non-text' ? ' [non-text]' : '';
|
|
@@ -433,7 +457,13 @@ if (json) {
|
|
|
433
457
|
console.log('');
|
|
434
458
|
}
|
|
435
459
|
const brandWarnings = brandResults.filter((r) => r.status === 'warn').length;
|
|
436
|
-
console.log(`${passed.length} pass · ${failed.length} fail · ${warned.length + brandWarnings} warn · ${skipped.length} skipped`);
|
|
460
|
+
console.log(`${passed.length} pass · ${failed.length} fail · ${excepted.length} documented exception(s) · ${warned.length + brandWarnings} warn · ${skipped.length} skipped`);
|
|
461
|
+
if (excepted.length) {
|
|
462
|
+
console.log('\nDocumented exceptions (below the AAA floor, knowingly):');
|
|
463
|
+
for (const r of excepted) {
|
|
464
|
+
console.log(` ! ${r.label} — ${exceptionFor(r).reason}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
437
467
|
if (warned.length || brandWarnings) {
|
|
438
468
|
console.log(
|
|
439
469
|
`\nWarnings are brand-derived pairs below AAA. The brand picker surfaces` +
|
package/src/api/layers/file.ts
CHANGED
package/src/app/font-ready.tsx
CHANGED
|
@@ -11,11 +11,12 @@ import { useEffect } from "react";
|
|
|
11
11
|
* hydration, awaits `document.fonts.ready`, then swaps to `fonts-loaded` —
|
|
12
12
|
* CSS transitions the body back in over 200ms.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
14
|
+
* NOTE: this is now a BACKSTOP, not the primary release. An inline script in the <head> of
|
|
15
|
+
* RootLayout releases the gate during head parsing, with a 400ms cap. It has to live there:
|
|
16
|
+
* a useEffect cannot run until the React bundle has hydrated, so on a heavy route this component
|
|
17
|
+
* could not lift the gate — or apply its own timeout — until well after the page was otherwise
|
|
18
|
+
* ready to paint. Measured blank until ~1.4s on the Components tab while being fully laid out at
|
|
19
|
+
* ~700ms. Both paths call the same class swap and are idempotent, so whichever runs first wins.
|
|
19
20
|
*/
|
|
20
21
|
export function FontReady() {
|
|
21
22
|
useEffect(() => {
|