@behavioral-agentic-design-system/core 0.6.0 → 0.8.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 (64) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +35 -6
  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 +41 -12
  9. package/src/api/onboarding-extract.ts +435 -0
  10. package/src/api/onboarding.ts +82 -0
  11. package/src/api/site-auth.ts +50 -0
  12. package/src/app/font-ready.tsx +1 -1
  13. package/src/app/layout.tsx +9 -3
  14. package/src/app/preview/components/page.tsx +78 -1
  15. package/src/app/preview/icons/page.tsx +5 -0
  16. package/src/app/shell.tsx +90 -23
  17. package/src/app/site-login/page.tsx +82 -0
  18. package/src/brand-fonts.css +5 -0
  19. package/src/components/Foundations/Colors.stories.tsx +10 -1
  20. package/src/components/Foundations/Motion.stories.tsx +66 -0
  21. package/src/components/customize/letter-spacing.tsx +3 -2
  22. package/src/components/customize/type-scale.tsx +3 -2
  23. package/src/components/customize-tab.tsx +11 -7
  24. package/src/components/home-tab.tsx +498 -235
  25. package/src/components/layers-tab.tsx +313 -10
  26. package/src/components/onboarding-wizard.tsx +1421 -0
  27. package/src/components/ui/alert.tsx +2 -2
  28. package/src/components/ui/bottom-sheet.tsx +124 -0
  29. package/src/components/ui/button.tsx +1 -1
  30. package/src/components/ui/chart.tsx +115 -14
  31. package/src/components/ui/checkbox.tsx +3 -2
  32. package/src/components/ui/dialog.tsx +7 -4
  33. package/src/components/ui/dropdown-menu.tsx +4 -0
  34. package/src/components/ui/index.ts +1 -0
  35. package/src/components/ui/popover.tsx +6 -0
  36. package/src/components/ui/radio-group.tsx +4 -3
  37. package/src/components/ui/scroll-area.tsx +5 -0
  38. package/src/components/ui/select.tsx +4 -0
  39. package/src/components/ui/sheet.tsx +8 -1
  40. package/src/components/ui/slider.tsx +22 -7
  41. package/src/components/ui/switch.tsx +3 -3
  42. package/src/components/ui/tabs.tsx +6 -0
  43. package/src/components/ui/tooltip.tsx +4 -0
  44. package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
  45. package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
  46. package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
  47. package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
  48. package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
  49. package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
  50. package/src/fonts/InterVariable-Italic.woff2 +0 -0
  51. package/src/fonts/InterVariable.woff2 +0 -0
  52. package/src/fonts.css +99 -0
  53. package/src/hooks/use-global-primary-color.ts +114 -68
  54. package/src/hooks/use-global-serif-font.ts +1 -1
  55. package/src/hooks/use-portal-theme-class.tsx +90 -0
  56. package/src/lib/storage.ts +2 -2
  57. package/src/styles.css +151 -61
  58. package/src/tokens.default.json +4 -4
  59. package/src/tokens.json +159 -162
  60. package/src/app/preview/login/page.tsx +0 -5
  61. package/src/app/preview/mail/page.tsx +0 -4
  62. package/src/app/preview/pricing/page.tsx +0 -4
  63. package/src/components/admin-menu.stories.tsx +0 -68
  64. package/src/components/admin-menu.tsx +0 -59
package/src/styles.css CHANGED
@@ -12,8 +12,26 @@
12
12
  * Override any token by re-declaring it after this @import.
13
13
  */
14
14
 
15
+ /* Inter Variable leads (the default sans) as the zero-setup CDN fallback;
16
+ * Atkinson Hyperlegible stays as the accessibility-preserving secondary.
17
+ * Self-hosted equivalents in fonts.css win when consumers copy the binaries
18
+ * (see note below). */
19
+ @import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
15
20
  @import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
16
21
 
22
+ /* Self-hosted brand faces shipped inside this package. fonts.css holds the
23
+ * canonical SIL OFL defaults (Hyperlegible Sans, 6 weights). brand-fonts.css
24
+ * is generated from brand-fonts.json by `pnpm build:fonts` and carries any
25
+ * client-uploaded faces (Season, etc.). Both reference URLs at /fonts/<file>
26
+ * — consumers copy the binaries from
27
+ * `node_modules/@behavioral-agentic-design-system/core/fonts/` into their own
28
+ * `public/fonts/` so the URLs resolve. See CLIENT_ONBOARDING.md → Shipping
29
+ * fonts. CSS @import order: Google Fonts first (lowest priority fallback),
30
+ * then local @font-face rules so the brand stack wins.
31
+ */
32
+ @import "./fonts.css";
33
+ @import "./brand-fonts.css";
34
+
17
35
  /* Tailwind v4 only generates classes it scans. The shell components, hooks,
18
36
  * and app routes shipped in this package use plenty of Tailwind classes that
19
37
  * the consumer's own source code never references — Button's variants,
@@ -35,9 +53,10 @@
35
53
  /* Brand sans from tokens.json leads. Atkinson Hyperlegible (loaded via the
36
54
  Google Fonts @import above) is the canonical fallback so unbranded
37
55
  consumers still get a high-legibility face out of the box. */
38
- --font-sans: 'Season', 'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
56
+ --font-sans: 'Inter', 'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
39
57
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
40
- --font-serif: 'Season Serif', 'Season', ui-serif, Georgia, serif;
58
+ --font-serif: ui-serif, Georgia, serif;
59
+ --font-variation-settings: normal;
41
60
  --font-size-scale: 1;
42
61
 
43
62
  --background: oklch(1 0 0);
@@ -46,7 +65,7 @@
46
65
  --card-foreground: oklch(0.1450 0 0);
47
66
  --popover: oklch(1 0 0);
48
67
  --popover-foreground: oklch(0.1450 0 0);
49
- --primary: #025FFF;
68
+ --primary: #1F1F1F;
50
69
  --primary-foreground: #FAFAFA;
51
70
  --link: var(--primary);
52
71
  --secondary: oklch(0.9700 0 0);
@@ -60,12 +79,12 @@
60
79
  --border: oklch(0.6100 0 0);
61
80
  --input: oklch(0.6100 0 0);
62
81
  --ring: oklch(0.4500 0 0);
63
- --chart-1: oklch(0.5836 0.2469 264.05);
64
- --chart-2: oklch(0.5000 0.2345 264.05);
65
- --chart-3: oklch(0.4200 0.1975 264.05);
66
- --chart-4: oklch(0.3400 0.1481 264.05);
67
- --chart-5: oklch(0.2700 0.0988 264.05);
68
- --sidebar: oklch(0.9700 0 0);
82
+ --chart-1: oklch(0.6200 0.2000 220);
83
+ --chart-2: oklch(0.6200 0.2200 145);
84
+ --chart-3: oklch(0.6700 0.2000 70);
85
+ --chart-4: oklch(0.6000 0.2600 340);
86
+ --chart-5: oklch(0.6200 0.2200 25);
87
+ --sidebar: oklch(0.9850 0 0);
69
88
  --sidebar-foreground: oklch(0.1450 0 0);
70
89
  --sidebar-primary: oklch(0.2050 0 0);
71
90
  --sidebar-primary-foreground: oklch(0.9850 0 0);
@@ -103,58 +122,73 @@
103
122
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
104
123
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
105
124
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
125
+ --spring-gentle: cubic-bezier(0.4, 0, 0.2, 1);
126
+ --spring-snappy: cubic-bezier(0.3, 0, 0, 1);
127
+ --spring-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
128
+ --motion-fade-duration: 200ms;
129
+ --motion-fade-ease: cubic-bezier(0, 0, 0.2, 1);
130
+ --motion-slide-duration: 200ms;
131
+ --motion-slide-ease: cubic-bezier(0, 0, 0.2, 1);
132
+ --motion-scale-duration: 150ms;
133
+ --motion-scale-ease: cubic-bezier(0.3, 0, 0, 1);
134
+ --motion-expand-duration: 300ms;
135
+ --motion-expand-ease: cubic-bezier(0.4, 0, 0.2, 1);
136
+ --motion-spin-duration: 300ms;
137
+ --motion-spin-ease: cubic-bezier(0, 0, 1, 1);
106
138
  --spacing: 0.25rem;
107
139
 
108
140
  /* Chart palette — derives from --primary so brand changes propagate.
109
141
  Override individual --chart-N inline (documentElement.style) to opt out. */
110
- --chart-1: oklch(from var(--primary) 0.58 c h);
111
- --chart-2: oklch(from var(--primary) 0.50 calc(c * 0.95) h);
112
- --chart-3: oklch(from var(--primary) 0.42 calc(c * 0.80) h);
113
- --chart-4: oklch(from var(--primary) 0.34 calc(c * 0.60) h);
114
- --chart-5: oklch(from var(--primary) 0.27 calc(c * 0.40) h);
142
+ --chart-lightness: 0.58;
143
+ --chart-1: oklch(from var(--primary) var(--chart-lightness) c calc(h + 0));
144
+ --chart-2: oklch(from var(--primary) var(--chart-lightness) calc(c * 0.65) calc(h + 35));
145
+ --chart-3: oklch(from var(--primary) var(--chart-lightness) c calc(h + 70));
146
+ --chart-4: oklch(from var(--primary) var(--chart-lightness) c calc(h + 105));
147
+ --chart-5: oklch(from var(--primary) var(--chart-lightness) c calc(h + 140));
115
148
  }
116
149
 
117
150
  .dark {
118
- --background: #040D20;
119
- --foreground: #FAFCFC;
120
- --card: #09142A;
121
- --card-foreground: #FAFCFC;
122
- --popover: #0E295E;
123
- --popover-foreground: #FAFCFC;
151
+ --background: oklch(0.1450 0 0);
152
+ --foreground: oklch(0.9850 0 0);
153
+ --card: oklch(0.2050 0 0);
154
+ --card-foreground: oklch(0.9850 0 0);
155
+ --popover: oklch(0.2690 0 0);
156
+ --popover-foreground: oklch(0.9850 0 0);
124
157
  --primary: #FAFAFA;
125
158
  --primary-foreground: #1F1F1F;
126
159
  --link: var(--primary);
127
- --secondary: #0A1D42;
128
- --secondary-foreground: #FAFCFC;
129
- --muted: #0A1D42;
130
- --muted-foreground: #B8D6E5;
131
- --accent: #0E295E;
132
- --accent-foreground: #FAFCFC;
160
+ --secondary: oklch(0.2690 0 0);
161
+ --secondary-foreground: oklch(0.9850 0 0);
162
+ --muted: oklch(0.2690 0 0);
163
+ --muted-foreground: oklch(0.7800 0 0);
164
+ --accent: oklch(0.3710 0 0);
165
+ --accent-foreground: oklch(0.9850 0 0);
133
166
  --destructive: oklch(0.7500 0.1600 22.2160);
134
167
  --destructive-foreground: oklch(0.1500 0 0);
135
- --border: rgb(255 255 255 / 0.10);
136
- --input: rgb(255 255 255 / 0.10);
137
- --ring: #B8D6E5;
138
- --chart-1: oklch(0.7800 0.1850 264.05);
139
- --chart-2: oklch(0.7000 0.2100 264.05);
140
- --chart-3: oklch(0.6200 0.1975 264.05);
141
- --chart-4: oklch(0.5600 0.1481 264.05);
142
- --chart-5: oklch(0.5200 0.0988 264.05);
143
- --sidebar: #09142A;
144
- --sidebar-foreground: #FAFCFC;
168
+ --border: oklch(0.5500 0 0);
169
+ --input: oklch(0.5500 0 0);
170
+ --ring: oklch(0.7000 0 0);
171
+ --chart-1: oklch(0.7800 0.1800 220);
172
+ --chart-2: oklch(0.8000 0.2000 145);
173
+ --chart-3: oklch(0.8500 0.2000 75);
174
+ --chart-4: oklch(0.7600 0.2200 340);
175
+ --chart-5: oklch(0.7800 0.1800 25);
176
+ --sidebar: oklch(0.1450 0 0);
177
+ --sidebar-foreground: oklch(0.9850 0 0);
145
178
  --sidebar-primary: oklch(0.4200 0.2000 264.3760);
146
- --sidebar-primary-foreground: #FAFCFC;
147
- --sidebar-accent: #0E295E;
148
- --sidebar-accent-foreground: #FAFCFC;
149
- --sidebar-border: #527081;
150
- --sidebar-ring: #B8D6E5;
179
+ --sidebar-primary-foreground: oklch(0.9850 0 0);
180
+ --sidebar-accent: oklch(0.2690 0 0);
181
+ --sidebar-accent-foreground: oklch(0.9850 0 0);
182
+ --sidebar-border: oklch(0.5500 0 0);
183
+ --sidebar-ring: oklch(0.7000 0 0);
151
184
 
152
185
  /* Chart palette (dark) — same derivation, mode-specific L floor for AAA. */
153
- --chart-1: oklch(from var(--primary) 0.78 c h);
154
- --chart-2: oklch(from var(--primary) 0.70 calc(c * 0.95) h);
155
- --chart-3: oklch(from var(--primary) 0.62 calc(c * 0.80) h);
156
- --chart-4: oklch(from var(--primary) 0.56 calc(c * 0.60) h);
157
- --chart-5: oklch(from var(--primary) 0.52 calc(c * 0.40) h);
186
+ --chart-lightness: 0.78;
187
+ --chart-1: oklch(from var(--primary) var(--chart-lightness) c calc(h + 0));
188
+ --chart-2: oklch(from var(--primary) var(--chart-lightness) calc(c * 0.65) calc(h + 35));
189
+ --chart-3: oklch(from var(--primary) var(--chart-lightness) c calc(h + 70));
190
+ --chart-4: oklch(from var(--primary) var(--chart-lightness) c calc(h + 105));
191
+ --chart-5: oklch(from var(--primary) var(--chart-lightness) c calc(h + 140));
158
192
  }
159
193
 
160
194
  @theme inline {
@@ -228,6 +262,9 @@
228
262
  --ease-out: var(--ease-out);
229
263
  --ease-in-out: var(--ease-in-out);
230
264
  --ease-spring: var(--ease-spring);
265
+ --ease-spring-gentle: var(--spring-gentle);
266
+ --ease-spring-snappy: var(--spring-snappy);
267
+ --ease-spring-bounce: var(--spring-bounce);
231
268
 
232
269
  /* Accessibility floor — minimum 14px for text-xs (vs Tailwind's 12px default).
233
270
  Font sizes are dynamically computed by useGlobalTypeScale hook and set as
@@ -279,7 +316,10 @@
279
316
  imports stylesheets in. Both rules live in @layer base; within a layer,
280
317
  specificity decides. `:root *` is (0,1,0), `*` is (0,0,0) — we win. Utility
281
318
  classes in @layer utilities still beat both because later layers trump
282
- specificity, so `border-red-500` and friends keep working normally. */
319
+ specificity, so `border-red-500` and friends keep working normally.
320
+ Without this bump, consumers who @import the design system BEFORE
321
+ tailwindcss get a cascade-order race where preflight wins and naked
322
+ `border` utilities render as text color (near-white on dark themes). */
283
323
  :root * {
284
324
  @apply border-border outline-ring/50;
285
325
  }
@@ -290,6 +330,11 @@
290
330
  fall through to system-ui regardless of the brand-font selection. */
291
331
  html {
292
332
  font-family: var(--font-sans);
333
+ /* Variable-font axis settings (Inter Variable ships by default). Sourced
334
+ from tokens.json → --font-variation-settings so forks tune optical
335
+ size / weight axes without touching component source. "normal" is a
336
+ no-op for static fonts. */
337
+ font-variation-settings: var(--font-variation-settings, normal);
293
338
  }
294
339
  /* Match: monospace elements pick up --font-mono without each component
295
340
  having to remember a `font-mono` class. */
@@ -323,23 +368,20 @@
323
368
  }
324
369
  /* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
325
370
  text. Scope to <p> only — UI primitives stay tight. Last-child has
326
- no trailing margin so containers don't get extra padding.
327
-
328
- The second rule bows out of flex / grid contexts because by the
329
- time an author has wrapped content in display:flex or display:grid,
330
- they are clearly building UI layout (rows of chips, tile metadata,
331
- calendar entries, etc.) and not running prose. Without this
332
- carve-out, every <p> used as a UI label inside a flex row gets
333
- an extra 1.5em margin-bottom, which silently inflates its margin
334
- box and breaks vertical alignment with adjacent items (a dot
335
- beside an uppercase eyebrow drops below the visible text, the
336
- classic symptom). The proper semantic fix is to use <span> for
337
- UI labels, but the design system shouldn't punish authors who
338
- reach for <p> in obvious UI contexts. Specificity 0,2,1 wins
339
- over the bare 0,1,1 rule above. */
371
+ no trailing margin so containers don't get extra padding. */
340
372
  p:not(:last-child) {
341
373
  margin-bottom: 1.5em;
342
374
  }
375
+ /* Flex / grid layout carve-out for the rule above. When <p> is used as
376
+ a UI label inside a flex row or grid cell, the 1.5em ghost margin-
377
+ bottom inflates its margin box, which drags its geometric center
378
+ down. items-center then aligns siblings (org-color dots, icons,
379
+ badges) to a lower y than the visible text. Zero the block margins
380
+ on <p> one level deep into any flex/grid container, and through one
381
+ wrapper, so authors who reach for <p> in obvious UI contexts don't
382
+ silently break alignment. Specificity ties the bare prose rule at
383
+ 0,1,1 — source order resolves the tie, which is why this block must
384
+ follow the rule above. */
343
385
  :is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) p,
344
386
  :is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) > * > p {
345
387
  margin-block: 0;
@@ -366,6 +408,54 @@
366
408
  scroll-behavior: auto !important;
367
409
  }
368
410
  }
411
+ /* Windows High Contrast Mode (forced-colors). Supports SC 1.4.1 (Use of
412
+ Color) and 1.4.11 (Non-text Contrast) for the ~3% of Windows users who
413
+ run HCM. When the OS forces its own palette it discards our custom
414
+ background fills — so a ghost/secondary Button, a selected tab, or a
415
+ checked control that relied on a background tint to read as distinct
416
+ collapses into the body text. The UA keeps token *borders* (mapping
417
+ them to system colors) but cannot invent a boundary where none was
418
+ drawn. These rules restore the structure the override drops; they do
419
+ NOT hardcode brand colors (that's forbidden) — they use the CSS
420
+ system-color keywords HCM actually honors. */
421
+ @media (forced-colors: active) {
422
+ /* Every interactive control gets a drawn boundary so it survives the
423
+ loss of its background fill. ButtonBorder is the system color the UA
424
+ uses for control edges. */
425
+ button,
426
+ [role="button"],
427
+ input,
428
+ select,
429
+ textarea {
430
+ border: 1px solid ButtonBorder;
431
+ }
432
+ /* Focus ring maps to the system Highlight so it is never invisible,
433
+ regardless of the user's chosen high-contrast theme. */
434
+ :focus-visible {
435
+ outline: 2px solid Highlight;
436
+ outline-offset: 2px;
437
+ }
438
+ /* Selected / checked / pressed / active states lose their background
439
+ tint under HCM. Opt out of forced-color-adjust for just these state
440
+ markers and paint the system Highlight so on/off stays legible on
441
+ toggles, switches, selected tabs, and checkboxes. */
442
+ [aria-selected="true"],
443
+ [aria-checked="true"],
444
+ [aria-pressed="true"],
445
+ [data-state="checked"],
446
+ [data-state="active"],
447
+ [data-state="on"] {
448
+ forced-color-adjust: none;
449
+ background-color: Highlight;
450
+ color: HighlightText;
451
+ }
452
+ /* Disabled controls should read as dimmed via the system GrayText color
453
+ rather than our muted token (which the override would flatten). */
454
+ :disabled,
455
+ [aria-disabled="true"] {
456
+ color: GrayText;
457
+ }
458
+ }
369
459
  }
370
460
 
371
461
  /* Global tracking offset — the Letter Spacing slider in the Customize
@@ -158,14 +158,14 @@
158
158
  },
159
159
  "fontFamily": {
160
160
  "sans": {
161
- "$value": "'Season', 'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui",
161
+ "$value": "'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui",
162
162
  "$type": "fontFamily",
163
- "$description": "Primary sans (body, UI). Season is the Swimtopia default \u2014 brand-forward with Hyperlegible Sans as the safe fallback."
163
+ "$description": "Primary sans (body, UI). Hyperlegible Sans is the BADS default \u2014 production-safe and accessibility-friendly. Override per client."
164
164
  },
165
165
  "serif": {
166
- "$value": "'Season Serif', 'Season', ui-serif, Georgia, serif",
166
+ "$value": "ui-serif, Georgia, serif",
167
167
  "$type": "fontFamily",
168
- "$description": "Primary serif stack. Season Serif is the Swimtopia default display face."
168
+ "$description": "Display/serif fallback stack. No default brand serif \u2014 clients should override."
169
169
  },
170
170
  "mono": {
171
171
  "$value": "'JetBrains Mono', ui-monospace, monospace",