@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
@@ -0,0 +1,267 @@
1
+ "use client";
2
+
3
+ import { useState, useEffect, useRef, useCallback } from "react";
4
+ import { Tabs, TabsContent, TabsList, TabsPanels, TabsTrigger } from "@behavioral-agentic-design-system/core/components/ui/tabs";
5
+ import { ScrollArea, ScrollBar } from "@behavioral-agentic-design-system/core/components/ui/scroll-area";
6
+ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
7
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
8
+ import { Sparkles, Sun, Moon, BookOpen } from "lucide-react";
9
+ import { brand } from "@/brand.config";
10
+ import { CustomizeTab } from "@behavioral-agentic-design-system/core/components/customize-tab";
11
+ import { LayersTab } from "@behavioral-agentic-design-system/core/components/layers-tab";
12
+ import { HomeTab } from "@behavioral-agentic-design-system/core/components/home-tab";
13
+
14
+ function IframePreview({ src, minWidth, dark }: { src: string; minWidth?: string; dark: boolean }) {
15
+ const iframeRef = useRef<HTMLIFrameElement>(null);
16
+ // Capture the initial src once on mount. After load, dark mode is applied via
17
+ // class toggle (syncDarkMode) — recomputing src on every dark change would
18
+ // reload the iframe and cause a flicker during the theme transition.
19
+ const initialSrcRef = useRef(`${src}${dark ? "?dark=1" : ""}`);
20
+ // Iframe is visually hidden until its document fires `load`. Otherwise the
21
+ // user sees a brief flash of unstyled content (HTML paints before CSS+fonts
22
+ // arrive). Once loaded, fade the iframe in over 250ms — the parent tab fade
23
+ // is also running, so cumulatively the first-click feels like a single
24
+ // smooth transition.
25
+ const [loaded, setLoaded] = useState(false);
26
+
27
+ const syncDarkMode = useCallback(() => {
28
+ try {
29
+ iframeRef.current?.contentDocument?.documentElement.classList.toggle("dark", dark);
30
+ } catch {}
31
+ }, [dark]);
32
+
33
+ useEffect(() => {
34
+ syncDarkMode();
35
+ }, [syncDarkMode]);
36
+
37
+ return (
38
+ <div className="size-full relative">
39
+ <ScrollArea className="size-full">
40
+ <div style={{ minWidth: minWidth || "100%" }} className="h-full">
41
+ <iframe
42
+ ref={iframeRef}
43
+ src={initialSrcRef.current}
44
+ onLoad={() => {
45
+ syncDarkMode();
46
+ setLoaded(true);
47
+ }}
48
+ className="w-full border-0 transition-opacity duration-300 ease-out"
49
+ style={{
50
+ height: "100vh",
51
+ minHeight: "800px",
52
+ opacity: loaded ? 1 : 0,
53
+ }}
54
+ />
55
+ </div>
56
+ {minWidth && <ScrollBar orientation="horizontal" />}
57
+ </ScrollArea>
58
+ </div>
59
+ );
60
+ }
61
+
62
+ const tabs = [
63
+ { value: "home", label: "Home" },
64
+ { value: "components", label: "Components" },
65
+ { value: "cards", label: "Cards" },
66
+ { value: "dashboard", label: "Dashboard", hidden: "md" },
67
+ { value: "mail", label: "Mail", hidden: "md" },
68
+ { value: "pricing", label: "Pricing" },
69
+ { value: "layers", label: "Layers" },
70
+ { value: "colors", label: "Customize" },
71
+ ];
72
+
73
+ export default function DesignSystemPreview() {
74
+ const [activeTab, setActiveTab] = useState("home");
75
+ const [dark, setDark] = useState(false);
76
+ // Sticky-mount: once a tab has been viewed, keep it mounted forever so the
77
+ // iframe (or React tree) doesn't cold-load on every switch. TabsPanels
78
+ // cross-fades between mounted siblings, so subsequent switches are instant
79
+ // and flash-free. Only the first visit to a tab pays the load cost.
80
+ const [seen, setSeen] = useState<Set<string>>(() => new Set([activeTab]));
81
+ useEffect(() => {
82
+ setSeen((prev) => (prev.has(activeTab) ? prev : new Set(prev).add(activeTab)));
83
+ }, [activeTab]);
84
+
85
+ // Background preload: after the active tab has fully painted and idled,
86
+ // mount every iframe tab so they load silently while the user is reading
87
+ // the home tab. By the time someone clicks Components / Cards / Dashboard /
88
+ // Mail / Pricing, the iframe is already loaded + styled — the tab switch
89
+ // becomes an instant cross-fade, no FOUC, no spinner. Uses
90
+ // requestIdleCallback when available so we don't compete with the home
91
+ // tab's first paint; falls back to a 1500ms setTimeout in Safari.
92
+ useEffect(() => {
93
+ const preloadAll = () => {
94
+ setSeen((prev) => {
95
+ const next = new Set(prev);
96
+ ["components", "cards", "dashboard", "mail", "pricing", "layers", "colors"].forEach(
97
+ (t) => next.add(t),
98
+ );
99
+ return next;
100
+ });
101
+ };
102
+ type RIC = (cb: () => void, opts?: { timeout?: number }) => number;
103
+ const w = window as Window & { requestIdleCallback?: RIC; cancelIdleCallback?: (id: number) => void };
104
+ if (w.requestIdleCallback) {
105
+ const id = w.requestIdleCallback(preloadAll, { timeout: 2500 });
106
+ return () => w.cancelIdleCallback?.(id);
107
+ }
108
+ const id = window.setTimeout(preloadAll, 1500);
109
+ return () => window.clearTimeout(id);
110
+ }, []);
111
+
112
+ useEffect(() => {
113
+ document.documentElement.classList.toggle("dark", dark);
114
+ }, [dark]);
115
+
116
+ const toggleDark = (event: React.MouseEvent) => {
117
+ const next = !dark;
118
+ const root = document.documentElement;
119
+ const prefersReduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
120
+ const supports = typeof document !== "undefined" && "startViewTransition" in document;
121
+
122
+ // Sync every iframe preview's dark class right now so its DOM matches the
123
+ // new theme at the same instant the parent does — otherwise the iframe lags
124
+ // behind React's useEffect and the transition captures stale iframe content.
125
+ const syncIframes = () => {
126
+ document.querySelectorAll("iframe").forEach((f) => {
127
+ try {
128
+ f.contentDocument?.documentElement.classList.toggle("dark", next);
129
+ } catch {}
130
+ });
131
+ };
132
+ const syncHost = () => {
133
+ root.classList.toggle("dark", next);
134
+ };
135
+
136
+ if (!supports || prefersReduce) {
137
+ syncHost();
138
+ syncIframes();
139
+ setDark(next);
140
+ return;
141
+ }
142
+ root.style.setProperty("--x", `${event.clientX}px`);
143
+ root.style.setProperty("--y", `${event.clientY}px`);
144
+ (document as Document & { startViewTransition: (cb: () => void) => void }).startViewTransition(() => {
145
+ syncHost();
146
+ syncIframes();
147
+ setDark(next);
148
+ });
149
+ };
150
+
151
+ return (
152
+ <div className="min-h-screen bg-background flex flex-col">
153
+ <header className="border-b bg-card shrink-0">
154
+ <div className="flex h-14 items-center px-6">
155
+ <div className="flex items-center gap-2">
156
+ <div
157
+ className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary"
158
+ >
159
+ <Sparkles className="h-4 w-4 text-primary-foreground" />
160
+ </div>
161
+ <span className="text-lg font-semibold">{brand.name}</span>
162
+ <Badge variant="outline" className="ml-2 text-xs">{brand.tagline}</Badge>
163
+ </div>
164
+ <div className="ml-auto flex items-center gap-2">
165
+ <Button
166
+ asChild
167
+ variant="ghost"
168
+ size="sm"
169
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-foreground hover:!text-background hover:border-foreground"
170
+ title="Open Storybook (requires `pnpm dev` or `pnpm storybook` to be running on :6006)"
171
+ >
172
+ <a href="http://localhost:6006" target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
173
+ <BookOpen className="h-4 w-4 transition-all group-hover:scale-110" strokeWidth={1.5} />
174
+ <span className="text-xs font-medium">Storybook</span>
175
+ </a>
176
+ </Button>
177
+ <Button
178
+ variant="ghost"
179
+ size="icon"
180
+ onClick={toggleDark}
181
+ className="group size-8 border border-foreground/30 hover:!bg-foreground hover:!text-background hover:border-foreground"
182
+ aria-label={dark ? "Switch to light mode" : "Switch to dark mode"}
183
+ >
184
+ {dark ? (
185
+ <Sun className="h-4 w-4 transition-all group-hover:scale-110" />
186
+ ) : (
187
+ <Moon className="h-4 w-4 transition-all group-hover:scale-110" />
188
+ )}
189
+ </Button>
190
+ </div>
191
+ </div>
192
+ </header>
193
+
194
+ <Tabs
195
+ value={activeTab}
196
+ onValueChange={setActiveTab}
197
+ // Slower cross-fade between mounted panels — 260ms feels deliberate
198
+ // without dragging. Read by the duration utility on TabsPanels.
199
+ style={{ "--tabs-fade-duration": "260ms" } as React.CSSProperties}
200
+ className="flex-1 flex flex-col overflow-hidden"
201
+ >
202
+ <div className="mt-2 mb-1 flex w-full items-center px-4">
203
+ <TabsList className="bg-background text-muted-foreground inline-flex w-fit items-center justify-center rounded-full px-0">
204
+ {tabs.map((tab) => (
205
+ <TabsTrigger
206
+ key={tab.value}
207
+ value={tab.value}
208
+ className={`items-center justify-center rounded-full px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=active]:shadow-sm ${
209
+ tab.hidden === "md" ? "hidden md:inline-flex" : "inline-flex"
210
+ }`}
211
+ >
212
+ {tab.label}
213
+ </TabsTrigger>
214
+ ))}
215
+ </TabsList>
216
+ </div>
217
+
218
+ <section className="relative flex-1 min-h-0 w-full overflow-hidden">
219
+ <div className="absolute inset-x-4 top-1 bottom-4 isolate overflow-hidden rounded-lg">
220
+ <TabsPanels>
221
+ {seen.has("home") && (
222
+ <TabsContent value="home" forceMount>
223
+ <HomeTab />
224
+ </TabsContent>
225
+ )}
226
+ {seen.has("components") && (
227
+ <TabsContent value="components" forceMount>
228
+ <IframePreview dark={dark} src="/preview/components" />
229
+ </TabsContent>
230
+ )}
231
+ {seen.has("cards") && (
232
+ <TabsContent value="cards" forceMount>
233
+ <IframePreview dark={dark} src="/preview/cards" />
234
+ </TabsContent>
235
+ )}
236
+ {seen.has("dashboard") && (
237
+ <TabsContent value="dashboard" forceMount>
238
+ <IframePreview dark={dark} src="/preview/dashboard" minWidth="1400px" />
239
+ </TabsContent>
240
+ )}
241
+ {seen.has("mail") && (
242
+ <TabsContent value="mail" forceMount>
243
+ <IframePreview dark={dark} src="/preview/mail" minWidth="1300px" />
244
+ </TabsContent>
245
+ )}
246
+ {seen.has("pricing") && (
247
+ <TabsContent value="pricing" forceMount>
248
+ <IframePreview dark={dark} src="/preview/pricing" />
249
+ </TabsContent>
250
+ )}
251
+ {seen.has("layers") && (
252
+ <TabsContent value="layers" forceMount>
253
+ <LayersTab />
254
+ </TabsContent>
255
+ )}
256
+ {seen.has("colors") && (
257
+ <TabsContent value="colors" forceMount>
258
+ <CustomizeTab />
259
+ </TabsContent>
260
+ )}
261
+ </TabsPanels>
262
+ </div>
263
+ </section>
264
+ </Tabs>
265
+ </div>
266
+ );
267
+ }
@@ -0,0 +1,8 @@
1
+ import Cards from "@/components/examples/cards";
2
+ export default function CardsPreview() {
3
+ return (
4
+ <div className="@container h-full w-full">
5
+ <Cards />
6
+ </div>
7
+ );
8
+ }
@@ -0,0 +1,232 @@
1
+ "use client";
2
+
3
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
4
+ import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
5
+ import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
6
+ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
7
+ import { Switch } from "@behavioral-agentic-design-system/core/components/ui/switch";
8
+ import { Checkbox } from "@behavioral-agentic-design-system/core/components/ui/checkbox";
9
+ import { RadioGroup, RadioGroupItem } from "@behavioral-agentic-design-system/core/components/ui/radio-group";
10
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@behavioral-agentic-design-system/core/components/ui/card";
11
+ import { Alert, AlertDescription, AlertTitle } from "@behavioral-agentic-design-system/core/components/ui/alert";
12
+ import { Avatar, AvatarFallback, AvatarImage } from "@behavioral-agentic-design-system/core/components/ui/avatar";
13
+ import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator";
14
+ import { Skeleton } from "@behavioral-agentic-design-system/core/components/ui/skeleton";
15
+ import { Progress } from "@behavioral-agentic-design-system/core/components/ui/progress";
16
+ import { Slider } from "@behavioral-agentic-design-system/core/components/ui/slider";
17
+ import { ScrollArea } from "@behavioral-agentic-design-system/core/components/ui/scroll-area";
18
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@behavioral-agentic-design-system/core/components/ui/tabs";
19
+ import {
20
+ Dialog,
21
+ DialogContent,
22
+ DialogDescription,
23
+ DialogFooter,
24
+ DialogHeader,
25
+ DialogTitle,
26
+ DialogTrigger,
27
+ } from "@behavioral-agentic-design-system/core/components/ui/dialog";
28
+ import { Sparkles, Info } from "lucide-react";
29
+
30
+ // Stable, deterministic data for ScrollArea — never use Math.random in
31
+ // SSR-rendered output, it causes hydration mismatches.
32
+ const SCROLL_ITEMS = Array.from({ length: 40 }, (_, i) => ({
33
+ id: i + 1,
34
+ title: `Item ${String(i + 1).padStart(2, "0")}`,
35
+ meta: `entry-${i + 1}`,
36
+ }));
37
+
38
+ function Section({ title, children }: { title: string; children: React.ReactNode }) {
39
+ return (
40
+ <section className="space-y-4">
41
+ <h2 className="text-2xl font-semibold tracking-tight">{title}</h2>
42
+ <div className="rounded-lg border bg-card p-6">{children}</div>
43
+ </section>
44
+ );
45
+ }
46
+
47
+ export default function ComponentsPreview() {
48
+ return (
49
+ <div className="min-h-screen bg-background">
50
+ <div className="mx-auto max-w-5xl space-y-10 p-8">
51
+ <header className="space-y-2">
52
+ <div className="flex items-center gap-2">
53
+ <Sparkles className="size-5 text-primary" />
54
+ <h1 className="text-3xl font-semibold tracking-tight">Components</h1>
55
+ </div>
56
+ <p className="text-muted-foreground">
57
+ Kitchen-sink showcase of every component in the system. Use this as a quick
58
+ visual check when changing tokens or adding variants.
59
+ </p>
60
+ </header>
61
+
62
+ <Section title="Buttons">
63
+ <div className="flex flex-wrap items-center gap-3">
64
+ <Button size="xs">xs</Button>
65
+ <Button size="sm">sm</Button>
66
+ <Button>default</Button>
67
+ <Button size="lg">lg</Button>
68
+ <Button size="xl">xl</Button>
69
+ <Button size="2xl">2xl</Button>
70
+ </div>
71
+ <Separator className="my-4" />
72
+ <div className="flex flex-wrap items-center gap-3">
73
+ <Button>Primary</Button>
74
+ <Button variant="secondary">Secondary</Button>
75
+ <Button variant="outline">Outline</Button>
76
+ <Button variant="ghost">Ghost</Button>
77
+ <Button variant="link">Link</Button>
78
+ <Button variant="destructive">Destructive</Button>
79
+ <Button variant="accent">Accent</Button>
80
+ </div>
81
+ </Section>
82
+
83
+ <Section title="Inputs">
84
+ <div className="grid gap-4 sm:grid-cols-2">
85
+ <div className="space-y-2">
86
+ <Label htmlFor="in-sm">sm</Label>
87
+ <Input id="in-sm" size="sm" placeholder="Small input" />
88
+ </div>
89
+ <div className="space-y-2">
90
+ <Label htmlFor="in-default">default</Label>
91
+ <Input id="in-default" placeholder="Default input" />
92
+ </div>
93
+ <div className="space-y-2">
94
+ <Label htmlFor="in-lg">lg</Label>
95
+ <Input id="in-lg" size="lg" placeholder="Large input" />
96
+ </div>
97
+ <div className="space-y-2">
98
+ <Label htmlFor="in-xl">xl</Label>
99
+ <Input id="in-xl" size="xl" placeholder="Extra large input" />
100
+ </div>
101
+ </div>
102
+ </Section>
103
+
104
+ <Section title="Form controls">
105
+ <div className="flex flex-wrap items-center gap-6">
106
+ <div className="flex items-center gap-2">
107
+ <Switch id="sw" defaultChecked />
108
+ <Label htmlFor="sw">Switch</Label>
109
+ </div>
110
+ <div className="flex items-center gap-2">
111
+ <Checkbox id="cb" defaultChecked />
112
+ <Label htmlFor="cb">Checkbox</Label>
113
+ </div>
114
+ <RadioGroup defaultValue="a" className="flex items-center gap-3">
115
+ <div className="flex items-center gap-2">
116
+ <RadioGroupItem id="r-a" value="a" />
117
+ <Label htmlFor="r-a">Option A</Label>
118
+ </div>
119
+ <div className="flex items-center gap-2">
120
+ <RadioGroupItem id="r-b" value="b" />
121
+ <Label htmlFor="r-b">Option B</Label>
122
+ </div>
123
+ </RadioGroup>
124
+ </div>
125
+ <Separator className="my-4" />
126
+ <div className="space-y-3">
127
+ <Label>Slider</Label>
128
+ <Slider defaultValue={[40]} max={100} step={1} />
129
+ <Label className="pt-3">Progress</Label>
130
+ <Progress value={62} />
131
+ </div>
132
+ </Section>
133
+
134
+ <Section title="Badges, Avatars, Skeletons">
135
+ <div className="flex flex-wrap items-center gap-3">
136
+ <Badge>Default</Badge>
137
+ <Badge variant="secondary">Secondary</Badge>
138
+ <Badge variant="outline">Outline</Badge>
139
+ <Badge variant="destructive">Destructive</Badge>
140
+ </div>
141
+ <Separator className="my-4" />
142
+ <div className="flex items-center gap-3">
143
+ <Avatar>
144
+ <AvatarImage src="" alt="" />
145
+ <AvatarFallback>MS</AvatarFallback>
146
+ </Avatar>
147
+ <Avatar>
148
+ <AvatarFallback>BD</AvatarFallback>
149
+ </Avatar>
150
+ <Skeleton className="h-9 w-9 rounded-full" />
151
+ <Skeleton className="h-9 w-32" />
152
+ </div>
153
+ </Section>
154
+
155
+ <Section title="Cards & Alerts">
156
+ <div className="grid gap-4 sm:grid-cols-2">
157
+ <Card>
158
+ <CardHeader>
159
+ <CardTitle>Card title</CardTitle>
160
+ <CardDescription>One line of supporting copy.</CardDescription>
161
+ </CardHeader>
162
+ <CardContent>
163
+ <p className="text-sm text-muted-foreground">
164
+ Card body content lives here.
165
+ </p>
166
+ </CardContent>
167
+ </Card>
168
+ <Alert>
169
+ <Info className="size-4" />
170
+ <AlertTitle>Heads up</AlertTitle>
171
+ <AlertDescription>This is a default alert.</AlertDescription>
172
+ </Alert>
173
+ </div>
174
+ </Section>
175
+
176
+ <Section title="Tabs & Dialog">
177
+ <Tabs defaultValue="one" className="w-full">
178
+ <TabsList>
179
+ <TabsTrigger value="one">One</TabsTrigger>
180
+ <TabsTrigger value="two">Two</TabsTrigger>
181
+ <TabsTrigger value="three">Three</TabsTrigger>
182
+ </TabsList>
183
+ <TabsContent value="one" className="pt-4 text-sm text-muted-foreground">
184
+ Tab one content.
185
+ </TabsContent>
186
+ <TabsContent value="two" className="pt-4 text-sm text-muted-foreground">
187
+ Tab two content.
188
+ </TabsContent>
189
+ <TabsContent value="three" className="pt-4 text-sm text-muted-foreground">
190
+ Tab three content.
191
+ </TabsContent>
192
+ </Tabs>
193
+ <Separator className="my-4" />
194
+ <div className="flex flex-wrap gap-3">
195
+ {(["sm", "default", "lg", "xl", "2xl"] as const).map((s) => (
196
+ <Dialog key={s}>
197
+ <DialogTrigger asChild>
198
+ <Button variant="outline">Dialog {s}</Button>
199
+ </DialogTrigger>
200
+ <DialogContent size={s}>
201
+ <DialogHeader>
202
+ <DialogTitle>Dialog ({s})</DialogTitle>
203
+ <DialogDescription>
204
+ Demonstrates the {s} size variant.
205
+ </DialogDescription>
206
+ </DialogHeader>
207
+ <DialogFooter showCloseButton />
208
+ </DialogContent>
209
+ </Dialog>
210
+ ))}
211
+ </div>
212
+ </Section>
213
+
214
+ <Section title="ScrollArea">
215
+ <ScrollArea className="h-64 w-full rounded-md border">
216
+ <ul className="divide-y">
217
+ {SCROLL_ITEMS.map((item) => (
218
+ <li
219
+ key={item.id}
220
+ className="flex items-center justify-between px-4 py-2 text-sm"
221
+ >
222
+ <span>{item.title}</span>
223
+ <span className="text-muted-foreground">{item.meta}</span>
224
+ </li>
225
+ ))}
226
+ </ul>
227
+ </ScrollArea>
228
+ </Section>
229
+ </div>
230
+ </div>
231
+ );
232
+ }
@@ -0,0 +1,24 @@
1
+ "use client";
2
+
3
+ import { useSearchParams } from "next/navigation";
4
+ import { Suspense, useEffect } from "react";
5
+
6
+ function DarkModeHandler() {
7
+ const searchParams = useSearchParams();
8
+ const isDark = searchParams.get("dark") === "1";
9
+
10
+ useEffect(() => {
11
+ document.documentElement.classList.toggle("dark", isDark);
12
+ }, [isDark]);
13
+
14
+ return null;
15
+ }
16
+
17
+ export default function DarkModeClient({ children }: { children: React.ReactNode }) {
18
+ return (
19
+ <Suspense>
20
+ <DarkModeHandler />
21
+ {children}
22
+ </Suspense>
23
+ );
24
+ }
@@ -0,0 +1,4 @@
1
+ import Dashboard from "@/components/examples/dashboard";
2
+ export default function DashboardPreview() {
3
+ return <Dashboard />;
4
+ }
@@ -0,0 +1,36 @@
1
+ "use client";
2
+
3
+ import { useGlobalSansFont } from "@behavioral-agentic-design-system/core/hooks/use-global-sans-font";
4
+ import { useGlobalSerifFont } from "@behavioral-agentic-design-system/core/hooks/use-global-serif-font";
5
+ import { useGlobalMonoFont } from "@behavioral-agentic-design-system/core/hooks/use-global-mono-font";
6
+ import { useGlobalPrimaryColor } from "@behavioral-agentic-design-system/core/hooks/use-global-primary-color";
7
+ import { useTokenOverrides } from "@behavioral-agentic-design-system/core/hooks/use-token-overrides";
8
+ import { useGlobalDesignControls } from "@behavioral-agentic-design-system/core/hooks/use-global-design-controls";
9
+ import { useGlobalTypeScale } from "@behavioral-agentic-design-system/core/hooks/use-global-type-scale";
10
+ import { useSyncTypeScale } from "@behavioral-agentic-design-system/core/hooks/use-sync-type-scale";
11
+
12
+ /**
13
+ * Iframe-side mirror of GlobalThemeSync (see app/providers.tsx). Every hook
14
+ * mounted here ALSO needs to be mounted in providers.tsx — they're the same
15
+ * set, just running in two trees (parent app + each preview iframe).
16
+ *
17
+ * If you add a hook to providers but not here, the iframe previews
18
+ * (Components / Cards / Dashboard / Mail / Pricing) won't pick it up — the
19
+ * hook's value will only apply when the user opens a tab whose component
20
+ * tree happens to include the picker for it.
21
+ *
22
+ * Order rule: useTokenOverrides FIRST. Anything before it gets wiped by
23
+ * clearManagedInlineThemeProperties. See providers.tsx for the full
24
+ * explanation.
25
+ */
26
+ export default function GlobalFontClient() {
27
+ useTokenOverrides();
28
+ useSyncTypeScale();
29
+ useGlobalSansFont();
30
+ useGlobalSerifFont();
31
+ useGlobalMonoFont();
32
+ useGlobalPrimaryColor();
33
+ useGlobalDesignControls();
34
+ useGlobalTypeScale();
35
+ return null;
36
+ }
@@ -0,0 +1,13 @@
1
+ import "@/styles/globals.css";
2
+ import { TooltipProvider } from "@behavioral-agentic-design-system/core/components/ui/tooltip";
3
+ import DarkModeClient from "./dark-mode-client";
4
+ import GlobalFontClient from "./global-font-client";
5
+
6
+ export default function PreviewLayout({ children }: { children: React.ReactNode }) {
7
+ return (
8
+ <TooltipProvider>
9
+ <GlobalFontClient />
10
+ <DarkModeClient>{children}</DarkModeClient>
11
+ </TooltipProvider>
12
+ );
13
+ }
@@ -0,0 +1,4 @@
1
+ import Mail from "@/components/examples/mail";
2
+ export default function MailPreview() {
3
+ return <Mail />;
4
+ }
@@ -0,0 +1,4 @@
1
+ import Pricing from "@/components/examples/pricing/pricing";
2
+ export default function PricingPreview() {
3
+ return <Pricing />;
4
+ }
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ import dynamic from "next/dynamic";
4
+
5
+ const TypographyDemo = dynamic(() => import("@/components/examples/typography/typography-demo"), {
6
+ ssr: false,
7
+ });
8
+
9
+ export default function TypographyPreview() {
10
+ return <TypographyDemo />;
11
+ }
@@ -0,0 +1,49 @@
1
+ "use client";
2
+
3
+ import { TooltipProvider } from "@behavioral-agentic-design-system/core/components/ui/tooltip";
4
+ import { useGlobalSansFont } from "@behavioral-agentic-design-system/core/hooks/use-global-sans-font";
5
+ import { useGlobalSerifFont } from "@behavioral-agentic-design-system/core/hooks/use-global-serif-font";
6
+ import { useGlobalMonoFont } from "@behavioral-agentic-design-system/core/hooks/use-global-mono-font";
7
+ import { useGlobalPrimaryColor } from "@behavioral-agentic-design-system/core/hooks/use-global-primary-color";
8
+ import { useTokenOverrides } from "@behavioral-agentic-design-system/core/hooks/use-token-overrides";
9
+ import { useGlobalDesignControls } from "@behavioral-agentic-design-system/core/hooks/use-global-design-controls";
10
+ import { useGlobalTypeScale } from "@behavioral-agentic-design-system/core/hooks/use-global-type-scale";
11
+ import { useSyncTypeScale } from "@behavioral-agentic-design-system/core/hooks/use-sync-type-scale";
12
+
13
+ /**
14
+ * Global theme sync — runs every "set CSS variable on mount" hook in one
15
+ * place so the picks the user made (font, color, radius, type scale, etc.)
16
+ * apply on every page load, not just inside the Customize tab.
17
+ *
18
+ * RULES for adding a new global state hook:
19
+ * 1. The hook should read its value from localStorage on mount and apply it
20
+ * to documentElement.style.
21
+ * 2. Mount it in BOTH this component AND app/preview/global-font-client.tsx
22
+ * so it works inside iframe previews too. (Forgetting the iframe one was
23
+ * the "Dashboard / Cards font is wrong" bug.)
24
+ * 3. Mount it AFTER useTokenOverrides. That hook calls
25
+ * clearManagedInlineThemeProperties which strips --font-sans / -serif /
26
+ * -mono, --radius, --spacing, and theme color keys from
27
+ * documentElement.style. Anything set before useTokenOverrides gets
28
+ * wiped; anything after sticks.
29
+ */
30
+ function GlobalThemeSync() {
31
+ useTokenOverrides();
32
+ useSyncTypeScale();
33
+ useGlobalSansFont();
34
+ useGlobalSerifFont();
35
+ useGlobalMonoFont();
36
+ useGlobalPrimaryColor();
37
+ useGlobalDesignControls();
38
+ useGlobalTypeScale();
39
+ return null;
40
+ }
41
+
42
+ export default function Providers({ children }: { children: React.ReactNode }) {
43
+ return (
44
+ <TooltipProvider>
45
+ <GlobalThemeSync />
46
+ {children}
47
+ </TooltipProvider>
48
+ );
49
+ }