@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.
Files changed (44) hide show
  1. package/package.json +36 -5
  2. package/scripts/bads-sync.mjs +81 -0
  3. package/scripts/build-tokens.cjs +430 -0
  4. package/src/app/font-ready.tsx +51 -0
  5. package/src/app/layout.tsx +152 -0
  6. package/src/app/page.tsx +267 -0
  7. package/src/app/preview/cards/page.tsx +8 -0
  8. package/src/app/preview/components/page.tsx +232 -0
  9. package/src/app/preview/dark-mode-client.tsx +24 -0
  10. package/src/app/preview/dashboard/page.tsx +4 -0
  11. package/src/app/preview/global-font-client.tsx +36 -0
  12. package/src/app/preview/layout.tsx +13 -0
  13. package/src/app/preview/mail/page.tsx +4 -0
  14. package/src/app/preview/pricing/page.tsx +4 -0
  15. package/src/app/preview/typography/page.tsx +11 -0
  16. package/src/app/providers.tsx +49 -0
  17. package/src/components/Foundations/Colors.stories.tsx +85 -0
  18. package/src/components/Foundations/Motion.stories.tsx +169 -0
  19. package/src/components/Foundations/Radius.stories.tsx +36 -0
  20. package/src/components/Foundations/Shadows.stories.tsx +30 -0
  21. package/src/components/Foundations/Spacing.stories.tsx +35 -0
  22. package/src/components/Foundations/Typography.stories.tsx +68 -0
  23. package/src/components/bads-update-banner.tsx +120 -0
  24. package/src/components/customize/design-controls.tsx +165 -0
  25. package/src/components/customize/font-pickers.tsx +118 -0
  26. package/src/components/customize/letter-spacing.tsx +105 -0
  27. package/src/components/customize/save-bar.tsx +379 -0
  28. package/src/components/customize/theme-io.tsx +245 -0
  29. package/src/components/customize/type-scale.tsx +134 -0
  30. package/src/components/customize-tab.tsx +502 -0
  31. package/src/components/home-tab.tsx +1227 -0
  32. package/src/components/layers-tab.tsx +225 -0
  33. package/src/components/ui/alert.tsx +5 -1
  34. package/src/hooks/use-global-design-controls.ts +117 -0
  35. package/src/hooks/use-global-mono-font.ts +73 -0
  36. package/src/hooks/use-global-primary-color.ts +544 -0
  37. package/src/hooks/use-global-sans-font.ts +98 -0
  38. package/src/hooks/use-global-serif-font.ts +77 -0
  39. package/src/hooks/use-global-theme.ts +259 -0
  40. package/src/hooks/use-global-type-scale.ts +141 -0
  41. package/src/hooks/use-sync-type-scale.ts +51 -0
  42. package/src/hooks/use-token-overrides.ts +98 -0
  43. package/src/styles.css +20 -5
  44. package/src/tokens.json +5 -5
@@ -0,0 +1,152 @@
1
+ import type { Metadata } from "next";
2
+ import { Atkinson_Hyperlegible, Inter, JetBrains_Mono, Lora, Source_Serif_4 } from "next/font/google";
3
+ import "@/styles/globals.css";
4
+ import Providers from "./providers";
5
+ import { FontReady } from "./font-ready";
6
+
7
+ // next/font self-hosts these and emits preload links automatically, so the
8
+ // browser has the woff2 in hand before first paint — kills FOUT on the
9
+ // showcase app. The published @import in packages/core/src/styles.css stays
10
+ // untouched so npm consumers still get the canonical theme out of the box.
11
+ const atkinson = Atkinson_Hyperlegible({
12
+ subsets: ["latin"],
13
+ weight: ["400", "700"],
14
+ display: "swap",
15
+ variable: "--font-atkinson",
16
+ });
17
+ const inter = Inter({
18
+ subsets: ["latin"],
19
+ display: "swap",
20
+ variable: "--font-inter",
21
+ });
22
+ const jetbrainsMono = JetBrains_Mono({
23
+ subsets: ["latin"],
24
+ display: "swap",
25
+ variable: "--font-jetbrains",
26
+ });
27
+ const lora = Lora({
28
+ subsets: ["latin"],
29
+ display: "swap",
30
+ variable: "--font-lora",
31
+ });
32
+ const sourceSerif = Source_Serif_4({
33
+ subsets: ["latin"],
34
+ display: "swap",
35
+ variable: "--font-source-serif",
36
+ });
37
+
38
+ export const metadata: Metadata = {
39
+ title: "BADS Design System",
40
+ description: "Interactive design system and component dashboard",
41
+ };
42
+
43
+ export default function RootLayout({
44
+ children,
45
+ }: {
46
+ children: React.ReactNode;
47
+ }) {
48
+ return (
49
+ <html
50
+ lang="en"
51
+ suppressHydrationWarning
52
+ // `fonts-loading` is removed by <FontReady /> on mount once
53
+ // document.fonts.ready resolves. CSS keeps body opacity 0 until then,
54
+ // killing the FOUT "jump" when web fonts swap in over system-ui.
55
+ className={`fonts-loading ${atkinson.variable} ${inter.variable} ${jetbrainsMono.variable} ${lora.variable} ${sourceSerif.variable}`}
56
+ >
57
+ <head>
58
+ <link
59
+ rel="preload"
60
+ href="/fonts/HyperlegibleSans-Regular.woff2"
61
+ as="font"
62
+ type="font/woff2"
63
+ crossOrigin=""
64
+ />
65
+ <link
66
+ rel="preload"
67
+ href="/fonts/HyperlegibleSans-Bold.woff2"
68
+ as="font"
69
+ type="font/woff2"
70
+ crossOrigin=""
71
+ />
72
+ <script
73
+ dangerouslySetInnerHTML={{
74
+ __html: `
75
+ (function() {
76
+ try {
77
+ // Reference next/font's preloaded variables (--font-atkinson etc.)
78
+ // first so the browser uses the already-fetched woff2 from the
79
+ // very first paint. Fall back to system-ui if next/font hasn't
80
+ // initialized yet.
81
+ var SANS = {
82
+ hyperlegible: "'Hyperlegible Sans', ui-sans-serif, sans-serif, system-ui",
83
+ atkinson: "var(--font-atkinson), 'Atkinson Hyperlegible', ui-sans-serif, sans-serif, system-ui",
84
+ inter: "var(--font-inter), 'Inter', ui-sans-serif, sans-serif, system-ui",
85
+ system: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif"
86
+ };
87
+ var SERIF = {
88
+ georgia: "Georgia, ui-serif, serif",
89
+ lora: "var(--font-lora), 'Lora', Georgia, ui-serif, serif",
90
+ "source-serif": "var(--font-source-serif), 'Source Serif 4', Georgia, ui-serif, serif",
91
+ system: "ui-serif, Georgia, Cambria, 'Times New Roman', Times, serif"
92
+ };
93
+ var MONO = {
94
+ jetbrains: "var(--font-jetbrains), 'JetBrains Mono', ui-monospace, monospace",
95
+ "ibm-plex": "'IBM Plex Mono', ui-monospace, monospace",
96
+ "fira-code": "'Fira Code', ui-monospace, monospace",
97
+ system: "ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace"
98
+ };
99
+ var STEPS = {
100
+ "text-xs": -2,
101
+ "text-sm": -1,
102
+ "text-base": 0,
103
+ "text-lg": 1,
104
+ "text-xl": 2,
105
+ "text-2xl": 3,
106
+ "text-3xl": 4
107
+ };
108
+ var s = document.documentElement.style;
109
+ var sans = localStorage.getItem("BADS.sansFont");
110
+ if (sans && SANS[sans]) s.setProperty("--font-sans", SANS[sans]);
111
+ var serif = localStorage.getItem("BADS.serifFont");
112
+ if (serif && SERIF[serif]) s.setProperty("--font-serif", SERIF[serif]);
113
+ var mono = localStorage.getItem("BADS.monoFont");
114
+ if (mono && MONO[mono]) s.setProperty("--font-mono", MONO[mono]);
115
+ var dc = localStorage.getItem("BADS.designControls");
116
+ if (dc) {
117
+ try {
118
+ var d = JSON.parse(dc);
119
+ if (typeof d.radius === "number") s.setProperty("--radius", d.radius + "rem");
120
+ if (typeof d.spacing === "number") s.setProperty("--spacing", d.spacing + "rem");
121
+ if (typeof d.letterSpacing === "number") s.setProperty("--tracking-offset", d.letterSpacing + "em");
122
+ if (typeof d.shadowOpacity === "number") s.setProperty("--shadow-opacity", d.shadowOpacity.toFixed(2));
123
+ } catch (e) {}
124
+ }
125
+ var ts = localStorage.getItem("BADS.typeScale");
126
+ var base = 18;
127
+ var ratio = 1.125;
128
+ if (ts) {
129
+ try {
130
+ var t = JSON.parse(ts);
131
+ if (typeof t.base === "number") base = t.base;
132
+ if (typeof t.ratio === "number") ratio = t.ratio;
133
+ } catch (e) {}
134
+ }
135
+ for (var name in STEPS) {
136
+ var step = STEPS[name];
137
+ var size = base * Math.pow(ratio, step);
138
+ s.setProperty("--" + name + "-size", size.toFixed(2) + "px");
139
+ }
140
+ } catch (e) {}
141
+ })();
142
+ `,
143
+ }}
144
+ />
145
+ </head>
146
+ <body>
147
+ <FontReady />
148
+ <Providers>{children}</Providers>
149
+ </body>
150
+ </html>
151
+ );
152
+ }
@@ -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
+ }