@behavioral-agentic-design-system/core 0.6.0 → 0.7.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +30 -5
  3. package/scripts/bads-sync.mjs +1 -1
  4. package/scripts/build-fonts.cjs +15 -8
  5. package/scripts/build-tokens.cjs +139 -23
  6. package/src/api/brand-fonts.ts +27 -6
  7. package/src/api/layers/file.ts +4 -3
  8. package/src/api/layers.ts +8 -7
  9. package/src/api/site-auth.ts +50 -0
  10. package/src/app/font-ready.tsx +1 -1
  11. package/src/app/layout.tsx +9 -3
  12. package/src/app/preview/components/page.tsx +78 -1
  13. package/src/app/preview/icons/page.tsx +5 -0
  14. package/src/app/shell.tsx +27 -22
  15. package/src/app/site-login/page.tsx +82 -0
  16. package/src/brand-fonts.css +5 -0
  17. package/src/components/Foundations/Motion.stories.tsx +66 -0
  18. package/src/components/customize/letter-spacing.tsx +3 -2
  19. package/src/components/customize/type-scale.tsx +3 -2
  20. package/src/components/customize-tab.tsx +8 -7
  21. package/src/components/home-tab.tsx +498 -235
  22. package/src/components/layers-tab.tsx +141 -3
  23. package/src/components/ui/alert.tsx +2 -2
  24. package/src/components/ui/bottom-sheet.tsx +124 -0
  25. package/src/components/ui/button.tsx +1 -1
  26. package/src/components/ui/chart.tsx +115 -14
  27. package/src/components/ui/checkbox.tsx +3 -2
  28. package/src/components/ui/dialog.tsx +3 -3
  29. package/src/components/ui/index.ts +1 -0
  30. package/src/components/ui/radio-group.tsx +4 -3
  31. package/src/components/ui/sheet.tsx +1 -1
  32. package/src/components/ui/switch.tsx +3 -3
  33. package/src/components/ui/tabs.tsx +6 -0
  34. package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
  35. package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
  36. package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
  37. package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
  38. package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
  39. package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
  40. package/src/fonts/InterVariable-Italic.woff2 +0 -0
  41. package/src/fonts/InterVariable.woff2 +0 -0
  42. package/src/fonts.css +99 -0
  43. package/src/hooks/use-global-primary-color.ts +114 -68
  44. package/src/hooks/use-global-serif-font.ts +1 -1
  45. package/src/lib/storage.ts +2 -2
  46. package/src/styles.css +151 -61
  47. package/src/tokens.default.json +4 -4
  48. package/src/tokens.json +159 -162
  49. package/src/app/preview/login/page.tsx +0 -5
  50. package/src/app/preview/mail/page.tsx +0 -4
  51. package/src/app/preview/pricing/page.tsx +0 -4
  52. package/src/components/admin-menu.stories.tsx +0 -68
  53. package/src/components/admin-menu.tsx +0 -59
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Matthew Stephens
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,8 +1,29 @@
1
1
  {
2
2
  "name": "@behavioral-agentic-design-system/core",
3
- "version": "0.6.0",
4
- "description": "Behavioral Agentic Design System core — tokens and base components.",
5
- "license": "ISC",
3
+ "version": "0.7.0",
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
+ "license": "MIT",
6
+ "author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
7
+ "homepage": "https://github.com/matthewlarn/behavioral-agentic-design-system#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/matthewlarn/behavioral-agentic-design-system.git",
11
+ "directory": "packages/core"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/matthewlarn/behavioral-agentic-design-system/issues"
15
+ },
16
+ "keywords": [
17
+ "design-system",
18
+ "shadcn-ui",
19
+ "radix-ui",
20
+ "tailwindcss",
21
+ "tokens",
22
+ "accessibility",
23
+ "wcag-aaa",
24
+ "ai",
25
+ "agentic"
26
+ ],
6
27
  "type": "module",
7
28
  "sideEffects": [
8
29
  "**/*.css",
@@ -23,13 +44,15 @@
23
44
  ".": "./src/index.ts",
24
45
  "./package.json": "./package.json",
25
46
  "./styles.css": "./src/styles.css",
47
+ "./fonts.css": "./src/fonts.css",
48
+ "./brand-fonts.css": "./src/brand-fonts.css",
49
+ "./fonts/*": "./src/fonts/*",
26
50
  "./tokens.json": "./src/tokens.json",
27
51
  "./tokens.default.json": "./src/tokens.default.json",
28
52
  "./lib/*": "./src/lib/*.ts",
29
53
  "./hooks/*": "./src/hooks/*.ts",
30
54
  "./components/ui": "./src/components/ui/index.ts",
31
55
  "./components/ui/*": "./src/components/ui/*.tsx",
32
- "./components/admin-menu": "./src/components/admin-menu.tsx",
33
56
  "./components/customize-tab": "./src/components/customize-tab.tsx",
34
57
  "./components/home-tab": "./src/components/home-tab.tsx",
35
58
  "./components/layers-tab": "./src/components/layers-tab.tsx",
@@ -67,6 +90,8 @@
67
90
  "@xmldom/xmldom": "^0.9.10",
68
91
  "class-variance-authority": "^0.7.0",
69
92
  "clsx": "^2.1.0",
93
+ "react-markdown": "^10.1.0",
94
+ "remark-gfm": "^4.0.1",
70
95
  "tailwind-merge": "^3.0.0"
71
96
  },
72
97
  "peerDependencies": {
@@ -179,4 +204,4 @@
179
204
  "optional": true
180
205
  }
181
206
  }
182
- }
207
+ }
@@ -18,7 +18,7 @@
18
18
  * What it does NOT touch:
19
19
  * - brand.config.ts, brand-colors.json, packages/core/src/tokens.json
20
20
  * - styles/client-extras.css (your local CSS additions)
21
- * - layer-1-brand-voice/, layer-2-ethics-responsibility/, layer-6-patterns-and-rules/
21
+ * - layer-1-foundation/, layer-2-ethics-responsibility/, layer-6-patterns-and-rules/
22
22
  * - public/logos/, CLAUDE.md
23
23
  */
24
24
 
@@ -5,14 +5,17 @@
5
5
  * brand-fonts.json → brand-fonts.css
6
6
  *
7
7
  * brand-fonts.json is the source of truth for client-uploaded fonts. The
8
- * Customize tab's font-picker "+" tile uploads woff2/woff files to public/fonts/
9
- * via /api/brand-fonts and appends entries to this JSON. After each upload (and
10
- * during pnpm install on a fresh clone), this script regenerates brand-fonts.css
11
- * so the @font-face declarations match what's on disk.
8
+ * Customize tab's font-picker "+" tile uploads woff2/woff files via
9
+ * /api/brand-fonts and appends entries to this JSON. After each upload (and
10
+ * during pnpm install on a fresh clone), this script regenerates
11
+ * `packages/core/src/brand-fonts.css` so the @font-face declarations match
12
+ * what's on disk.
12
13
  *
13
- * The generated brand-fonts.css is imported by styles/globals.css (the import
14
- * is emitted by build-tokens.cjs) so every preview surface picks up the
15
- * faces automatically.
14
+ * The generated brand-fonts.css ships inside the @core package and is
15
+ * @imported automatically by styles.css — that's how downstream consumers
16
+ * (prototype repos, deployed apps) actually get the brand faces declared
17
+ * in tokens.json. The preview app's styles/globals.css also imports it via
18
+ * the relative path so dev feedback stays live.
16
19
  *
17
20
  * Run-from-consumer model: this script is invoked from a consumer repo's CWD
18
21
  * (via `pnpm build:fonts` → `bads-build-fonts`). Paths resolve against
@@ -24,7 +27,8 @@ const path = require('path');
24
27
 
25
28
  const ROOT = process.cwd();
26
29
  const SOURCE = path.join(ROOT, 'brand-fonts.json');
27
- const TARGET = path.join(ROOT, 'brand-fonts.css');
30
+ const TARGET_DIR = path.join(ROOT, 'packages', 'core', 'src');
31
+ const TARGET = path.join(TARGET_DIR, 'brand-fonts.css');
28
32
 
29
33
  const banner = `/* GENERATED FROM brand-fonts.json — DO NOT EDIT BY HAND.
30
34
  * Run \`pnpm build:fonts\` after changing brand-fonts.json (this happens
@@ -83,6 +87,9 @@ function build() {
83
87
  ? blocks
84
88
  : '/* No brand fonts registered yet. Add one via the Customize tab → font picker → "+". */';
85
89
  const out = `${banner}\n\n${body}\n`;
90
+ // Make sure packages/core/src exists even on a fresh clone where the dir
91
+ // hasn't been touched yet (rare, but the script should never crash here).
92
+ fs.mkdirSync(TARGET_DIR, { recursive: true });
86
93
  fs.writeFileSync(TARGET, out, 'utf8');
87
94
  console.log(`✓ wrote ${path.relative(ROOT, TARGET)} (${fonts.length} ${fonts.length === 1 ? 'family' : 'families'})`);
88
95
  }
@@ -58,7 +58,9 @@ if (!tokens.theme || !tokens.theme.light || !tokens.theme.dark) {
58
58
 
59
59
  // Resolve Tokens Studio aliases like `{color.primitive.slate.400}` to their
60
60
  // final $value at build time. Supports nested aliases (an alias whose target
61
- // is itself an alias). Non-alias values pass through unchanged.
61
+ // is itself an alias). Non-alias values pass through unchanged. This keeps
62
+ // semantic tokens (e.g. `theme.dark.border`) wired to primitive scale entries
63
+ // so designers can update one place and have everything follow.
62
64
  function resolveAlias(value, depth = 0) {
63
65
  if (typeof value !== 'string') return value;
64
66
  const match = value.match(/^\{(.+)\}$/);
@@ -84,6 +86,10 @@ const darkVars = emitVars(tokens.theme.dark);
84
86
  const fontSans = tokens.fontFamily.sans.$value;
85
87
  const fontMono = tokens.fontFamily.mono.$value;
86
88
  const fontSerif = tokens.fontFamily.serif.$value;
89
+ // Variable-font axis settings, applied to html so the whole tree inherits
90
+ // them. Only meaningful when the active sans is a variable font (Inter
91
+ // Variable ships as the default). Forks tune type here without code change.
92
+ const fontVariationSettings = tokens.fontVariationSettings?.$value ?? 'normal';
87
93
  const radius = tokens.borderRadius?.lg?.$value ?? '0.625rem';
88
94
  const spacing = tokens.theme?.light?.spacing?.$value ?? '0.25rem';
89
95
 
@@ -100,6 +106,15 @@ const easeIn = easing('ease-in', 'cubic-bezier(0.4, 0, 1, 1)');
100
106
  const easeOut = easing('ease-out', 'cubic-bezier(0, 0, 0.2, 1)');
101
107
  const easeInOut = easing('ease-in-out', 'cubic-bezier(0.4, 0, 0.2, 1)');
102
108
  const easeSpring = easing('ease-spring', 'cubic-bezier(0.34, 1.56, 0.64, 1)');
109
+ // Spring curve presets — physically-consistent named springs so animated
110
+ // component additions (and ecosystem libs like Motion Primitives that read
111
+ // the same CSS vars) settle the same way across the system. gentle = no
112
+ // overshoot for large surfaces, snappy = fast/no-overshoot for frequent UI,
113
+ // bounce = playful overshoot for delight. All auto-killed under
114
+ // prefers-reduced-motion by the base layer.
115
+ const springGentle = easing('spring-gentle', 'cubic-bezier(0.4, 0, 0.2, 1)');
116
+ const springSnappy = easing('spring-snappy', 'cubic-bezier(0.3, 0, 0, 1)');
117
+ const springBounce = easing('spring-bounce', 'cubic-bezier(0.34, 1.56, 0.64, 1)');
103
118
 
104
119
  const fontSize = (key, fallback) => tokens.fontSize?.[key]?.$value ?? fallback;
105
120
  const textXs = fontSize('xs', '14px');
@@ -157,7 +172,26 @@ const motionBlock = ` --duration-fast: ${durationFast};
157
172
  --ease-in: ${easeIn};
158
173
  --ease-out: ${easeOut};
159
174
  --ease-in-out: ${easeInOut};
160
- --ease-spring: ${easeSpring};`;
175
+ --ease-spring: ${easeSpring};
176
+ --spring-gentle: ${springGentle};
177
+ --spring-snappy: ${springSnappy};
178
+ --spring-bounce: ${springBounce};`;
179
+
180
+ // Semantic motion layer — intent-named duration+easing pairs sourced from
181
+ // tokens.motion (fade / slide / scale / expand / spin). Emits
182
+ // --motion-<intent>-duration and --motion-<intent>-ease so components and AI
183
+ // pick motion by intent rather than raw numbers. resolveAlias turns
184
+ // {duration.base} / {easing.ease-out} into their primitive values, so editing a
185
+ // primitive re-tunes every intent that references it. Reduced-motion still
186
+ // neutralizes all of it via the base layer. See layer-6 motion.md.
187
+ const motionSemanticBlock = Object.entries(tokens.motion || {})
188
+ .filter(([, v]) => v && v.duration && v.easing)
189
+ .map(
190
+ ([intent, v]) =>
191
+ ` --motion-${intent}-duration: ${resolveAlias(v.duration.$value)};\n` +
192
+ ` --motion-${intent}-ease: ${resolveAlias(v.easing.$value)};`,
193
+ )
194
+ .join('\n');
161
195
 
162
196
  // Chart palette derives from --primary by default so all data viz tracks the
163
197
  // brand color picker. Each chart-N reads --primary's hue and rotates around
@@ -182,9 +216,11 @@ const chartHue = (n, fallback) =>
182
216
  const chartChroma2 = tokens.chart?.chroma2Damping?.$value ?? '0.65';
183
217
 
184
218
  // Optional per-step lightness and chroma. When defined in tokens.json the
185
- // palette becomes a monochromatic ramp at --primary's hue (each step picks its
186
- // own L and a chroma multiplier on --primary's c). When absent, falls back to
187
- // the legacy hue-rotation behavior using a single --chart-lightness.
219
+ // palette becomes a monochromatic ramp at --primary's hue (each step picks
220
+ // its own L and a chroma multiplier on --primary's c). When absent, falls
221
+ // back to the legacy hue-rotation behavior using a single --chart-lightness.
222
+ // Clients opt in by adding chart.lightnessSteps + chart.chromaSteps to their
223
+ // tokens.json (see Swimtopia for an example of a Pool Blue → Navy ramp).
188
224
  const stepL = (mode, n) =>
189
225
  tokens.chart?.lightnessSteps?.[mode]?.[`step${n}`]?.$value;
190
226
  const stepC = (n) => tokens.chart?.chromaSteps?.[`step${n}`]?.$value;
@@ -296,6 +332,9 @@ const themeInline = `@theme inline {
296
332
  --ease-out: var(--ease-out);
297
333
  --ease-in-out: var(--ease-in-out);
298
334
  --ease-spring: var(--ease-spring);
335
+ --ease-spring-gentle: var(--spring-gentle);
336
+ --ease-spring-snappy: var(--spring-snappy);
337
+ --ease-spring-bounce: var(--spring-bounce);
299
338
 
300
339
  /* Accessibility floor — minimum 14px for text-xs (vs Tailwind's 12px default).
301
340
  Font sizes are dynamically computed by useGlobalTypeScale hook and set as
@@ -347,7 +386,10 @@ const baseLayer = `@layer base {
347
386
  imports stylesheets in. Both rules live in @layer base; within a layer,
348
387
  specificity decides. \`:root *\` is (0,1,0), \`*\` is (0,0,0) — we win. Utility
349
388
  classes in @layer utilities still beat both because later layers trump
350
- specificity, so \`border-red-500\` and friends keep working normally. */
389
+ specificity, so \`border-red-500\` and friends keep working normally.
390
+ Without this bump, consumers who @import the design system BEFORE
391
+ tailwindcss get a cascade-order race where preflight wins and naked
392
+ \`border\` utilities render as text color (near-white on dark themes). */
351
393
  :root * {
352
394
  @apply border-border outline-ring/50;
353
395
  }
@@ -358,6 +400,11 @@ const baseLayer = `@layer base {
358
400
  fall through to system-ui regardless of the brand-font selection. */
359
401
  html {
360
402
  font-family: var(--font-sans);
403
+ /* Variable-font axis settings (Inter Variable ships by default). Sourced
404
+ from tokens.json → --font-variation-settings so forks tune optical
405
+ size / weight axes without touching component source. "normal" is a
406
+ no-op for static fonts. */
407
+ font-variation-settings: var(--font-variation-settings, normal);
361
408
  }
362
409
  /* Match: monospace elements pick up --font-mono without each component
363
410
  having to remember a \`font-mono\` class. */
@@ -391,23 +438,20 @@ const baseLayer = `@layer base {
391
438
  }
392
439
  /* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
393
440
  text. Scope to <p> only — UI primitives stay tight. Last-child has
394
- no trailing margin so containers don't get extra padding.
395
-
396
- The second rule bows out of flex / grid contexts because by the
397
- time an author has wrapped content in display:flex or display:grid,
398
- they are clearly building UI layout (rows of chips, tile metadata,
399
- calendar entries, etc.) and not running prose. Without this
400
- carve-out, every <p> used as a UI label inside a flex row gets
401
- an extra 1.5em margin-bottom, which silently inflates its margin
402
- box and breaks vertical alignment with adjacent items (a dot
403
- beside an uppercase eyebrow drops below the visible text, the
404
- classic symptom). The proper semantic fix is to use <span> for
405
- UI labels, but the design system shouldn't punish authors who
406
- reach for <p> in obvious UI contexts. Specificity 0,2,1 wins
407
- over the bare 0,1,1 rule above. */
441
+ no trailing margin so containers don't get extra padding. */
408
442
  p:not(:last-child) {
409
443
  margin-bottom: 1.5em;
410
444
  }
445
+ /* Flex / grid layout carve-out for the rule above. When <p> is used as
446
+ a UI label inside a flex row or grid cell, the 1.5em ghost margin-
447
+ bottom inflates its margin box, which drags its geometric center
448
+ down. items-center then aligns siblings (org-color dots, icons,
449
+ badges) to a lower y than the visible text. Zero the block margins
450
+ on <p> one level deep into any flex/grid container, and through one
451
+ wrapper, so authors who reach for <p> in obvious UI contexts don't
452
+ silently break alignment. Specificity ties the bare prose rule at
453
+ 0,1,1 — source order resolves the tie, which is why this block must
454
+ follow the rule above. */
411
455
  :is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) p,
412
456
  :is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) > * > p {
413
457
  margin-block: 0;
@@ -434,6 +478,54 @@ const baseLayer = `@layer base {
434
478
  scroll-behavior: auto !important;
435
479
  }
436
480
  }
481
+ /* Windows High Contrast Mode (forced-colors). Supports SC 1.4.1 (Use of
482
+ Color) and 1.4.11 (Non-text Contrast) for the ~3% of Windows users who
483
+ run HCM. When the OS forces its own palette it discards our custom
484
+ background fills — so a ghost/secondary Button, a selected tab, or a
485
+ checked control that relied on a background tint to read as distinct
486
+ collapses into the body text. The UA keeps token *borders* (mapping
487
+ them to system colors) but cannot invent a boundary where none was
488
+ drawn. These rules restore the structure the override drops; they do
489
+ NOT hardcode brand colors (that's forbidden) — they use the CSS
490
+ system-color keywords HCM actually honors. */
491
+ @media (forced-colors: active) {
492
+ /* Every interactive control gets a drawn boundary so it survives the
493
+ loss of its background fill. ButtonBorder is the system color the UA
494
+ uses for control edges. */
495
+ button,
496
+ [role="button"],
497
+ input,
498
+ select,
499
+ textarea {
500
+ border: 1px solid ButtonBorder;
501
+ }
502
+ /* Focus ring maps to the system Highlight so it is never invisible,
503
+ regardless of the user's chosen high-contrast theme. */
504
+ :focus-visible {
505
+ outline: 2px solid Highlight;
506
+ outline-offset: 2px;
507
+ }
508
+ /* Selected / checked / pressed / active states lose their background
509
+ tint under HCM. Opt out of forced-color-adjust for just these state
510
+ markers and paint the system Highlight so on/off stays legible on
511
+ toggles, switches, selected tabs, and checkboxes. */
512
+ [aria-selected="true"],
513
+ [aria-checked="true"],
514
+ [aria-pressed="true"],
515
+ [data-state="checked"],
516
+ [data-state="active"],
517
+ [data-state="on"] {
518
+ forced-color-adjust: none;
519
+ background-color: Highlight;
520
+ color: HighlightText;
521
+ }
522
+ /* Disabled controls should read as dimmed via the system GrayText color
523
+ rather than our muted token (which the override would flatten). */
524
+ :disabled,
525
+ [aria-disabled="true"] {
526
+ color: GrayText;
527
+ }
528
+ }
437
529
  }
438
530
 
439
531
  /* Global tracking offset — the Letter Spacing slider in the Customize
@@ -490,8 +582,26 @@ const pkgCss = `${banner}
490
582
  * Override any token by re-declaring it after this @import.
491
583
  */
492
584
 
585
+ /* Inter Variable leads (the default sans) as the zero-setup CDN fallback;
586
+ * Atkinson Hyperlegible stays as the accessibility-preserving secondary.
587
+ * Self-hosted equivalents in fonts.css win when consumers copy the binaries
588
+ * (see note below). */
589
+ @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
493
590
  @import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
494
591
 
592
+ /* Self-hosted brand faces shipped inside this package. fonts.css holds the
593
+ * canonical SIL OFL defaults (Hyperlegible Sans, 6 weights). brand-fonts.css
594
+ * is generated from brand-fonts.json by \`pnpm build:fonts\` and carries any
595
+ * client-uploaded faces (Season, etc.). Both reference URLs at /fonts/<file>
596
+ * — consumers copy the binaries from
597
+ * \`node_modules/@behavioral-agentic-design-system/core/fonts/\` into their own
598
+ * \`public/fonts/\` so the URLs resolve. See CLIENT_ONBOARDING.md → Shipping
599
+ * fonts. CSS @import order: Google Fonts first (lowest priority fallback),
600
+ * then local @font-face rules so the brand stack wins.
601
+ */
602
+ @import "./fonts.css";
603
+ @import "./brand-fonts.css";
604
+
495
605
  /* Tailwind v4 only generates classes it scans. The shell components, hooks,
496
606
  * and app routes shipped in this package use plenty of Tailwind classes that
497
607
  * the consumer's own source code never references — Button's variants,
@@ -516,6 +626,7 @@ const pkgCss = `${banner}
516
626
  --font-sans: ${fontSans}, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
517
627
  --font-mono: ${fontMono};
518
628
  --font-serif: ${fontSerif};
629
+ --font-variation-settings: ${fontVariationSettings};
519
630
  --font-size-scale: 1;
520
631
 
521
632
  ${lightVars}
@@ -523,6 +634,7 @@ ${lightVars}
523
634
  --radius: ${radius};
524
635
  ${shadowBlock}
525
636
  ${motionBlock}
637
+ ${motionSemanticBlock}
526
638
  --spacing: ${spacing};
527
639
 
528
640
  ${chartDerivationLight}
@@ -551,8 +663,10 @@ console.log(`✓ wrote ${path.relative(ROOT, PKG_CSS)}`);
551
663
  // @import so consumers without next/font still get the canonical theme.
552
664
  const appCss = `${banner}
553
665
 
554
- @import "../fonts.css";
555
- @import "../brand-fonts.css";
666
+ /* Pulled from packages/core/src/ so the preview app and the published
667
+ * package read from the same canonical files. */
668
+ @import "../packages/core/src/fonts.css";
669
+ @import "../packages/core/src/brand-fonts.css";
556
670
  @import "tailwindcss";
557
671
  @import "tw-animate-css";
558
672
 
@@ -568,9 +682,10 @@ const appCss = `${banner}
568
682
  undefined, and a bare var() reference invalidates the entire
569
683
  custom-property value at computed-value time, leaving --font-sans
570
684
  empty and text falling through to browser default ("Times"). */
571
- --font-sans: ${fontSans}, var(--font-atkinson, 'Atkinson Hyperlegible'), 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
685
+ --font-sans: ${fontSans}, var(--font-inter, 'Inter'), var(--font-atkinson, 'Atkinson Hyperlegible'), 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
572
686
  --font-serif: ${fontSerif}, var(--font-source-serif, 'Source Serif 4'), 'Source Serif 4', Georgia, ui-serif, serif;
573
687
  --font-mono: ${fontMono}, var(--font-jetbrains, 'JetBrains Mono'), 'JetBrains Mono', ui-monospace, monospace;
688
+ --font-variation-settings: ${fontVariationSettings};
574
689
  --font-size-scale: 1;
575
690
 
576
691
  ${lightVars}
@@ -578,6 +693,7 @@ ${lightVars}
578
693
  --radius: ${radius};
579
694
  ${shadowBlock}
580
695
  ${motionBlock}
696
+ ${motionSemanticBlock}
581
697
  --spacing: ${spacing};
582
698
 
583
699
  ${chartDerivationLight}
@@ -4,6 +4,17 @@ import { spawn } from "node:child_process";
4
4
  import { NextResponse } from "next/server";
5
5
 
6
6
  const FONTS_PATH = path.join(process.cwd(), "brand-fonts.json");
7
+ // Canonical location — ships with the npm package via the `./fonts/*` export.
8
+ const PKG_FONTS = path.join(
9
+ process.cwd(),
10
+ "packages",
11
+ "core",
12
+ "src",
13
+ "fonts",
14
+ );
15
+ // Mirror — Next.js serves these at /fonts/<file> for the dev preview. Kept
16
+ // in sync with PKG_FONTS so the preview reflects uploads instantly without a
17
+ // symlink (symlinks complicate Windows + git in mixed-OS teams).
7
18
  const PUBLIC_FONTS = path.join(process.cwd(), "public", "fonts");
8
19
 
9
20
  type BrandFontFile = {
@@ -154,6 +165,7 @@ export async function POST(request: Request) {
154
165
  );
155
166
  }
156
167
 
168
+ await fs.mkdir(PKG_FONTS, { recursive: true });
157
169
  await fs.mkdir(PUBLIC_FONTS, { recursive: true });
158
170
 
159
171
  const written: BrandFontFile[] = [];
@@ -171,6 +183,9 @@ export async function POST(request: Request) {
171
183
  // Stable deterministic filename so re-uploads overwrite the same path.
172
184
  const out = `${id}-${String(weight).replace(/\s+/g, "_")}-${style}.${format}`;
173
185
  const buf = Buffer.from(await f.arrayBuffer());
186
+ // Canonical write — this is the copy that ships in the npm tarball.
187
+ await fs.writeFile(path.join(PKG_FONTS, out), buf);
188
+ // Mirror for the dev preview's /fonts/<file> static-asset route.
174
189
  await fs.writeFile(path.join(PUBLIC_FONTS, out), buf);
175
190
  written.push({
176
191
  path: `/fonts/${out}`,
@@ -237,14 +252,20 @@ export async function POST(request: Request) {
237
252
  { status: 404 },
238
253
  );
239
254
  }
240
- // Best-effort delete the actual files too — never fatal.
255
+ // Best-effort delete the actual files too — never fatal. Removes from
256
+ // both the canonical (packages/core/src/fonts/) and mirror (public/fonts/)
257
+ // locations so the next `pnpm build` doesn't drag stale binaries along.
241
258
  if (target.files) {
242
259
  for (const f of target.files) {
243
- const abs = path.join(process.cwd(), "public", f.path.replace(/^\//, ""));
244
- try {
245
- await fs.unlink(abs);
246
- } catch {
247
- // already gone
260
+ const fileName = f.path.replace(/^\/fonts\//, "");
261
+ const pkgAbs = path.join(PKG_FONTS, fileName);
262
+ const publicAbs = path.join(PUBLIC_FONTS, fileName);
263
+ for (const p of [pkgAbs, publicAbs]) {
264
+ try {
265
+ await fs.unlink(p);
266
+ } catch {
267
+ // already gone
268
+ }
248
269
  }
249
270
  }
250
271
  }
@@ -16,9 +16,10 @@ function isAllowed(rel: string) {
16
16
  }
17
17
 
18
18
  export async function GET(request: Request) {
19
- if (process.env.NODE_ENV !== "development") {
20
- return Response.json({ error: "dev-only" }, { status: 403 });
21
- }
19
+ // Public read: layer file contents are the open-source design system.
20
+ // Path is sanitized via isAllowed() so traversal can't escape the
21
+ // allowlist. POST below stays dev-only because Vercel's filesystem is
22
+ // read-only and writes would silently no-op there.
22
23
  const url = new URL(request.url);
23
24
  const rel = url.searchParams.get("path") ?? "";
24
25
  if (!isAllowed(rel)) {
package/src/api/layers.ts CHANGED
@@ -31,11 +31,11 @@ function listFiles(dir: string): string[] {
31
31
 
32
32
  function sortLayerFiles(slug: string, files: string[]): string[] {
33
33
  // Brand Voice: intro.md first, then framework.md, then others alphabetically
34
- if (slug === "layer-1-brand-voice") {
34
+ if (slug === "layer-1-foundation") {
35
35
  const intro = files.find((f) => f.endsWith("intro.md"));
36
36
  const framework = files.find((f) => f.endsWith("framework.md"));
37
37
  const rest = files.filter((f) => !f.endsWith("intro.md") && !f.endsWith("framework.md")).sort();
38
- return [intro, framework, ...rest].filter(Boolean) as string[];
38
+ return [intro, framework, ...rest].filter((f): f is string => f !== undefined);
39
39
  }
40
40
  return files.sort();
41
41
  }
@@ -48,17 +48,18 @@ function prettifyLayerName(slug: string) {
48
48
  }
49
49
 
50
50
  export async function GET() {
51
- if (process.env.NODE_ENV !== "development") {
52
- return Response.json({ error: "dev-only" }, { status: 403 });
53
- }
51
+ // Public read: the layer file structure is the open-source design system
52
+ // itself, safe to expose. Writes (POST in layers/file.ts) stay dev-only
53
+ // because Vercel's serverless filesystem is read-only and we don't want
54
+ // saves to silently no-op in production.
54
55
  const layers = listLayers().map((slug) => ({
55
56
  slug,
56
57
  label: prettifyLayerName(slug),
57
58
  files: sortLayerFiles(slug, listFiles(path.join(ROOT, slug))),
58
59
  }));
59
60
 
60
- // Add tokens.json from Foundation layer (layer-3)
61
- const foundationIndex = layers.findIndex((l) => l.slug === "layer-3-foundation");
61
+ // Add tokens.json from Primitive Tokens layer (layer-3)
62
+ const foundationIndex = layers.findIndex((l) => l.slug === "layer-3-primitive-tokens");
62
63
  if (foundationIndex !== -1) {
63
64
  const tokensPath = path.join(ROOT, "packages/core/src/tokens.json");
64
65
  if (fs.existsSync(tokensPath)) {
@@ -0,0 +1,50 @@
1
+ import { NextRequest, NextResponse } from "next/server";
2
+
3
+ // POST /api/site-auth handles the password submission from /site-login.
4
+ // Validates against SITE_PASSWORD and sets an httpOnly cookie containing
5
+ // the password value. The middleware (middleware.ts at the repo root)
6
+ // reads the cookie on every subsequent request. Returns a 303 redirect
7
+ // either back to the requested `next` path (success) or back to
8
+ // /site-login with ?error=1 (mismatch).
9
+
10
+ const COOKIE_NAME = "bads_site_auth";
11
+ const COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 30; // 30 days
12
+
13
+ export async function POST(req: NextRequest) {
14
+ const password = process.env.SITE_PASSWORD;
15
+ if (!password) {
16
+ return NextResponse.json(
17
+ { ok: false, error: "Site gate not configured" },
18
+ { status: 400 },
19
+ );
20
+ }
21
+
22
+ const form = await req.formData();
23
+ const submitted = String(form.get("password") || "");
24
+ const requestedNext = String(form.get("next") || "/");
25
+
26
+ if (submitted !== password) {
27
+ const url = new URL("/site-login", req.url);
28
+ url.searchParams.set("next", requestedNext);
29
+ url.searchParams.set("error", "1");
30
+ return NextResponse.redirect(url, 303);
31
+ }
32
+
33
+ const redirect = NextResponse.redirect(
34
+ new URL(sanitizeNext(requestedNext), req.url),
35
+ 303,
36
+ );
37
+ redirect.cookies.set(COOKIE_NAME, password, {
38
+ path: "/",
39
+ httpOnly: true,
40
+ sameSite: "lax",
41
+ secure: process.env.NODE_ENV === "production",
42
+ maxAge: COOKIE_MAX_AGE_SECONDS,
43
+ });
44
+ return redirect;
45
+ }
46
+
47
+ function sanitizeNext(next: string): string {
48
+ if (next.startsWith("/") && !next.startsWith("//")) return next;
49
+ return "/";
50
+ }
@@ -27,7 +27,7 @@ export function FontReady() {
27
27
 
28
28
  let alreadyReady = false;
29
29
  try {
30
- alreadyReady = document.fonts.check("1em 'Season'");
30
+ alreadyReady = document.fonts.check("1em 'Hyperlegible Sans'");
31
31
  } catch {
32
32
  // fonts.check throws if the font name is unknown — treat as not ready.
33
33
  }
@@ -93,9 +93,16 @@ export default function RootLayout({
93
93
  <head>
94
94
  <link
95
95
  rel="preload"
96
- href="/fonts/SeasonCollectionVF-TRIAL.ttf"
96
+ href="/fonts/HyperlegibleSans-Regular.woff2"
97
97
  as="font"
98
- type="font/ttf"
98
+ type="font/woff2"
99
+ crossOrigin=""
100
+ />
101
+ <link
102
+ rel="preload"
103
+ href="/fonts/HyperlegibleSans-Bold.woff2"
104
+ as="font"
105
+ type="font/woff2"
99
106
  crossOrigin=""
100
107
  />
101
108
  <script
@@ -131,7 +138,6 @@ export default function RootLayout({
131
138
  system: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif"
132
139
  }, ${JSON.stringify(brandSansMap)});
133
140
  var SERIF = {
134
- "season-serif": "'Season Serif', 'Season', ui-serif, Georgia, serif",
135
141
  georgia: "Georgia, ui-serif, serif",
136
142
  lora: "var(--font-lora), 'Lora', Georgia, ui-serif, serif",
137
143
  "source-serif": "var(--font-source-serif), 'Source Serif 4', Georgia, ui-serif, serif",