@behavioral-agentic-design-system/core 0.5.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.
- package/LICENSE +21 -0
- package/package.json +39 -7
- package/scripts/bads-sync.mjs +1 -1
- package/scripts/build-fonts.cjs +97 -0
- package/scripts/build-tokens.cjs +202 -10
- package/src/api/brand-fonts.ts +301 -0
- package/src/api/brand-mark.ts +146 -0
- package/src/api/layers/file.ts +8 -5
- package/src/api/layers.ts +27 -4
- package/src/api/site-auth.ts +50 -0
- package/src/app/preview/cards/page.tsx +1 -1
- package/src/app/preview/components/page.tsx +78 -1
- package/src/app/preview/icons/page.tsx +5 -0
- package/src/app/shell.tsx +105 -39
- package/src/app/site-login/page.tsx +82 -0
- package/src/brand-fonts.css +5 -0
- package/src/components/Foundations/Motion.stories.tsx +66 -0
- package/src/components/brand-mark.tsx +64 -0
- package/src/components/customize/brand-mark-section.tsx +265 -0
- package/src/components/customize/font-pickers.tsx +293 -0
- package/src/components/customize/letter-spacing.tsx +3 -2
- package/src/components/customize/save-bar.tsx +11 -5
- package/src/components/customize/type-scale.tsx +3 -2
- package/src/components/customize-tab.tsx +330 -24
- package/src/components/dev-identity-badge.tsx +92 -0
- package/src/components/home-tab.tsx +1291 -380
- package/src/components/layers-tab.tsx +179 -12
- package/src/components/ui/alert.tsx +10 -2
- package/src/components/ui/bottom-sheet.tsx +124 -0
- package/src/components/ui/button.tsx +2 -2
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/chart.tsx +118 -7
- package/src/components/ui/checkbox.tsx +3 -2
- package/src/components/ui/dialog.tsx +3 -3
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/radio-group.tsx +4 -3
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/sidebar.tsx +6 -1
- package/src/components/ui/sonner.tsx +18 -0
- package/src/components/ui/switch.tsx +9 -3
- package/src/components/ui/tabs.tsx +7 -1
- package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
- package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
- package/src/fonts/InterVariable-Italic.woff2 +0 -0
- package/src/fonts/InterVariable.woff2 +0 -0
- package/src/fonts.css +99 -0
- package/src/hooks/use-global-brand-mark.ts +64 -0
- package/src/hooks/use-global-mono-font.ts +13 -3
- package/src/hooks/use-global-primary-color.ts +192 -9
- package/src/hooks/use-global-sans-font.ts +5 -3
- package/src/hooks/use-global-serif-font.ts +13 -3
- package/src/lib/storage.ts +29 -0
- package/src/lib/svg-sanitize.ts +272 -0
- package/src/styles.css +126 -6
- package/src/tokens.json +100 -9
- package/src/app/preview/mail/page.tsx +0 -4
- package/src/app/preview/pricing/page.tsx +0 -4
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.
|
|
3
|
+
"version": "0.7.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
|
-
"license": "
|
|
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",
|
|
@@ -16,12 +37,16 @@
|
|
|
16
37
|
],
|
|
17
38
|
"bin": {
|
|
18
39
|
"bads-build-tokens": "scripts/build-tokens.cjs",
|
|
40
|
+
"bads-build-fonts": "scripts/build-fonts.cjs",
|
|
19
41
|
"bads-sync": "scripts/bads-sync.mjs"
|
|
20
42
|
},
|
|
21
43
|
"exports": {
|
|
22
44
|
".": "./src/index.ts",
|
|
23
45
|
"./package.json": "./package.json",
|
|
24
46
|
"./styles.css": "./src/styles.css",
|
|
47
|
+
"./fonts.css": "./src/fonts.css",
|
|
48
|
+
"./brand-fonts.css": "./src/brand-fonts.css",
|
|
49
|
+
"./fonts/*": "./src/fonts/*",
|
|
25
50
|
"./tokens.json": "./src/tokens.json",
|
|
26
51
|
"./tokens.default.json": "./src/tokens.default.json",
|
|
27
52
|
"./lib/*": "./src/lib/*.ts",
|
|
@@ -32,6 +57,8 @@
|
|
|
32
57
|
"./components/home-tab": "./src/components/home-tab.tsx",
|
|
33
58
|
"./components/layers-tab": "./src/components/layers-tab.tsx",
|
|
34
59
|
"./components/bads-update-banner": "./src/components/bads-update-banner.tsx",
|
|
60
|
+
"./components/brand-mark": "./src/components/brand-mark.tsx",
|
|
61
|
+
"./components/dev-identity-badge": "./src/components/dev-identity-badge.tsx",
|
|
35
62
|
"./components/customize/*": "./src/components/customize/*.tsx",
|
|
36
63
|
"./components/Foundations/*": "./src/components/Foundations/*.tsx",
|
|
37
64
|
"./app/page": "./src/app/page.tsx",
|
|
@@ -52,19 +79,22 @@
|
|
|
52
79
|
"./api/layers": "./src/api/layers.ts",
|
|
53
80
|
"./api/layers/file": "./src/api/layers/file.ts",
|
|
54
81
|
"./api/save-tokens": "./src/api/save-tokens.ts",
|
|
55
|
-
"./api/brand-colors": "./src/api/brand-colors.ts"
|
|
82
|
+
"./api/brand-colors": "./src/api/brand-colors.ts",
|
|
83
|
+
"./api/brand-fonts": "./src/api/brand-fonts.ts",
|
|
84
|
+
"./api/brand-mark": "./src/api/brand-mark.ts"
|
|
56
85
|
},
|
|
57
86
|
"publishConfig": {
|
|
58
87
|
"access": "public"
|
|
59
88
|
},
|
|
60
89
|
"dependencies": {
|
|
90
|
+
"@xmldom/xmldom": "^0.9.10",
|
|
91
|
+
"class-variance-authority": "^0.7.0",
|
|
61
92
|
"clsx": "^2.1.0",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
93
|
+
"react-markdown": "^10.1.0",
|
|
94
|
+
"remark-gfm": "^4.0.1",
|
|
95
|
+
"tailwind-merge": "^3.0.0"
|
|
64
96
|
},
|
|
65
97
|
"peerDependencies": {
|
|
66
|
-
"react": ">=18",
|
|
67
|
-
"react-dom": ">=18",
|
|
68
98
|
"@radix-ui/react-avatar": "*",
|
|
69
99
|
"@radix-ui/react-checkbox": "*",
|
|
70
100
|
"@radix-ui/react-collapsible": "*",
|
|
@@ -87,7 +117,9 @@
|
|
|
87
117
|
"cmdk": "*",
|
|
88
118
|
"lucide-react": "*",
|
|
89
119
|
"next-themes": "*",
|
|
120
|
+
"react": ">=18",
|
|
90
121
|
"react-day-picker": "*",
|
|
122
|
+
"react-dom": ">=18",
|
|
91
123
|
"react-resizable-panels": "*",
|
|
92
124
|
"recharts": "*",
|
|
93
125
|
"sonner": "*"
|
package/scripts/bads-sync.mjs
CHANGED
|
@@ -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-
|
|
21
|
+
* - layer-1-foundation/, layer-2-ethics-responsibility/, layer-6-patterns-and-rules/
|
|
22
22
|
* - public/logos/, CLAUDE.md
|
|
23
23
|
*/
|
|
24
24
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Build brand-fonts.css from brand-fonts.json.
|
|
4
|
+
*
|
|
5
|
+
* brand-fonts.json → brand-fonts.css
|
|
6
|
+
*
|
|
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 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.
|
|
13
|
+
*
|
|
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.
|
|
19
|
+
*
|
|
20
|
+
* Run-from-consumer model: this script is invoked from a consumer repo's CWD
|
|
21
|
+
* (via `pnpm build:fonts` → `bads-build-fonts`). Paths resolve against
|
|
22
|
+
* process.cwd() so it works the same in upstream BADS and in client forks.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const fs = require('fs');
|
|
26
|
+
const path = require('path');
|
|
27
|
+
|
|
28
|
+
const ROOT = process.cwd();
|
|
29
|
+
const SOURCE = path.join(ROOT, 'brand-fonts.json');
|
|
30
|
+
const TARGET_DIR = path.join(ROOT, 'packages', 'core', 'src');
|
|
31
|
+
const TARGET = path.join(TARGET_DIR, 'brand-fonts.css');
|
|
32
|
+
|
|
33
|
+
const banner = `/* GENERATED FROM brand-fonts.json — DO NOT EDIT BY HAND.
|
|
34
|
+
* Run \`pnpm build:fonts\` after changing brand-fonts.json (this happens
|
|
35
|
+
* automatically when fonts are added/removed via the Customize tab). */`;
|
|
36
|
+
|
|
37
|
+
function readSource() {
|
|
38
|
+
if (!fs.existsSync(SOURCE)) {
|
|
39
|
+
return { fonts: [] };
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const raw = fs.readFileSync(SOURCE, 'utf8');
|
|
43
|
+
const parsed = JSON.parse(raw);
|
|
44
|
+
return { fonts: Array.isArray(parsed.fonts) ? parsed.fonts : [] };
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error(`build-fonts: failed to parse ${SOURCE}:`, err.message);
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function escapeFamily(label) {
|
|
52
|
+
// Family names with spaces or punctuation must be quoted in @font-face.
|
|
53
|
+
// Single-token alphanumeric labels can be unquoted but quoting always works.
|
|
54
|
+
return `'${String(label).replace(/'/g, "\\'")}'`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function emitFace(family, file) {
|
|
58
|
+
const format = file.format === 'woff' ? 'woff' : 'woff2';
|
|
59
|
+
const weight = file.weight ?? 400;
|
|
60
|
+
const style = file.style === 'italic' ? 'italic' : 'normal';
|
|
61
|
+
return `@font-face {
|
|
62
|
+
font-family: ${family};
|
|
63
|
+
src: url('${file.path}') format('${format}');
|
|
64
|
+
font-weight: ${weight};
|
|
65
|
+
font-style: ${style};
|
|
66
|
+
font-display: swap;
|
|
67
|
+
}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function emitFamily(font) {
|
|
71
|
+
const family = escapeFamily(font.label || font.id);
|
|
72
|
+
if (!Array.isArray(font.files) || font.files.length === 0) {
|
|
73
|
+
// Family registered without files — assumed to be loaded externally
|
|
74
|
+
// (the type allows this for forward-compat with hosted-font sources).
|
|
75
|
+
return `/* ${family} — registered without local files (loaded externally). */`;
|
|
76
|
+
}
|
|
77
|
+
const sectionHeader = `/* ============================================================
|
|
78
|
+
* ${family} — id: ${font.id}
|
|
79
|
+
* ============================================================ */`;
|
|
80
|
+
return [sectionHeader, ...font.files.map((f) => emitFace(family, f))].join('\n\n');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function build() {
|
|
84
|
+
const { fonts } = readSource();
|
|
85
|
+
const blocks = fonts.map(emitFamily).join('\n\n');
|
|
86
|
+
const body = blocks.trim().length > 0
|
|
87
|
+
? blocks
|
|
88
|
+
: '/* No brand fonts registered yet. Add one via the Customize tab → font picker → "+". */';
|
|
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 });
|
|
93
|
+
fs.writeFileSync(TARGET, out, 'utf8');
|
|
94
|
+
console.log(`✓ wrote ${path.relative(ROOT, TARGET)} (${fonts.length} ${fonts.length === 1 ? 'family' : 'families'})`);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
build();
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -56,9 +56,28 @@ if (!tokens.theme || !tokens.theme.light || !tokens.theme.dark) {
|
|
|
56
56
|
process.exit(1);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
// Resolve Tokens Studio aliases like `{color.primitive.slate.400}` to their
|
|
60
|
+
// final $value at build time. Supports nested aliases (an alias whose target
|
|
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.
|
|
64
|
+
function resolveAlias(value, depth = 0) {
|
|
65
|
+
if (typeof value !== 'string') return value;
|
|
66
|
+
const match = value.match(/^\{(.+)\}$/);
|
|
67
|
+
if (!match) return value;
|
|
68
|
+
if (depth > 8) {
|
|
69
|
+
throw new Error(`Token alias chain too deep — likely a cycle near "${value}"`);
|
|
70
|
+
}
|
|
71
|
+
const target = match[1].split('.').reduce((node, key) => node?.[key], tokens);
|
|
72
|
+
if (!target || target.$value === undefined) {
|
|
73
|
+
throw new Error(`Token alias "${value}" did not resolve to a token with $value`);
|
|
74
|
+
}
|
|
75
|
+
return resolveAlias(target.$value, depth + 1);
|
|
76
|
+
}
|
|
77
|
+
|
|
59
78
|
function emitVars(modeTokens) {
|
|
60
79
|
return Object.entries(modeTokens)
|
|
61
|
-
.map(([name, token]) => ` --${name}: ${token.$value};`)
|
|
80
|
+
.map(([name, token]) => ` --${name}: ${resolveAlias(token.$value)};`)
|
|
62
81
|
.join('\n');
|
|
63
82
|
}
|
|
64
83
|
|
|
@@ -67,6 +86,10 @@ const darkVars = emitVars(tokens.theme.dark);
|
|
|
67
86
|
const fontSans = tokens.fontFamily.sans.$value;
|
|
68
87
|
const fontMono = tokens.fontFamily.mono.$value;
|
|
69
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';
|
|
70
93
|
const radius = tokens.borderRadius?.lg?.$value ?? '0.625rem';
|
|
71
94
|
const spacing = tokens.theme?.light?.spacing?.$value ?? '0.25rem';
|
|
72
95
|
|
|
@@ -83,6 +106,15 @@ const easeIn = easing('ease-in', 'cubic-bezier(0.4, 0, 1, 1)');
|
|
|
83
106
|
const easeOut = easing('ease-out', 'cubic-bezier(0, 0, 0.2, 1)');
|
|
84
107
|
const easeInOut = easing('ease-in-out', 'cubic-bezier(0.4, 0, 0.2, 1)');
|
|
85
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)');
|
|
86
118
|
|
|
87
119
|
const fontSize = (key, fallback) => tokens.fontSize?.[key]?.$value ?? fallback;
|
|
88
120
|
const textXs = fontSize('xs', '14px');
|
|
@@ -140,7 +172,26 @@ const motionBlock = ` --duration-fast: ${durationFast};
|
|
|
140
172
|
--ease-in: ${easeIn};
|
|
141
173
|
--ease-out: ${easeOut};
|
|
142
174
|
--ease-in-out: ${easeInOut};
|
|
143
|
-
--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');
|
|
144
195
|
|
|
145
196
|
// Chart palette derives from --primary by default so all data viz tracks the
|
|
146
197
|
// brand color picker. Each chart-N reads --primary's hue and rotates around
|
|
@@ -163,17 +214,52 @@ const chartLightnessDark = tokens.chart?.lightness?.dark?.$value ?? '0.78';
|
|
|
163
214
|
const chartHue = (n, fallback) =>
|
|
164
215
|
tokens.chart?.hueRotation?.[`step${n}`]?.$value ?? fallback;
|
|
165
216
|
const chartChroma2 = tokens.chart?.chroma2Damping?.$value ?? '0.65';
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
217
|
+
|
|
218
|
+
// Optional per-step lightness and chroma. When defined in tokens.json the
|
|
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).
|
|
224
|
+
const stepL = (mode, n) =>
|
|
225
|
+
tokens.chart?.lightnessSteps?.[mode]?.[`step${n}`]?.$value;
|
|
226
|
+
const stepC = (n) => tokens.chart?.chromaSteps?.[`step${n}`]?.$value;
|
|
227
|
+
const hasLightSteps = [1, 2, 3, 4, 5].every((n) => stepL('light', n) !== undefined);
|
|
228
|
+
const hasDarkSteps = [1, 2, 3, 4, 5].every((n) => stepL('dark', n) !== undefined);
|
|
229
|
+
const hasChromaSteps = [1, 2, 3, 4, 5].every((n) => stepC(n) !== undefined);
|
|
230
|
+
|
|
231
|
+
const buildRamp = (mode, lightnessFallback) => {
|
|
232
|
+
const useSteps = mode === 'light' ? hasLightSteps : hasDarkSteps;
|
|
233
|
+
if (!useSteps) {
|
|
234
|
+
// Legacy: single L, hue rotation, chroma2 damping on series 2.
|
|
235
|
+
return ` --chart-lightness: ${lightnessFallback};
|
|
169
236
|
--chart-1: oklch(from var(--primary) var(--chart-lightness) c calc(h + ${chartHue(1, '0')}));
|
|
170
237
|
--chart-2: oklch(from var(--primary) var(--chart-lightness) calc(c * ${chartChroma2}) calc(h + ${chartHue(2, '35')}));
|
|
171
238
|
--chart-3: oklch(from var(--primary) var(--chart-lightness) c calc(h + ${chartHue(3, '70')}));
|
|
172
239
|
--chart-4: oklch(from var(--primary) var(--chart-lightness) c calc(h + ${chartHue(4, '105')}));
|
|
173
240
|
--chart-5: oklch(from var(--primary) var(--chart-lightness) c calc(h + ${chartHue(5, '140')}));`;
|
|
241
|
+
}
|
|
242
|
+
const cExpr = (n) => {
|
|
243
|
+
const m = hasChromaSteps ? stepC(n) : null;
|
|
244
|
+
return m && m !== '1.00' && m !== '1' ? `calc(c * ${m})` : 'c';
|
|
245
|
+
};
|
|
246
|
+
const hExpr = (n) => {
|
|
247
|
+
const r = chartHue(n, '0');
|
|
248
|
+
return r === '0' ? 'h' : `calc(h + ${r})`;
|
|
249
|
+
};
|
|
250
|
+
return ` --chart-1: oklch(from var(--primary) ${stepL(mode, 1)} ${cExpr(1)} ${hExpr(1)});
|
|
251
|
+
--chart-2: oklch(from var(--primary) ${stepL(mode, 2)} ${cExpr(2)} ${hExpr(2)});
|
|
252
|
+
--chart-3: oklch(from var(--primary) ${stepL(mode, 3)} ${cExpr(3)} ${hExpr(3)});
|
|
253
|
+
--chart-4: oklch(from var(--primary) ${stepL(mode, 4)} ${cExpr(4)} ${hExpr(4)});
|
|
254
|
+
--chart-5: oklch(from var(--primary) ${stepL(mode, 5)} ${cExpr(5)} ${hExpr(5)});`;
|
|
255
|
+
};
|
|
174
256
|
|
|
175
|
-
const
|
|
176
|
-
|
|
257
|
+
const chartDerivationLight = ` /* Chart palette — derives from --primary so brand changes propagate.
|
|
258
|
+
Override individual --chart-N inline (documentElement.style) to opt out. */
|
|
259
|
+
${buildRamp('light', chartLightnessLight)}`;
|
|
260
|
+
|
|
261
|
+
const chartDerivationDark = ` /* Chart palette (dark) — same derivation, mode-specific L floor for AAA. */
|
|
262
|
+
${buildRamp('dark', chartLightnessDark)}`;
|
|
177
263
|
|
|
178
264
|
const themeInline = `@theme inline {
|
|
179
265
|
--color-background: var(--background);
|
|
@@ -184,6 +270,7 @@ const themeInline = `@theme inline {
|
|
|
184
270
|
--color-popover-foreground: var(--popover-foreground);
|
|
185
271
|
--color-primary: var(--primary);
|
|
186
272
|
--color-primary-foreground: var(--primary-foreground);
|
|
273
|
+
--color-link: var(--link);
|
|
187
274
|
--color-secondary: var(--secondary);
|
|
188
275
|
--color-secondary-foreground: var(--secondary-foreground);
|
|
189
276
|
--color-muted: var(--muted);
|
|
@@ -245,6 +332,9 @@ const themeInline = `@theme inline {
|
|
|
245
332
|
--ease-out: var(--ease-out);
|
|
246
333
|
--ease-in-out: var(--ease-in-out);
|
|
247
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);
|
|
248
338
|
|
|
249
339
|
/* Accessibility floor — minimum 14px for text-xs (vs Tailwind's 12px default).
|
|
250
340
|
Font sizes are dynamically computed by useGlobalTypeScale hook and set as
|
|
@@ -290,7 +380,17 @@ const themeInline = `@theme inline {
|
|
|
290
380
|
}`;
|
|
291
381
|
|
|
292
382
|
const baseLayer = `@layer base {
|
|
293
|
-
|
|
383
|
+
/* Selector is \`:root *\` rather than the more obvious \`*\` so this rule beats
|
|
384
|
+
Tailwind's preflight \`* { border: 0 solid }\` (which resets border-color to
|
|
385
|
+
currentColor = the text color) regardless of which order the consumer
|
|
386
|
+
imports stylesheets in. Both rules live in @layer base; within a layer,
|
|
387
|
+
specificity decides. \`:root *\` is (0,1,0), \`*\` is (0,0,0) — we win. Utility
|
|
388
|
+
classes in @layer utilities still beat both because later layers trump
|
|
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). */
|
|
393
|
+
:root * {
|
|
294
394
|
@apply border-border outline-ring/50;
|
|
295
395
|
}
|
|
296
396
|
/* Bind html to --font-sans so the picker propagates everywhere — not just
|
|
@@ -300,6 +400,11 @@ const baseLayer = `@layer base {
|
|
|
300
400
|
fall through to system-ui regardless of the brand-font selection. */
|
|
301
401
|
html {
|
|
302
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);
|
|
303
408
|
}
|
|
304
409
|
/* Match: monospace elements pick up --font-mono without each component
|
|
305
410
|
having to remember a \`font-mono\` class. */
|
|
@@ -337,6 +442,20 @@ const baseLayer = `@layer base {
|
|
|
337
442
|
p:not(:last-child) {
|
|
338
443
|
margin-bottom: 1.5em;
|
|
339
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. */
|
|
455
|
+
:is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) p,
|
|
456
|
+
:is(.flex, .inline-flex, .grid, .inline-grid, [class*="grid-cols"]) > * > p {
|
|
457
|
+
margin-block: 0;
|
|
458
|
+
}
|
|
340
459
|
/* WCAG AAA 2.4.13 Focus Appearance: focus indicator must be ≥ 2 CSS
|
|
341
460
|
pixels thick AND have ≥ 3:1 contrast against adjacent colors. The
|
|
342
461
|
--ring token is luminance-tuned for 3:1 against every surface in
|
|
@@ -359,6 +478,54 @@ const baseLayer = `@layer base {
|
|
|
359
478
|
scroll-behavior: auto !important;
|
|
360
479
|
}
|
|
361
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
|
+
}
|
|
362
529
|
}
|
|
363
530
|
|
|
364
531
|
/* Global tracking offset — the Letter Spacing slider in the Customize
|
|
@@ -415,8 +582,26 @@ const pkgCss = `${banner}
|
|
|
415
582
|
* Override any token by re-declaring it after this @import.
|
|
416
583
|
*/
|
|
417
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');
|
|
418
590
|
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
|
|
419
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
|
+
|
|
420
605
|
/* Tailwind v4 only generates classes it scans. The shell components, hooks,
|
|
421
606
|
* and app routes shipped in this package use plenty of Tailwind classes that
|
|
422
607
|
* the consumer's own source code never references — Button's variants,
|
|
@@ -441,6 +626,7 @@ const pkgCss = `${banner}
|
|
|
441
626
|
--font-sans: ${fontSans}, 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
|
|
442
627
|
--font-mono: ${fontMono};
|
|
443
628
|
--font-serif: ${fontSerif};
|
|
629
|
+
--font-variation-settings: ${fontVariationSettings};
|
|
444
630
|
--font-size-scale: 1;
|
|
445
631
|
|
|
446
632
|
${lightVars}
|
|
@@ -448,6 +634,7 @@ ${lightVars}
|
|
|
448
634
|
--radius: ${radius};
|
|
449
635
|
${shadowBlock}
|
|
450
636
|
${motionBlock}
|
|
637
|
+
${motionSemanticBlock}
|
|
451
638
|
--spacing: ${spacing};
|
|
452
639
|
|
|
453
640
|
${chartDerivationLight}
|
|
@@ -476,7 +663,10 @@ console.log(`✓ wrote ${path.relative(ROOT, PKG_CSS)}`);
|
|
|
476
663
|
// @import so consumers without next/font still get the canonical theme.
|
|
477
664
|
const appCss = `${banner}
|
|
478
665
|
|
|
479
|
-
|
|
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";
|
|
480
670
|
@import "tailwindcss";
|
|
481
671
|
@import "tw-animate-css";
|
|
482
672
|
|
|
@@ -492,9 +682,10 @@ const appCss = `${banner}
|
|
|
492
682
|
undefined, and a bare var() reference invalidates the entire
|
|
493
683
|
custom-property value at computed-value time, leaving --font-sans
|
|
494
684
|
empty and text falling through to browser default ("Times"). */
|
|
495
|
-
--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;
|
|
496
686
|
--font-serif: ${fontSerif}, var(--font-source-serif, 'Source Serif 4'), 'Source Serif 4', Georgia, ui-serif, serif;
|
|
497
687
|
--font-mono: ${fontMono}, var(--font-jetbrains, 'JetBrains Mono'), 'JetBrains Mono', ui-monospace, monospace;
|
|
688
|
+
--font-variation-settings: ${fontVariationSettings};
|
|
498
689
|
--font-size-scale: 1;
|
|
499
690
|
|
|
500
691
|
${lightVars}
|
|
@@ -502,6 +693,7 @@ ${lightVars}
|
|
|
502
693
|
--radius: ${radius};
|
|
503
694
|
${shadowBlock}
|
|
504
695
|
${motionBlock}
|
|
696
|
+
${motionSemanticBlock}
|
|
505
697
|
--spacing: ${spacing};
|
|
506
698
|
|
|
507
699
|
${chartDerivationLight}
|