@behavioral-agentic-design-system/core 0.2.0 → 0.3.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/package.json +36 -5
- package/scripts/bads-sync.mjs +81 -0
- package/scripts/build-tokens.cjs +430 -0
- package/src/app/font-ready.tsx +51 -0
- package/src/app/layout.tsx +152 -0
- package/src/app/page.tsx +267 -0
- package/src/app/preview/cards/page.tsx +8 -0
- package/src/app/preview/components/page.tsx +232 -0
- package/src/app/preview/dark-mode-client.tsx +24 -0
- package/src/app/preview/dashboard/page.tsx +4 -0
- package/src/app/preview/global-font-client.tsx +36 -0
- package/src/app/preview/layout.tsx +13 -0
- package/src/app/preview/mail/page.tsx +4 -0
- package/src/app/preview/pricing/page.tsx +4 -0
- package/src/app/preview/typography/page.tsx +11 -0
- package/src/app/providers.tsx +49 -0
- package/src/components/Foundations/Colors.stories.tsx +85 -0
- package/src/components/Foundations/Motion.stories.tsx +169 -0
- package/src/components/Foundations/Radius.stories.tsx +36 -0
- package/src/components/Foundations/Shadows.stories.tsx +30 -0
- package/src/components/Foundations/Spacing.stories.tsx +35 -0
- package/src/components/Foundations/Typography.stories.tsx +68 -0
- package/src/components/bads-update-banner.tsx +120 -0
- package/src/components/customize/design-controls.tsx +165 -0
- package/src/components/customize/font-pickers.tsx +118 -0
- package/src/components/customize/letter-spacing.tsx +105 -0
- package/src/components/customize/save-bar.tsx +379 -0
- package/src/components/customize/theme-io.tsx +245 -0
- package/src/components/customize/type-scale.tsx +134 -0
- package/src/components/customize-tab.tsx +502 -0
- package/src/components/home-tab.tsx +1227 -0
- package/src/components/layers-tab.tsx +225 -0
- package/src/components/ui/alert.tsx +5 -1
- package/src/hooks/use-global-design-controls.ts +117 -0
- package/src/hooks/use-global-mono-font.ts +73 -0
- package/src/hooks/use-global-primary-color.ts +544 -0
- package/src/hooks/use-global-sans-font.ts +98 -0
- package/src/hooks/use-global-serif-font.ts +77 -0
- package/src/hooks/use-global-theme.ts +259 -0
- package/src/hooks/use-global-type-scale.ts +141 -0
- package/src/hooks/use-sync-type-scale.ts +51 -0
- package/src/hooks/use-token-overrides.ts +98 -0
- package/src/styles.css +20 -5
- package/src/tokens.json +5 -5
package/package.json
CHANGED
|
@@ -1,21 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "BADS core — tokens
|
|
3
|
+
"version": "0.3.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
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"sideEffects":
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"**/*.css",
|
|
9
|
+
"./src/app/**",
|
|
10
|
+
"./src/app/preview/**"
|
|
11
|
+
],
|
|
8
12
|
"files": [
|
|
9
13
|
"src",
|
|
14
|
+
"scripts",
|
|
10
15
|
"README.md"
|
|
11
16
|
],
|
|
17
|
+
"bin": {
|
|
18
|
+
"bads-build-tokens": "scripts/build-tokens.cjs",
|
|
19
|
+
"bads-sync": "scripts/bads-sync.mjs"
|
|
20
|
+
},
|
|
12
21
|
"exports": {
|
|
13
22
|
".": "./src/index.ts",
|
|
23
|
+
"./package.json": "./package.json",
|
|
14
24
|
"./styles.css": "./src/styles.css",
|
|
15
25
|
"./tokens.json": "./src/tokens.json",
|
|
16
|
-
"./
|
|
26
|
+
"./tokens.default.json": "./src/tokens.default.json",
|
|
27
|
+
"./lib/*": "./src/lib/*.ts",
|
|
17
28
|
"./hooks/*": "./src/hooks/*.ts",
|
|
18
|
-
"./components/ui
|
|
29
|
+
"./components/ui": "./src/components/ui/index.ts",
|
|
30
|
+
"./components/ui/*": "./src/components/ui/*.tsx",
|
|
31
|
+
"./components/customize-tab": "./src/components/customize-tab.tsx",
|
|
32
|
+
"./components/home-tab": "./src/components/home-tab.tsx",
|
|
33
|
+
"./components/layers-tab": "./src/components/layers-tab.tsx",
|
|
34
|
+
"./components/bads-update-banner": "./src/components/bads-update-banner.tsx",
|
|
35
|
+
"./components/customize/*": "./src/components/customize/*.tsx",
|
|
36
|
+
"./components/Foundations/*": "./src/components/Foundations/*.tsx",
|
|
37
|
+
"./app/page": "./src/app/page.tsx",
|
|
38
|
+
"./app/layout": "./src/app/layout.tsx",
|
|
39
|
+
"./app/providers": "./src/app/providers.tsx",
|
|
40
|
+
"./app/font-ready": "./src/app/font-ready.tsx",
|
|
41
|
+
"./app/preview/layout": "./src/app/preview/layout.tsx",
|
|
42
|
+
"./app/preview/dark-mode-client": "./src/app/preview/dark-mode-client.tsx",
|
|
43
|
+
"./app/preview/global-font-client": "./src/app/preview/global-font-client.tsx",
|
|
44
|
+
"./app/preview/cards/page": "./src/app/preview/cards/page.tsx",
|
|
45
|
+
"./app/preview/components/page": "./src/app/preview/components/page.tsx",
|
|
46
|
+
"./app/preview/dashboard/page": "./src/app/preview/dashboard/page.tsx",
|
|
47
|
+
"./app/preview/mail/page": "./src/app/preview/mail/page.tsx",
|
|
48
|
+
"./app/preview/pricing/page": "./src/app/preview/pricing/page.tsx",
|
|
49
|
+
"./app/preview/typography/page": "./src/app/preview/typography/page.tsx"
|
|
19
50
|
},
|
|
20
51
|
"publishConfig": {
|
|
21
52
|
"access": "public"
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* bads:sync — pull the latest BADS package into a client fork.
|
|
4
|
+
*
|
|
5
|
+
* As of @core 0.3.0 the template shell (app routes, customize tab, theme
|
|
6
|
+
* hooks, build-tokens) ships in the package itself. Client forks become
|
|
7
|
+
* thin re-exports, so a sync is now nothing more than:
|
|
8
|
+
*
|
|
9
|
+
* pnpm update @behavioral-agentic-design-system/core --latest
|
|
10
|
+
* pnpm build:tokens
|
|
11
|
+
*
|
|
12
|
+
* Usage (from a client fork):
|
|
13
|
+
*
|
|
14
|
+
* pnpm bads:sync # update to latest
|
|
15
|
+
* pnpm bads:sync --check # dry-run, prints what would change
|
|
16
|
+
* pnpm bads:sync --version=0.3.0 # pin a specific version
|
|
17
|
+
*
|
|
18
|
+
* What it does NOT touch:
|
|
19
|
+
* - brand.config.ts, brand-colors.json, packages/core/src/tokens.json
|
|
20
|
+
* - styles/client-extras.css (your local CSS additions)
|
|
21
|
+
* - layer-1-brand-voice/, layer-2-ethics-responsibility/, layer-6-patterns-and-rules/
|
|
22
|
+
* - public/logos/, CLAUDE.md
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { execSync } from 'node:child_process';
|
|
26
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
27
|
+
import { resolve } from 'node:path';
|
|
28
|
+
|
|
29
|
+
const ROOT = process.cwd();
|
|
30
|
+
|
|
31
|
+
const args = process.argv.slice(2);
|
|
32
|
+
const dryRun = args.includes('--check');
|
|
33
|
+
const versionArg = args.find((a) => a.startsWith('--version='));
|
|
34
|
+
const pinnedVersion = versionArg ? versionArg.split('=')[1] : null;
|
|
35
|
+
|
|
36
|
+
function run(cmd) {
|
|
37
|
+
if (dryRun) {
|
|
38
|
+
console.log(`[dry-run] ${cmd}`);
|
|
39
|
+
return '';
|
|
40
|
+
}
|
|
41
|
+
return execSync(cmd, { cwd: ROOT, stdio: 'inherit' });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function read(file) {
|
|
45
|
+
return existsSync(file) ? readFileSync(file, 'utf8') : '';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function detectUpstream() {
|
|
49
|
+
const pkg = JSON.parse(read(resolve(ROOT, 'package.json')) || '{}');
|
|
50
|
+
const isUpstreamName = pkg.name === 'behavioral-agentic-design-system';
|
|
51
|
+
const hasClientIdentity = existsSync(resolve(ROOT, '.client-identity.json'));
|
|
52
|
+
return isUpstreamName && !hasClientIdentity;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function main() {
|
|
56
|
+
console.log('▸ bads:sync');
|
|
57
|
+
|
|
58
|
+
if (detectUpstream()) {
|
|
59
|
+
console.log('this is upstream BADS itself — nothing to sync.');
|
|
60
|
+
console.log('(client forks have a .client-identity.json or a renamed package.json)');
|
|
61
|
+
process.exit(0);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (pinnedVersion) {
|
|
65
|
+
console.log(`▸ pinning @behavioral-agentic-design-system/core to ${pinnedVersion}`);
|
|
66
|
+
run(`pnpm add @behavioral-agentic-design-system/core@${pinnedVersion}`);
|
|
67
|
+
} else {
|
|
68
|
+
console.log('▸ updating @behavioral-agentic-design-system/core to latest');
|
|
69
|
+
run('pnpm update @behavioral-agentic-design-system/core --latest');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
console.log('▸ regenerating tokens');
|
|
73
|
+
run('pnpm build:tokens');
|
|
74
|
+
|
|
75
|
+
console.log('\n✓ bads:sync complete');
|
|
76
|
+
console.log('next:');
|
|
77
|
+
console.log(' - run `pnpm dev` and walk the preview routes');
|
|
78
|
+
console.log(' - if anything looks off, check the BADS CHANGELOG');
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
main();
|
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Build CSS files from tokens.json.
|
|
4
|
+
*
|
|
5
|
+
* tokens.json → packages/core/src/styles.css (published, consumer-facing)
|
|
6
|
+
* → styles/globals.css (preview app)
|
|
7
|
+
*
|
|
8
|
+
* tokens.json is the source of truth. Edit values there, then run:
|
|
9
|
+
*
|
|
10
|
+
* pnpm build:tokens
|
|
11
|
+
*
|
|
12
|
+
* Both files get the same theme block — light + dark modes, the @theme inline
|
|
13
|
+
* mapping for Tailwind v4, and the accessibility-floor text-* scale.
|
|
14
|
+
*
|
|
15
|
+
* Differences:
|
|
16
|
+
* - styles.css imports Atkinson Hyperlegible from Google Fonts (zero setup
|
|
17
|
+
* for consumers). globals.css does not — the preview app self-hosts
|
|
18
|
+
* Hyperlegible Sans via fonts.css.
|
|
19
|
+
* - globals.css has the additional `@import "tailwindcss"` and `@import
|
|
20
|
+
* "tw-animate-css"` lines so the dev preview works standalone. Consumers
|
|
21
|
+
* write those imports themselves and then import styles.css after.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const fs = require('fs');
|
|
25
|
+
const path = require('path');
|
|
26
|
+
|
|
27
|
+
// Run-from-consumer model: this script ships in @core's bin and is invoked
|
|
28
|
+
// from a consumer repo's CWD (via `pnpm build:tokens` → `bads-build-tokens`).
|
|
29
|
+
// Source-of-truth tokens.json and the generated CSS files live in the
|
|
30
|
+
// consumer's tree, not the package's node_modules copy. Resolving paths from
|
|
31
|
+
// process.cwd() means the same script works for upstream BADS (CWD = repo
|
|
32
|
+
// root) and for client forks alike.
|
|
33
|
+
const ROOT = process.cwd();
|
|
34
|
+
const TOKENS = path.join(ROOT, 'packages/core/src/tokens.json');
|
|
35
|
+
const PKG_CSS = path.join(ROOT, 'packages/core/src/styles.css');
|
|
36
|
+
const APP_CSS = path.join(ROOT, 'styles/globals.css');
|
|
37
|
+
const CLIENT_EXTRAS = path.join(ROOT, 'styles/client-extras.css');
|
|
38
|
+
|
|
39
|
+
// Client-extras: optional file in client forks for global rules that must
|
|
40
|
+
// survive every regen (e.g. .lucide { stroke-width: 1.5 }, button cursor,
|
|
41
|
+
// brand-font @import lines). Inlined into the preview-app globals.css ONLY,
|
|
42
|
+
// never the published package — the npm package stays canonical.
|
|
43
|
+
function readClientExtras() {
|
|
44
|
+
if (!fs.existsSync(CLIENT_EXTRAS)) return '';
|
|
45
|
+
const body = fs.readFileSync(CLIENT_EXTRAS, 'utf8').trim();
|
|
46
|
+
if (!body) return '';
|
|
47
|
+
return `\n/* ---- styles/client-extras.css (inlined by build-tokens) ---- */\n${body}\n`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const clientExtras = readClientExtras();
|
|
51
|
+
|
|
52
|
+
const tokens = JSON.parse(fs.readFileSync(TOKENS, 'utf8'));
|
|
53
|
+
|
|
54
|
+
if (!tokens.theme || !tokens.theme.light || !tokens.theme.dark) {
|
|
55
|
+
console.error('tokens.json is missing theme.light / theme.dark — aborting.');
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function emitVars(modeTokens) {
|
|
60
|
+
return Object.entries(modeTokens)
|
|
61
|
+
.map(([name, token]) => ` --${name}: ${token.$value};`)
|
|
62
|
+
.join('\n');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const lightVars = emitVars(tokens.theme.light);
|
|
66
|
+
const darkVars = emitVars(tokens.theme.dark);
|
|
67
|
+
const fontSans = tokens.fontFamily.sans.$value;
|
|
68
|
+
const fontMono = tokens.fontFamily.mono.$value;
|
|
69
|
+
const fontSerif = tokens.fontFamily.serif.$value;
|
|
70
|
+
const radius = tokens.borderRadius?.lg?.$value ?? '0.625rem';
|
|
71
|
+
const spacing = tokens.theme?.light?.spacing?.$value ?? '0.25rem';
|
|
72
|
+
|
|
73
|
+
const fontSize = (key, fallback) => tokens.fontSize?.[key]?.$value ?? fallback;
|
|
74
|
+
const textXs = fontSize('xs', '14px');
|
|
75
|
+
const textSm = fontSize('sm', '16px');
|
|
76
|
+
const textBase = fontSize('base', '18px');
|
|
77
|
+
const textLg = fontSize('lg', '20px');
|
|
78
|
+
const textXl = fontSize('xl', '24px');
|
|
79
|
+
const text2xl = fontSize('2xl', '28px');
|
|
80
|
+
const text3xl = fontSize('3xl', '32px');
|
|
81
|
+
// Marketing tier — display sizes for landing pages, hero blocks, and
|
|
82
|
+
// editorial layouts. Always emitted; Tailwind only generates the utilities
|
|
83
|
+
// that get used, so unused tiers cost nothing in the bundle.
|
|
84
|
+
const text4xl = fontSize('4xl', '36px');
|
|
85
|
+
const text5xl = fontSize('5xl', '48px');
|
|
86
|
+
const text6xl = fontSize('6xl', '60px');
|
|
87
|
+
const text7xl = fontSize('7xl', '72px');
|
|
88
|
+
const text8xl = fontSize('8xl', '96px');
|
|
89
|
+
|
|
90
|
+
const banner = `/* GENERATED FROM tokens.json — DO NOT EDIT BY HAND.
|
|
91
|
+
* Run \`pnpm build:tokens\` after changing tokens.json. */`;
|
|
92
|
+
|
|
93
|
+
// Shadow tokens, all keyed off a single --shadow-opacity variable so the
|
|
94
|
+
// Customize tab's Shadow Opacity slider (use-global-design-controls →
|
|
95
|
+
// documentElement.style --shadow-opacity) actually retunes every elevation.
|
|
96
|
+
// Default 0.10 matches shadcn's classic alpha. The 2xs/xs are 0.5× base
|
|
97
|
+
// (subtler edges) and 2xl is 2.5× base (deeper drop) so the proportional
|
|
98
|
+
// rhythm holds while one slider drives them all.
|
|
99
|
+
const shadowBlock = ` --shadow-opacity: 0.10;
|
|
100
|
+
--shadow-2xs: 0 1px 3px 0px hsl(0 0% 0% / calc(var(--shadow-opacity) * 0.5));
|
|
101
|
+
--shadow-xs: 0 1px 3px 0px hsl(0 0% 0% / calc(var(--shadow-opacity) * 0.5));
|
|
102
|
+
--shadow-sm: 0 1px 3px 0px hsl(0 0% 0% / var(--shadow-opacity)), 0 1px 2px -1px hsl(0 0% 0% / var(--shadow-opacity));
|
|
103
|
+
--shadow: 0 1px 3px 0px hsl(0 0% 0% / var(--shadow-opacity)), 0 1px 2px -1px hsl(0 0% 0% / var(--shadow-opacity));
|
|
104
|
+
--shadow-md: 0 1px 3px 0px hsl(0 0% 0% / var(--shadow-opacity)), 0 2px 4px -1px hsl(0 0% 0% / var(--shadow-opacity));
|
|
105
|
+
--shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / var(--shadow-opacity)), 0 4px 6px -1px hsl(0 0% 0% / var(--shadow-opacity));
|
|
106
|
+
--shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / var(--shadow-opacity)), 0 8px 10px -1px hsl(0 0% 0% / var(--shadow-opacity));
|
|
107
|
+
--shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / calc(var(--shadow-opacity) * 2.5));`;
|
|
108
|
+
|
|
109
|
+
// Chart palette derives from --primary by default so all data viz tracks the
|
|
110
|
+
// brand color picker. Each chart-N reads --primary's hue and rotates around
|
|
111
|
+
// it (35° steps) for multi-series distinguishability. --chart-lightness sets
|
|
112
|
+
// the absolute L per mode so dark backgrounds get readable lighter charts
|
|
113
|
+
// regardless of how dark the brand color is.
|
|
114
|
+
//
|
|
115
|
+
// Override mechanism (in priority order, last wins):
|
|
116
|
+
// 1. tokens.json theme.light/dark.chart-N → emitted into :root / .dark
|
|
117
|
+
// first, gets overridden by the derivation below.
|
|
118
|
+
// 2. This derivation block (default): chart-N = oklch(from --primary ...).
|
|
119
|
+
// 3. Per-token override via documentElement.style.--chart-N (Customize tab
|
|
120
|
+
// or any client code) — wins because inline styles beat :root.
|
|
121
|
+
//
|
|
122
|
+
// Uses CSS Color 5 relative-color syntax: Chrome 119+, Safari 18+, Firefox 128+.
|
|
123
|
+
const chartDerivationLight = ` /* Chart palette — derives from --primary so brand changes propagate.
|
|
124
|
+
Override individual --chart-N inline (documentElement.style) to opt out. */
|
|
125
|
+
--chart-lightness: 0.58;
|
|
126
|
+
--chart-1: oklch(from var(--primary) var(--chart-lightness) c h);
|
|
127
|
+
--chart-2: oklch(from var(--primary) var(--chart-lightness) calc(c * 0.65) calc(h + 35));
|
|
128
|
+
--chart-3: oklch(from var(--primary) var(--chart-lightness) c calc(h + 70));
|
|
129
|
+
--chart-4: oklch(from var(--primary) var(--chart-lightness) c calc(h + 105));
|
|
130
|
+
--chart-5: oklch(from var(--primary) var(--chart-lightness) c calc(h + 140));`;
|
|
131
|
+
|
|
132
|
+
const chartDerivationDark = ` /* Lift lightness on dark backgrounds so charts stay readable. */
|
|
133
|
+
--chart-lightness: 0.78;`;
|
|
134
|
+
|
|
135
|
+
const themeInline = `@theme inline {
|
|
136
|
+
--color-background: var(--background);
|
|
137
|
+
--color-foreground: var(--foreground);
|
|
138
|
+
--color-card: var(--card);
|
|
139
|
+
--color-card-foreground: var(--card-foreground);
|
|
140
|
+
--color-popover: var(--popover);
|
|
141
|
+
--color-popover-foreground: var(--popover-foreground);
|
|
142
|
+
--color-primary: var(--primary);
|
|
143
|
+
--color-primary-foreground: var(--primary-foreground);
|
|
144
|
+
--color-secondary: var(--secondary);
|
|
145
|
+
--color-secondary-foreground: var(--secondary-foreground);
|
|
146
|
+
--color-muted: var(--muted);
|
|
147
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
148
|
+
--color-accent: var(--accent);
|
|
149
|
+
--color-accent-foreground: var(--accent-foreground);
|
|
150
|
+
--color-destructive: var(--destructive);
|
|
151
|
+
--color-destructive-foreground: var(--destructive-foreground);
|
|
152
|
+
--color-border: var(--border);
|
|
153
|
+
--color-input: var(--input);
|
|
154
|
+
--color-ring: var(--ring);
|
|
155
|
+
--color-chart-1: var(--chart-1);
|
|
156
|
+
--color-chart-2: var(--chart-2);
|
|
157
|
+
--color-chart-3: var(--chart-3);
|
|
158
|
+
--color-chart-4: var(--chart-4);
|
|
159
|
+
--color-chart-5: var(--chart-5);
|
|
160
|
+
--color-sidebar: var(--sidebar);
|
|
161
|
+
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
162
|
+
--color-sidebar-primary: var(--sidebar-primary);
|
|
163
|
+
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
164
|
+
--color-sidebar-accent: var(--sidebar-accent);
|
|
165
|
+
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
166
|
+
--color-sidebar-border: var(--sidebar-border);
|
|
167
|
+
--color-sidebar-ring: var(--sidebar-ring);
|
|
168
|
+
|
|
169
|
+
--font-sans: var(--font-sans);
|
|
170
|
+
--font-mono: var(--font-mono);
|
|
171
|
+
--font-serif: var(--font-serif);
|
|
172
|
+
|
|
173
|
+
--radius-sm: calc(var(--radius) - 4px);
|
|
174
|
+
--radius-md: calc(var(--radius) - 2px);
|
|
175
|
+
--radius-lg: var(--radius);
|
|
176
|
+
--radius-xl: calc(var(--radius) + 4px);
|
|
177
|
+
|
|
178
|
+
/* Map Tailwind's shadow-* utilities through to the :root --shadow-* tokens
|
|
179
|
+
so the Customize tab's Shadow Opacity slider takes effect. Without this
|
|
180
|
+
mapping, shadow-sm / shadow-md / shadow-lg etc. resolve to Tailwind's
|
|
181
|
+
built-in box-shadow values and ignore --shadow-opacity entirely. */
|
|
182
|
+
--shadow-2xs: var(--shadow-2xs);
|
|
183
|
+
--shadow-xs: var(--shadow-xs);
|
|
184
|
+
--shadow-sm: var(--shadow-sm);
|
|
185
|
+
--shadow: var(--shadow);
|
|
186
|
+
--shadow-md: var(--shadow-md);
|
|
187
|
+
--shadow-lg: var(--shadow-lg);
|
|
188
|
+
--shadow-xl: var(--shadow-xl);
|
|
189
|
+
--shadow-2xl: var(--shadow-2xl);
|
|
190
|
+
|
|
191
|
+
/* Accessibility floor — minimum 14px for text-xs (vs Tailwind's 12px default).
|
|
192
|
+
Font sizes are dynamically computed by useGlobalTypeScale hook and set as
|
|
193
|
+
--text-xs-size, --text-sm-size, etc. These are then scaled by --font-size-scale
|
|
194
|
+
(1 = 100%, 0.8 = 80%, etc) so the Customize tab slider affects all text. */
|
|
195
|
+
--text-xs: calc(var(--text-xs-size, ${textXs}) * var(--font-size-scale, 1));
|
|
196
|
+
--text-sm: calc(var(--text-sm-size, ${textSm}) * var(--font-size-scale, 1));
|
|
197
|
+
--text-base: calc(var(--text-base-size, ${textBase}) * var(--font-size-scale, 1));
|
|
198
|
+
--text-lg: calc(var(--text-lg-size, ${textLg}) * var(--font-size-scale, 1));
|
|
199
|
+
--text-xl: calc(var(--text-xl-size, ${textXl}) * var(--font-size-scale, 1));
|
|
200
|
+
--text-2xl: calc(var(--text-2xl-size, ${text2xl}) * var(--font-size-scale, 1));
|
|
201
|
+
--text-3xl: calc(var(--text-3xl-size, ${text3xl}) * var(--font-size-scale, 1));
|
|
202
|
+
|
|
203
|
+
/* Marketing tier — display sizes for landing pages, hero blocks, editorial.
|
|
204
|
+
Tailwind only emits utilities that get used, so a non-marketing fork pays
|
|
205
|
+
nothing for these. line-height drops to 1.1 at scale to keep big type
|
|
206
|
+
readable; tracking tightens slightly to compensate for optical loosening. */
|
|
207
|
+
--text-4xl: calc(${text4xl} * var(--font-size-scale, 1));
|
|
208
|
+
--text-5xl: calc(${text5xl} * var(--font-size-scale, 1));
|
|
209
|
+
--text-6xl: calc(${text6xl} * var(--font-size-scale, 1));
|
|
210
|
+
--text-7xl: calc(${text7xl} * var(--font-size-scale, 1));
|
|
211
|
+
--text-8xl: calc(${text8xl} * var(--font-size-scale, 1));
|
|
212
|
+
--text-4xl--line-height: 1.15;
|
|
213
|
+
--text-5xl--line-height: 1.10;
|
|
214
|
+
--text-6xl--line-height: 1.05;
|
|
215
|
+
--text-7xl--line-height: 1.02;
|
|
216
|
+
--text-8xl--line-height: 1.00;
|
|
217
|
+
--text-4xl--letter-spacing: -0.015em;
|
|
218
|
+
--text-5xl--letter-spacing: -0.020em;
|
|
219
|
+
--text-6xl--letter-spacing: -0.025em;
|
|
220
|
+
--text-7xl--letter-spacing: -0.030em;
|
|
221
|
+
--text-8xl--letter-spacing: -0.035em;
|
|
222
|
+
|
|
223
|
+
/* Tracking — every Tailwind tracking-* utility folds in the runtime
|
|
224
|
+
--tracking-offset offset, so the Customize tab slider moves the
|
|
225
|
+
entire app (headlines included), not just unstyled text. */
|
|
226
|
+
--tracking-tighter: calc(-0.05em + var(--tracking-offset, 0em));
|
|
227
|
+
--tracking-tight: calc(-0.025em + var(--tracking-offset, 0em));
|
|
228
|
+
--tracking-normal: var(--tracking-offset, 0em);
|
|
229
|
+
--tracking-wide: calc(0.025em + var(--tracking-offset, 0em));
|
|
230
|
+
--tracking-wider: calc(0.05em + var(--tracking-offset, 0em));
|
|
231
|
+
--tracking-widest: calc(0.1em + var(--tracking-offset, 0em));
|
|
232
|
+
}`;
|
|
233
|
+
|
|
234
|
+
const baseLayer = `@layer base {
|
|
235
|
+
* {
|
|
236
|
+
@apply border-border outline-ring/50;
|
|
237
|
+
}
|
|
238
|
+
body {
|
|
239
|
+
@apply bg-background text-foreground;
|
|
240
|
+
-webkit-font-smoothing: antialiased;
|
|
241
|
+
-moz-osx-font-smoothing: grayscale;
|
|
242
|
+
/* WCAG AAA 1.4.8 Visual Presentation: body line-height ≥ 1.5. */
|
|
243
|
+
line-height: 1.5;
|
|
244
|
+
/* WCAG AAA 1.4.8: avoid full-justified body — uneven word spacing
|
|
245
|
+
hurts readability. Components opt-in to justify only when needed. */
|
|
246
|
+
text-align: start;
|
|
247
|
+
/* Fade body in once fonts are ready. The boot script in app/layout.tsx
|
|
248
|
+
toggles .fonts-loading / .fonts-loaded on <html>. Cached loads bypass
|
|
249
|
+
the gate entirely (instant paint); first uncached loads briefly hide
|
|
250
|
+
body until document.fonts.ready resolves, then fade in. Eliminates
|
|
251
|
+
the FOUT "jump" as web fonts swap in over system-ui fallback. */
|
|
252
|
+
opacity: 1;
|
|
253
|
+
transition: opacity 200ms ease-out;
|
|
254
|
+
}
|
|
255
|
+
html.fonts-loading body {
|
|
256
|
+
opacity: 0;
|
|
257
|
+
}
|
|
258
|
+
/* Reduced-motion: never animate the fade — show body immediately when
|
|
259
|
+
the gate releases. Honors SC 2.3.3. */
|
|
260
|
+
@media (prefers-reduced-motion: reduce) {
|
|
261
|
+
body { transition: none; }
|
|
262
|
+
}
|
|
263
|
+
/* WCAG AAA 1.4.8: paragraph spacing ≥ 1.5× line-height inside running
|
|
264
|
+
text. Scope to <p> only — UI primitives stay tight. Last-child has
|
|
265
|
+
no trailing margin so containers don't get extra padding. */
|
|
266
|
+
p:not(:last-child) {
|
|
267
|
+
margin-bottom: 1.5em;
|
|
268
|
+
}
|
|
269
|
+
/* WCAG AAA 2.4.13 Focus Appearance: focus indicator must be ≥ 2 CSS
|
|
270
|
+
pixels thick AND have ≥ 3:1 contrast against adjacent colors. The
|
|
271
|
+
--ring token is luminance-tuned for 3:1 against every surface in
|
|
272
|
+
the system. Always show a 2px offset so the ring isn't visually
|
|
273
|
+
obscured by the component's own border. */
|
|
274
|
+
:focus-visible {
|
|
275
|
+
outline-offset: 2px;
|
|
276
|
+
}
|
|
277
|
+
/* WCAG AAA 2.3.3 Animation from Interactions: respect the user's
|
|
278
|
+
reduced-motion preference globally. Components with essential
|
|
279
|
+
motion (loading spinners, progress bars) opt back in via
|
|
280
|
+
\`motion-safe:\` Tailwind utilities or scoped @media queries. */
|
|
281
|
+
@media (prefers-reduced-motion: reduce) {
|
|
282
|
+
*,
|
|
283
|
+
*::before,
|
|
284
|
+
*::after {
|
|
285
|
+
animation-duration: 0.01ms !important;
|
|
286
|
+
animation-iteration-count: 1 !important;
|
|
287
|
+
transition-duration: 0.01ms !important;
|
|
288
|
+
scroll-behavior: auto !important;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* Global tracking offset — the Letter Spacing slider in the Customize
|
|
294
|
+
tab writes --tracking-offset on documentElement (via use-global-design-
|
|
295
|
+
controls). Both the @theme inline tracking-* tokens AND this body rule
|
|
296
|
+
fold it in, so every element retracks live: utilities-styled elements
|
|
297
|
+
via the Tailwind classes, unstyled text via inheritance from body. */
|
|
298
|
+
html, body {
|
|
299
|
+
letter-spacing: var(--tracking-offset, 0em);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* Theme toggle: iris reveal via View Transitions API. The click coords are
|
|
303
|
+
written to --x / --y on <html> before startViewTransition fires (see
|
|
304
|
+
app/page.tsx toggleDark). */
|
|
305
|
+
::view-transition-old(root),
|
|
306
|
+
::view-transition-new(root) {
|
|
307
|
+
animation: none;
|
|
308
|
+
mix-blend-mode: normal;
|
|
309
|
+
}
|
|
310
|
+
::view-transition-old(root) { z-index: 0; }
|
|
311
|
+
::view-transition-new(root) { z-index: 1; }
|
|
312
|
+
|
|
313
|
+
@keyframes theme-reveal {
|
|
314
|
+
from {
|
|
315
|
+
clip-path: circle(0% at var(--x, 50%) var(--y, 50%));
|
|
316
|
+
opacity: 0.7;
|
|
317
|
+
}
|
|
318
|
+
to {
|
|
319
|
+
clip-path: circle(150% at var(--x, 50%) var(--y, 50%));
|
|
320
|
+
opacity: 1;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
::view-transition-new(root) {
|
|
325
|
+
animation: theme-reveal 0.4s ease-in-out forwards;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
@media (prefers-reduced-motion: reduce) {
|
|
329
|
+
::view-transition-new(root) { animation: none; }
|
|
330
|
+
}`;
|
|
331
|
+
|
|
332
|
+
// ---- packages/core/src/styles.css (consumer-facing) ----------------------
|
|
333
|
+
|
|
334
|
+
const pkgCss = `${banner}
|
|
335
|
+
|
|
336
|
+
/* @behavioral-agentic-design-system/core — single-file theme import.
|
|
337
|
+
*
|
|
338
|
+
* Usage in your app's global stylesheet:
|
|
339
|
+
* @import "tailwindcss";
|
|
340
|
+
* @import "tw-animate-css";
|
|
341
|
+
* @import "@behavioral-agentic-design-system/core/styles.css";
|
|
342
|
+
*
|
|
343
|
+
* Atkinson Hyperlegible loaded from Google Fonts; zero font setup required.
|
|
344
|
+
* Override any token by re-declaring it after this @import.
|
|
345
|
+
*/
|
|
346
|
+
|
|
347
|
+
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
|
|
348
|
+
|
|
349
|
+
@custom-variant dark (&:is(.dark *));
|
|
350
|
+
|
|
351
|
+
:root {
|
|
352
|
+
--font-sans: 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui;
|
|
353
|
+
--font-mono: ${fontMono};
|
|
354
|
+
--font-serif: ${fontSerif};
|
|
355
|
+
--font-size-scale: 1;
|
|
356
|
+
|
|
357
|
+
${lightVars}
|
|
358
|
+
|
|
359
|
+
--radius: ${radius};
|
|
360
|
+
${shadowBlock}
|
|
361
|
+
--spacing: ${spacing};
|
|
362
|
+
|
|
363
|
+
${chartDerivationLight}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
.dark {
|
|
367
|
+
${darkVars}
|
|
368
|
+
|
|
369
|
+
${chartDerivationDark}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
${themeInline}
|
|
373
|
+
|
|
374
|
+
${baseLayer}
|
|
375
|
+
`;
|
|
376
|
+
|
|
377
|
+
fs.writeFileSync(PKG_CSS, pkgCss);
|
|
378
|
+
console.log(`✓ wrote ${path.relative(ROOT, PKG_CSS)}`);
|
|
379
|
+
|
|
380
|
+
// ---- styles/globals.css (preview app) ------------------------------------
|
|
381
|
+
|
|
382
|
+
// Note: Google Fonts @imports are intentionally NOT emitted for the preview app.
|
|
383
|
+
// app/layout.tsx loads Atkinson Hyperlegible / Inter / Lora / Source Serif 4 /
|
|
384
|
+
// JetBrains Mono via next/font/google, which self-hosts and preloads the woff2
|
|
385
|
+
// to eliminate FOUT. The npm package (packages/core/src/styles.css) keeps its
|
|
386
|
+
// @import so consumers without next/font still get the canonical theme.
|
|
387
|
+
const appCss = `${banner}
|
|
388
|
+
|
|
389
|
+
@import "../fonts.css";
|
|
390
|
+
@import "tailwindcss";
|
|
391
|
+
@import "tw-animate-css";
|
|
392
|
+
|
|
393
|
+
@custom-variant dark (&:is(.dark *));
|
|
394
|
+
|
|
395
|
+
:root {
|
|
396
|
+
/* Showcase app: lead with next/font's preloaded vars so the browser uses
|
|
397
|
+
* the self-hosted woff2 set up in app/layout.tsx — kills FOUT. The literal
|
|
398
|
+
* family names from tokens.json remain as fallbacks. */
|
|
399
|
+
--font-sans: var(--font-atkinson), ${fontSans};
|
|
400
|
+
--font-serif: var(--font-source-serif), ${fontSerif};
|
|
401
|
+
--font-mono: var(--font-jetbrains), ${fontMono};
|
|
402
|
+
--font-size-scale: 1;
|
|
403
|
+
|
|
404
|
+
${lightVars}
|
|
405
|
+
|
|
406
|
+
--radius: ${radius};
|
|
407
|
+
${shadowBlock}
|
|
408
|
+
--spacing: ${spacing};
|
|
409
|
+
|
|
410
|
+
${chartDerivationLight}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.dark {
|
|
414
|
+
${darkVars}
|
|
415
|
+
|
|
416
|
+
${chartDerivationDark}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
${themeInline}
|
|
420
|
+
|
|
421
|
+
${baseLayer}
|
|
422
|
+
|
|
423
|
+
* {
|
|
424
|
+
color-scheme: light dark;
|
|
425
|
+
border-color: var(--color-border);
|
|
426
|
+
}
|
|
427
|
+
${clientExtras}`;
|
|
428
|
+
|
|
429
|
+
fs.writeFileSync(APP_CSS, appCss);
|
|
430
|
+
console.log(`✓ wrote ${path.relative(ROOT, APP_CSS)}${clientExtras ? ' (with client-extras)' : ''}`);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Removes the `fonts-loading` class on <html> once web fonts are ready.
|
|
7
|
+
*
|
|
8
|
+
* RootLayout renders `<html className="fonts-loading ...">` so the body is
|
|
9
|
+
* hidden from the very first paint (CSS rule in the base layer:
|
|
10
|
+
* `html.fonts-loading body { opacity: 0 }`). This component runs after
|
|
11
|
+
* hydration, awaits `document.fonts.ready`, then swaps to `fonts-loaded` —
|
|
12
|
+
* CSS transitions the body back in over 200ms.
|
|
13
|
+
*
|
|
14
|
+
* Cached loads: fonts.check() returns true immediately, so the class is
|
|
15
|
+
* removed within a few ms of hydration — barely perceptible.
|
|
16
|
+
*
|
|
17
|
+
* Slow / failed loads: a 1500ms safety timeout releases the gate so the
|
|
18
|
+
* page never stays blank, even if a font 404s or hangs.
|
|
19
|
+
*/
|
|
20
|
+
export function FontReady() {
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
const root = document.documentElement;
|
|
23
|
+
const reveal = () => {
|
|
24
|
+
root.classList.remove("fonts-loading");
|
|
25
|
+
root.classList.add("fonts-loaded");
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
let alreadyReady = false;
|
|
29
|
+
try {
|
|
30
|
+
alreadyReady = document.fonts.check("1em 'Hyperlegible Sans'");
|
|
31
|
+
} catch {
|
|
32
|
+
// fonts.check throws if the font name is unknown — treat as not ready.
|
|
33
|
+
}
|
|
34
|
+
if (alreadyReady) {
|
|
35
|
+
reveal();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
let cancelled = false;
|
|
40
|
+
document.fonts.ready.then(() => {
|
|
41
|
+
if (!cancelled) reveal();
|
|
42
|
+
});
|
|
43
|
+
const safety = window.setTimeout(reveal, 1500);
|
|
44
|
+
return () => {
|
|
45
|
+
cancelled = true;
|
|
46
|
+
window.clearTimeout(safety);
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|