@behavioral-agentic-design-system/core 0.3.1 → 0.3.2
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/scripts/build-tokens.cjs +24 -7
- package/src/app/layout.tsx +12 -2
- package/src/hooks/use-reduced-motion.ts +19 -0
- package/src/styles.css +17 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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": "ISC",
|
|
6
6
|
"type": "module",
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -290,6 +290,19 @@ const baseLayer = `@layer base {
|
|
|
290
290
|
* {
|
|
291
291
|
@apply border-border outline-ring/50;
|
|
292
292
|
}
|
|
293
|
+
/* Bind html to --font-sans so the picker propagates everywhere — not just
|
|
294
|
+
elements that use the \`font-sans\` Tailwind utility. Tailwind v4's preflight
|
|
295
|
+
binds html to --default-font-family, which is silently NOT --font-sans, so
|
|
296
|
+
iframe previews, plain-text components, and Home/Layers tabs would otherwise
|
|
297
|
+
fall through to system-ui regardless of the brand-font selection. */
|
|
298
|
+
html {
|
|
299
|
+
font-family: var(--font-sans);
|
|
300
|
+
}
|
|
301
|
+
/* Match: monospace elements pick up --font-mono without each component
|
|
302
|
+
having to remember a \`font-mono\` class. */
|
|
303
|
+
code, kbd, samp, pre {
|
|
304
|
+
font-family: var(--font-mono);
|
|
305
|
+
}
|
|
293
306
|
body {
|
|
294
307
|
@apply bg-background text-foreground;
|
|
295
308
|
-webkit-font-smoothing: antialiased;
|
|
@@ -404,7 +417,10 @@ const pkgCss = `${banner}
|
|
|
404
417
|
@custom-variant dark (&:is(.dark *));
|
|
405
418
|
|
|
406
419
|
:root {
|
|
407
|
-
|
|
420
|
+
/* Brand sans from tokens.json leads. Atkinson Hyperlegible (loaded via the
|
|
421
|
+
Google Fonts @import above) is the canonical fallback so unbranded
|
|
422
|
+
consumers still get a high-legibility face out of the box. */
|
|
423
|
+
--font-sans: ${fontSans}, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
|
|
408
424
|
--font-mono: ${fontMono};
|
|
409
425
|
--font-serif: ${fontSerif};
|
|
410
426
|
--font-size-scale: 1;
|
|
@@ -449,12 +465,13 @@ const appCss = `${banner}
|
|
|
449
465
|
@custom-variant dark (&:is(.dark *));
|
|
450
466
|
|
|
451
467
|
:root {
|
|
452
|
-
/*
|
|
453
|
-
*
|
|
454
|
-
*
|
|
455
|
-
|
|
456
|
-
--font-
|
|
457
|
-
--font-
|
|
468
|
+
/* Brand fonts from tokens.json lead so the picker selection actually
|
|
469
|
+
* shows up. next/font's preloaded vars come second as a self-hosted
|
|
470
|
+
* fallback for forks that haven't loaded their own woff2 yet — keeps
|
|
471
|
+
* the showcase styled even before fonts.css resolves. */
|
|
472
|
+
--font-sans: ${fontSans}, var(--font-atkinson), 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
|
|
473
|
+
--font-serif: ${fontSerif}, var(--font-source-serif), 'Source Serif 4', Georgia, ui-serif, serif;
|
|
474
|
+
--font-mono: ${fontMono}, var(--font-jetbrains), 'JetBrains Mono', ui-monospace, monospace;
|
|
458
475
|
--font-size-scale: 1;
|
|
459
476
|
|
|
460
477
|
${lightVars}
|
package/src/app/layout.tsx
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { Metadata } from "next";
|
|
2
2
|
import { Atkinson_Hyperlegible, Inter, JetBrains_Mono, Lora, Source_Serif_4 } from "next/font/google";
|
|
3
3
|
import "@/styles/globals.css";
|
|
4
|
+
import { brand } from "@/brand.config";
|
|
4
5
|
import Providers from "./providers";
|
|
5
6
|
import { FontReady } from "./font-ready";
|
|
6
7
|
|
|
8
|
+
// Brand fonts declared in the consumer's brand.config.ts get folded into the
|
|
9
|
+
// pre-hydration font map below. Without this, picking "season-sans" in the
|
|
10
|
+
// Customize tab writes "season-sans" to localStorage but the boot script's
|
|
11
|
+
// hardcoded SANS map misses on first paint, causing a flash of system-ui →
|
|
12
|
+
// brand-font swap on every refresh. Server-rendering this map kills the swap.
|
|
13
|
+
const brandSansMap = Object.fromEntries(
|
|
14
|
+
brand.fonts.map((f) => [f.id, f.stack]),
|
|
15
|
+
);
|
|
16
|
+
|
|
7
17
|
// next/font self-hosts these and emits preload links automatically, so the
|
|
8
18
|
// browser has the woff2 in hand before first paint — kills FOUT on the
|
|
9
19
|
// showcase app. The published @import in packages/core/src/styles.css stays
|
|
@@ -78,12 +88,12 @@ export default function RootLayout({
|
|
|
78
88
|
// first so the browser uses the already-fetched woff2 from the
|
|
79
89
|
// very first paint. Fall back to system-ui if next/font hasn't
|
|
80
90
|
// initialized yet.
|
|
81
|
-
var SANS = {
|
|
91
|
+
var SANS = Object.assign({
|
|
82
92
|
hyperlegible: "'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui",
|
|
83
93
|
atkinson: "var(--font-atkinson), 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui",
|
|
84
94
|
inter: "var(--font-inter), 'Inter', ui-sans-serif, sans-serif, system-ui",
|
|
85
95
|
system: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif"
|
|
86
|
-
};
|
|
96
|
+
}, ${JSON.stringify(brandSansMap)});
|
|
87
97
|
var SERIF = {
|
|
88
98
|
georgia: "Georgia, ui-serif, serif",
|
|
89
99
|
lora: "var(--font-lora), 'Lora', Georgia, ui-serif, serif",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
const QUERY = "(prefers-reduced-motion: reduce)";
|
|
6
|
+
|
|
7
|
+
export function useReducedMotion(): boolean {
|
|
8
|
+
const [reduced, setReduced] = React.useState(false);
|
|
9
|
+
|
|
10
|
+
React.useEffect(() => {
|
|
11
|
+
const mql = window.matchMedia(QUERY);
|
|
12
|
+
const update = () => setReduced(mql.matches);
|
|
13
|
+
update();
|
|
14
|
+
mql.addEventListener("change", update);
|
|
15
|
+
return () => mql.removeEventListener("change", update);
|
|
16
|
+
}, []);
|
|
17
|
+
|
|
18
|
+
return reduced;
|
|
19
|
+
}
|
package/src/styles.css
CHANGED
|
@@ -17,7 +17,10 @@
|
|
|
17
17
|
@custom-variant dark (&:is(.dark *));
|
|
18
18
|
|
|
19
19
|
:root {
|
|
20
|
-
|
|
20
|
+
/* Brand sans from tokens.json leads. Atkinson Hyperlegible (loaded via the
|
|
21
|
+
Google Fonts @import above) is the canonical fallback so unbranded
|
|
22
|
+
consumers still get a high-legibility face out of the box. */
|
|
23
|
+
--font-sans: 'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
|
|
21
24
|
--font-mono: 'JetBrains Mono', ui-monospace, monospace;
|
|
22
25
|
--font-serif: ui-serif, Georgia, serif;
|
|
23
26
|
--font-size-scale: 1;
|
|
@@ -249,6 +252,19 @@
|
|
|
249
252
|
* {
|
|
250
253
|
@apply border-border outline-ring/50;
|
|
251
254
|
}
|
|
255
|
+
/* Bind html to --font-sans so the picker propagates everywhere — not just
|
|
256
|
+
elements that use the `font-sans` Tailwind utility. Tailwind v4's preflight
|
|
257
|
+
binds html to --default-font-family, which is silently NOT --font-sans, so
|
|
258
|
+
iframe previews, plain-text components, and Home/Layers tabs would otherwise
|
|
259
|
+
fall through to system-ui regardless of the brand-font selection. */
|
|
260
|
+
html {
|
|
261
|
+
font-family: var(--font-sans);
|
|
262
|
+
}
|
|
263
|
+
/* Match: monospace elements pick up --font-mono without each component
|
|
264
|
+
having to remember a `font-mono` class. */
|
|
265
|
+
code, kbd, samp, pre {
|
|
266
|
+
font-family: var(--font-mono);
|
|
267
|
+
}
|
|
252
268
|
body {
|
|
253
269
|
@apply bg-background text-foreground;
|
|
254
270
|
-webkit-font-smoothing: antialiased;
|