@behavioral-agentic-design-system/core 0.2.1 → 0.3.1

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 (49) hide show
  1. package/package.json +37 -4
  2. package/scripts/bads-sync.mjs +81 -0
  3. package/scripts/build-tokens.cjs +487 -0
  4. package/src/api/bads-update-check.ts +151 -0
  5. package/src/api/brand-colors.ts +180 -0
  6. package/src/api/layers/file.ts +71 -0
  7. package/src/api/layers.ts +49 -0
  8. package/src/api/save-tokens.ts +280 -0
  9. package/src/app/font-ready.tsx +51 -0
  10. package/src/app/layout.tsx +152 -0
  11. package/src/app/page.tsx +267 -0
  12. package/src/app/preview/cards/page.tsx +8 -0
  13. package/src/app/preview/components/page.tsx +232 -0
  14. package/src/app/preview/dark-mode-client.tsx +24 -0
  15. package/src/app/preview/dashboard/page.tsx +4 -0
  16. package/src/app/preview/global-font-client.tsx +36 -0
  17. package/src/app/preview/layout.tsx +13 -0
  18. package/src/app/preview/mail/page.tsx +4 -0
  19. package/src/app/preview/pricing/page.tsx +4 -0
  20. package/src/app/preview/typography/page.tsx +11 -0
  21. package/src/app/providers.tsx +49 -0
  22. package/src/components/Foundations/Colors.stories.tsx +85 -0
  23. package/src/components/Foundations/Motion.stories.tsx +169 -0
  24. package/src/components/Foundations/Radius.stories.tsx +36 -0
  25. package/src/components/Foundations/Shadows.stories.tsx +30 -0
  26. package/src/components/Foundations/Spacing.stories.tsx +35 -0
  27. package/src/components/Foundations/Typography.stories.tsx +68 -0
  28. package/src/components/bads-update-banner.tsx +120 -0
  29. package/src/components/customize/design-controls.tsx +165 -0
  30. package/src/components/customize/font-pickers.tsx +118 -0
  31. package/src/components/customize/letter-spacing.tsx +105 -0
  32. package/src/components/customize/save-bar.tsx +379 -0
  33. package/src/components/customize/theme-io.tsx +245 -0
  34. package/src/components/customize/type-scale.tsx +134 -0
  35. package/src/components/customize-tab.tsx +502 -0
  36. package/src/components/home-tab.tsx +1227 -0
  37. package/src/components/layers-tab.tsx +225 -0
  38. package/src/components/ui/alert.tsx +5 -1
  39. package/src/hooks/use-global-design-controls.ts +117 -0
  40. package/src/hooks/use-global-mono-font.ts +73 -0
  41. package/src/hooks/use-global-primary-color.ts +544 -0
  42. package/src/hooks/use-global-sans-font.ts +98 -0
  43. package/src/hooks/use-global-serif-font.ts +77 -0
  44. package/src/hooks/use-global-theme.ts +259 -0
  45. package/src/hooks/use-global-type-scale.ts +141 -0
  46. package/src/hooks/use-sync-type-scale.ts +51 -0
  47. package/src/hooks/use-token-overrides.ts +98 -0
  48. package/src/styles.css +40 -6
  49. package/src/tokens.json +86 -5
package/src/styles.css CHANGED
@@ -77,12 +77,19 @@
77
77
  --shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / var(--shadow-opacity)), 0 4px 6px -1px hsl(0 0% 0% / var(--shadow-opacity));
78
78
  --shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / var(--shadow-opacity)), 0 8px 10px -1px hsl(0 0% 0% / var(--shadow-opacity));
79
79
  --shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / calc(var(--shadow-opacity) * 2.5));
80
+ --duration-fast: 150ms;
81
+ --duration-base: 200ms;
82
+ --duration-slow: 300ms;
83
+ --ease-in: cubic-bezier(0.4, 0, 1, 1);
84
+ --ease-out: cubic-bezier(0, 0, 0.2, 1);
85
+ --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
86
+ --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
80
87
  --spacing: 0.25rem;
81
88
 
82
89
  /* Chart palette — derives from --primary so brand changes propagate.
83
90
  Override individual --chart-N inline (documentElement.style) to opt out. */
84
91
  --chart-lightness: 0.58;
85
- --chart-1: oklch(from var(--primary) var(--chart-lightness) c h);
92
+ --chart-1: oklch(from var(--primary) var(--chart-lightness) c calc(h + 0));
86
93
  --chart-2: oklch(from var(--primary) var(--chart-lightness) calc(c * 0.65) calc(h + 35));
87
94
  --chart-3: oklch(from var(--primary) var(--chart-lightness) c calc(h + 70));
88
95
  --chart-4: oklch(from var(--primary) var(--chart-lightness) c calc(h + 105));
@@ -183,17 +190,29 @@
183
190
  --shadow-xl: var(--shadow-xl);
184
191
  --shadow-2xl: var(--shadow-2xl);
185
192
 
193
+ /* Animation token layer. Sourced from tokens.json (duration / easing).
194
+ Components use these via Tailwind utilities — duration-base,
195
+ ease-spring, etc. — or the raw var(--duration-base) / var(--ease-out)
196
+ when classnames don't fit. Single source of truth for motion. */
197
+ --duration-fast: var(--duration-fast);
198
+ --duration-base: var(--duration-base);
199
+ --duration-slow: var(--duration-slow);
200
+ --ease-in: var(--ease-in);
201
+ --ease-out: var(--ease-out);
202
+ --ease-in-out: var(--ease-in-out);
203
+ --ease-spring: var(--ease-spring);
204
+
186
205
  /* Accessibility floor — minimum 14px for text-xs (vs Tailwind's 12px default).
187
206
  Font sizes are dynamically computed by useGlobalTypeScale hook and set as
188
207
  --text-xs-size, --text-sm-size, etc. These are then scaled by --font-size-scale
189
208
  (1 = 100%, 0.8 = 80%, etc) so the Customize tab slider affects all text. */
190
209
  --text-xs: calc(var(--text-xs-size, 14px) * var(--font-size-scale, 1));
191
210
  --text-sm: calc(var(--text-sm-size, 16px) * var(--font-size-scale, 1));
192
- --text-base: calc(var(--text-base-size, 18px) * var(--font-size-scale, 1));
193
- --text-lg: calc(var(--text-lg-size, 20px) * var(--font-size-scale, 1));
194
- --text-xl: calc(var(--text-xl-size, 24px) * var(--font-size-scale, 1));
195
- --text-2xl: calc(var(--text-2xl-size, 28px) * var(--font-size-scale, 1));
196
- --text-3xl: calc(var(--text-3xl-size, 32px) * var(--font-size-scale, 1));
211
+ --text-base: calc(var(--text-base-size, 20px) * var(--font-size-scale, 1));
212
+ --text-lg: calc(var(--text-lg-size, 25px) * var(--font-size-scale, 1));
213
+ --text-xl: calc(var(--text-xl-size, 31.25px) * var(--font-size-scale, 1));
214
+ --text-2xl: calc(var(--text-2xl-size, 39.06px) * var(--font-size-scale, 1));
215
+ --text-3xl: calc(var(--text-3xl-size, 48.83px) * var(--font-size-scale, 1));
197
216
 
198
217
  /* Marketing tier — display sizes for landing pages, hero blocks, editorial.
199
218
  Tailwind only emits utilities that get used, so a non-marketing fork pays
@@ -239,6 +258,21 @@
239
258
  /* WCAG AAA 1.4.8: avoid full-justified body — uneven word spacing
240
259
  hurts readability. Components opt-in to justify only when needed. */
241
260
  text-align: start;
261
+ /* Fade body in once fonts are ready. The boot script in app/layout.tsx
262
+ toggles .fonts-loading / .fonts-loaded on <html>. Cached loads bypass
263
+ the gate entirely (instant paint); first uncached loads briefly hide
264
+ body until document.fonts.ready resolves, then fade in. Eliminates
265
+ the FOUT "jump" as web fonts swap in over system-ui fallback. */
266
+ opacity: 1;
267
+ transition: opacity 200ms ease-out;
268
+ }
269
+ html.fonts-loading body {
270
+ opacity: 0;
271
+ }
272
+ /* Reduced-motion: never animate the fade — show body immediately when
273
+ the gate releases. Honors SC 2.3.3. */
274
+ @media (prefers-reduced-motion: reduce) {
275
+ body { transition: none; }
242
276
  }
243
277
  /* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
244
278
  text. Scope to <p> only — UI primitives stay tight. Last-child has
package/src/tokens.json CHANGED
@@ -185,24 +185,24 @@
185
185
  "$description": "Secondary text. Sits just under body."
186
186
  },
187
187
  "base": {
188
- "$value": "18px",
188
+ "$value": "20px",
189
189
  "$type": "dimension",
190
190
  "$description": "Body text baseline. Default type scale computes from this."
191
191
  },
192
192
  "lg": {
193
- "$value": "20px",
193
+ "$value": "25px",
194
194
  "$type": "dimension"
195
195
  },
196
196
  "xl": {
197
- "$value": "24px",
197
+ "$value": "31.25px",
198
198
  "$type": "dimension"
199
199
  },
200
200
  "2xl": {
201
- "$value": "28px",
201
+ "$value": "39.06px",
202
202
  "$type": "dimension"
203
203
  },
204
204
  "3xl": {
205
- "$value": "32px",
205
+ "$value": "48.83px",
206
206
  "$type": "dimension"
207
207
  },
208
208
  "4xl": {
@@ -356,6 +356,43 @@
356
356
  "xl": {
357
357
  "$value": "0 1px 3px 0px hsl(0 0% 0% / 0.10), 0 8px 10px -1px hsl(0 0% 0% / 0.10)",
358
358
  "$type": "shadow"
359
+ },
360
+ "opacity": {
361
+ "$value": "0.10",
362
+ "$type": "number",
363
+ "$description": "Base alpha for hsl-driven shadows. Customize tab Shadow Opacity slider overrides at runtime via documentElement.style.--shadow-opacity. Each shadow level (2xs, xs, sm, md, lg, xl, 2xl) scales this base by its opacityMultiplier."
364
+ },
365
+ "opacityMultiplier": {
366
+ "2xs": {
367
+ "$value": "0.5",
368
+ "$type": "number",
369
+ "$description": "Soft edge — subtle UI accents."
370
+ },
371
+ "xs": {
372
+ "$value": "0.5",
373
+ "$type": "number"
374
+ },
375
+ "sm": {
376
+ "$value": "1.0",
377
+ "$type": "number"
378
+ },
379
+ "md": {
380
+ "$value": "1.0",
381
+ "$type": "number"
382
+ },
383
+ "lg": {
384
+ "$value": "1.0",
385
+ "$type": "number"
386
+ },
387
+ "xl": {
388
+ "$value": "1.0",
389
+ "$type": "number"
390
+ },
391
+ "2xl": {
392
+ "$value": "2.5",
393
+ "$type": "number",
394
+ "$description": "Deep drop — modal / overlay surfaces."
395
+ }
359
396
  }
360
397
  },
361
398
  "breakpoint": {
@@ -1030,5 +1067,49 @@
1030
1067
  "$description": "AAA non-text 3:1 on dark sidebar."
1031
1068
  }
1032
1069
  }
1070
+ },
1071
+ "chart": {
1072
+ "lightness": {
1073
+ "light": {
1074
+ "$value": "0.58",
1075
+ "$type": "number",
1076
+ "$description": "Absolute L for chart series in light mode (oklch). Tuned so all five series sit at readable contrast on white card surfaces."
1077
+ },
1078
+ "dark": {
1079
+ "$value": "0.78",
1080
+ "$type": "number",
1081
+ "$description": "Absolute L for chart series in dark mode. Lifted from light so charts stay legible on near-black backgrounds."
1082
+ }
1083
+ },
1084
+ "hueRotation": {
1085
+ "step1": {
1086
+ "$value": "0",
1087
+ "$type": "number",
1088
+ "$description": "Series 1 — hue inherited from --primary as-is."
1089
+ },
1090
+ "step2": {
1091
+ "$value": "35",
1092
+ "$type": "number",
1093
+ "$description": "Series 2 — primary hue + 35deg, chroma damped to 0.65× for pairing."
1094
+ },
1095
+ "step3": {
1096
+ "$value": "70",
1097
+ "$type": "number"
1098
+ },
1099
+ "step4": {
1100
+ "$value": "105",
1101
+ "$type": "number"
1102
+ },
1103
+ "step5": {
1104
+ "$value": "140",
1105
+ "$type": "number",
1106
+ "$description": "Series 5 — final hue rotation, max separation from primary."
1107
+ }
1108
+ },
1109
+ "chroma2Damping": {
1110
+ "$value": "0.65",
1111
+ "$type": "number",
1112
+ "$description": "Chroma multiplier on series 2 only (others inherit primary chroma)."
1113
+ }
1033
1114
  }
1034
1115
  }