@behavioral-agentic-design-system/core 0.3.2 → 0.5.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 +2 -1
- package/scripts/build-tokens.cjs +29 -6
- package/src/app/layout.tsx +50 -7
- package/src/app/page.tsx +9 -263
- package/src/app/shell.tsx +293 -0
- package/src/components/bads-update-banner.tsx +3 -2
- package/src/components/customize/save-bar.tsx +12 -10
- package/src/components/customize-tab.tsx +2 -2
- package/src/hooks/use-global-design-controls.ts +4 -2
- package/src/hooks/use-global-mono-font.ts +4 -2
- package/src/hooks/use-global-primary-color.ts +15 -4
- package/src/hooks/use-global-sans-font.ts +4 -2
- package/src/hooks/use-global-serif-font.ts +4 -2
- package/src/hooks/use-global-theme.ts +4 -2
- package/src/hooks/use-global-type-scale.ts +4 -2
- package/src/hooks/use-sync-type-scale.ts +2 -1
- package/src/hooks/use-token-overrides.ts +4 -2
- package/src/lib/storage.ts +76 -0
- package/src/lib/theme-editor.ts +13 -4
- package/src/styles.css +31 -13
- package/src/tokens.json +19 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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
5
|
"license": "ISC",
|
|
6
6
|
"type": "module",
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
"./components/customize/*": "./src/components/customize/*.tsx",
|
|
36
36
|
"./components/Foundations/*": "./src/components/Foundations/*.tsx",
|
|
37
37
|
"./app/page": "./src/app/page.tsx",
|
|
38
|
+
"./app/shell": "./src/app/shell.tsx",
|
|
38
39
|
"./app/layout": "./src/app/layout.tsx",
|
|
39
40
|
"./app/providers": "./src/app/providers.tsx",
|
|
40
41
|
"./app/font-ready": "./src/app/font-ready.tsx",
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -209,9 +209,12 @@ const themeInline = `@theme inline {
|
|
|
209
209
|
--color-sidebar-border: var(--sidebar-border);
|
|
210
210
|
--color-sidebar-ring: var(--sidebar-ring);
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
212
|
+
/* font-sans/serif/mono intentionally NOT mapped here. Tailwind v4
|
|
213
|
+
compiles @theme inline self-references into a :root rule of the
|
|
214
|
+
same shape, which collides with the unlayered :root that sets the
|
|
215
|
+
actual font stack and resolves to an empty circular reference. The
|
|
216
|
+
:root above already defines --font-sans, and Tailwind picks it up
|
|
217
|
+
for the font-sans utility automatically. */
|
|
215
218
|
|
|
216
219
|
--radius-sm: calc(var(--radius) - 4px);
|
|
217
220
|
--radius-md: calc(var(--radius) - 2px);
|
|
@@ -414,6 +417,21 @@ const pkgCss = `${banner}
|
|
|
414
417
|
|
|
415
418
|
@import url('https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap');
|
|
416
419
|
|
|
420
|
+
/* Tailwind v4 only generates classes it scans. The shell components, hooks,
|
|
421
|
+
* and app routes shipped in this package use plenty of Tailwind classes that
|
|
422
|
+
* the consumer's own source code never references — Button's variants,
|
|
423
|
+
* Dialog's overlay, the customize tab's grid, etc. Without these @source
|
|
424
|
+
* paths a fresh fork imports styles.css and gets unstyled components because
|
|
425
|
+
* the classes never made it into the consumer's bundle.
|
|
426
|
+
*
|
|
427
|
+
* Paths resolve relative to this file (node_modules/@.../core/src/styles.css),
|
|
428
|
+
* so they cover the package's own source files in node_modules. Consumers
|
|
429
|
+
* don't need to touch their own Tailwind content config to get this working. */
|
|
430
|
+
@source "./components/**/*.{ts,tsx}";
|
|
431
|
+
@source "./app/**/*.{ts,tsx}";
|
|
432
|
+
@source "./hooks/**/*.{ts,tsx}";
|
|
433
|
+
@source "./lib/**/*.{ts,tsx}";
|
|
434
|
+
|
|
417
435
|
@custom-variant dark (&:is(.dark *));
|
|
418
436
|
|
|
419
437
|
:root {
|
|
@@ -469,9 +487,14 @@ const appCss = `${banner}
|
|
|
469
487
|
* shows up. next/font's preloaded vars come second as a self-hosted
|
|
470
488
|
* fallback for forks that haven't loaded their own woff2 yet — keeps
|
|
471
489
|
* the showcase styled even before fonts.css resolves. */
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
490
|
+
/* var() fallbacks (second arg) are required: when next/font isn't running
|
|
491
|
+
(Storybook, plain HTML test harness), --font-atkinson et al. are
|
|
492
|
+
undefined, and a bare var() reference invalidates the entire
|
|
493
|
+
custom-property value at computed-value time, leaving --font-sans
|
|
494
|
+
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;
|
|
496
|
+
--font-serif: ${fontSerif}, var(--font-source-serif, 'Source Serif 4'), 'Source Serif 4', Georgia, ui-serif, serif;
|
|
497
|
+
--font-mono: ${fontMono}, var(--font-jetbrains, 'JetBrains Mono'), 'JetBrains Mono', ui-monospace, monospace;
|
|
475
498
|
--font-size-scale: 1;
|
|
476
499
|
|
|
477
500
|
${lightVars}
|
package/src/app/layout.tsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Metadata } from "next";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import { Atkinson_Hyperlegible, Inter, JetBrains_Mono, Lora, Source_Serif_4 } from "next/font/google";
|
|
3
5
|
import "@/styles/globals.css";
|
|
4
6
|
import { brand } from "@/brand.config";
|
|
@@ -14,6 +16,28 @@ const brandSansMap = Object.fromEntries(
|
|
|
14
16
|
brand.fonts.map((f) => [f.id, f.stack]),
|
|
15
17
|
);
|
|
16
18
|
|
|
19
|
+
// Resolve the fork's slug at module load (server-side). Source priority:
|
|
20
|
+
// 1. .client-identity.json `slug` field (set by scripts/rename.mjs)
|
|
21
|
+
// 2. literal "bads" — upstream BADS itself, or unrenamed fresh forks
|
|
22
|
+
// Injected into the inline boot script as window.__BADS_SLUG__ so client
|
|
23
|
+
// hooks can derive their localStorage prefix without each one re-reading
|
|
24
|
+
// the filesystem (impossible in browser anyway).
|
|
25
|
+
function resolveSlug(): string {
|
|
26
|
+
try {
|
|
27
|
+
const raw = fs.readFileSync(
|
|
28
|
+
path.join(process.cwd(), ".client-identity.json"),
|
|
29
|
+
"utf8",
|
|
30
|
+
);
|
|
31
|
+
const ci = JSON.parse(raw) as { slug?: unknown };
|
|
32
|
+
if (typeof ci.slug === "string" && ci.slug.length > 0) return ci.slug;
|
|
33
|
+
} catch {
|
|
34
|
+
// file missing or unreadable — upstream BADS path
|
|
35
|
+
}
|
|
36
|
+
return "bads";
|
|
37
|
+
}
|
|
38
|
+
const slug = resolveSlug();
|
|
39
|
+
const slugUpper = slug.toUpperCase();
|
|
40
|
+
|
|
17
41
|
// next/font self-hosts these and emits preload links automatically, so the
|
|
18
42
|
// browser has the woff2 in hand before first paint — kills FOUT on the
|
|
19
43
|
// showcase app. The published @import in packages/core/src/styles.css stays
|
|
@@ -45,9 +69,11 @@ const sourceSerif = Source_Serif_4({
|
|
|
45
69
|
variable: "--font-source-serif",
|
|
46
70
|
});
|
|
47
71
|
|
|
72
|
+
// Title and description derive from brand.config so each fork's tab title and
|
|
73
|
+
// open-graph metadata reflects its own identity without overriding this file.
|
|
48
74
|
export const metadata: Metadata = {
|
|
49
|
-
title:
|
|
50
|
-
description: "Interactive design system and component dashboard",
|
|
75
|
+
title: brand.tagline ? `${brand.name} — ${brand.tagline}` : brand.name,
|
|
76
|
+
description: brand.tagline ?? "Interactive design system and component dashboard",
|
|
51
77
|
};
|
|
52
78
|
|
|
53
79
|
export default function RootLayout({
|
|
@@ -84,6 +110,23 @@ export default function RootLayout({
|
|
|
84
110
|
__html: `
|
|
85
111
|
(function() {
|
|
86
112
|
try {
|
|
113
|
+
// Set the slug as a global so the storage helper in @core/lib/storage
|
|
114
|
+
// resolves the prefix consistently in every hook on this page. This
|
|
115
|
+
// line must run BEFORE the Next.js bundle parses any module that
|
|
116
|
+
// calls storageKey(), which is why it lives in the inline <head>.
|
|
117
|
+
window.__BADS_SLUG__ = ${JSON.stringify(slug)};
|
|
118
|
+
var P = ${JSON.stringify(slugUpper)};
|
|
119
|
+
function k(suffix) {
|
|
120
|
+
var newKey = P + "." + suffix;
|
|
121
|
+
var fresh = localStorage.getItem(newKey);
|
|
122
|
+
if (fresh !== null) return fresh;
|
|
123
|
+
var legacy = localStorage.getItem("BADS." + suffix);
|
|
124
|
+
if (legacy !== null && P !== "BADS") {
|
|
125
|
+
try { localStorage.setItem(newKey, legacy); localStorage.removeItem("BADS." + suffix); } catch (e) {}
|
|
126
|
+
return legacy;
|
|
127
|
+
}
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
87
130
|
// Reference next/font's preloaded variables (--font-atkinson etc.)
|
|
88
131
|
// first so the browser uses the already-fetched woff2 from the
|
|
89
132
|
// very first paint. Fall back to system-ui if next/font hasn't
|
|
@@ -116,13 +159,13 @@ export default function RootLayout({
|
|
|
116
159
|
"text-3xl": 4
|
|
117
160
|
};
|
|
118
161
|
var s = document.documentElement.style;
|
|
119
|
-
var sans =
|
|
162
|
+
var sans = k("sansFont");
|
|
120
163
|
if (sans && SANS[sans]) s.setProperty("--font-sans", SANS[sans]);
|
|
121
|
-
var serif =
|
|
164
|
+
var serif = k("serifFont");
|
|
122
165
|
if (serif && SERIF[serif]) s.setProperty("--font-serif", SERIF[serif]);
|
|
123
|
-
var mono =
|
|
166
|
+
var mono = k("monoFont");
|
|
124
167
|
if (mono && MONO[mono]) s.setProperty("--font-mono", MONO[mono]);
|
|
125
|
-
var dc =
|
|
168
|
+
var dc = k("designControls");
|
|
126
169
|
if (dc) {
|
|
127
170
|
try {
|
|
128
171
|
var d = JSON.parse(dc);
|
|
@@ -132,7 +175,7 @@ export default function RootLayout({
|
|
|
132
175
|
if (typeof d.shadowOpacity === "number") s.setProperty("--shadow-opacity", d.shadowOpacity.toFixed(2));
|
|
133
176
|
} catch (e) {}
|
|
134
177
|
}
|
|
135
|
-
var ts =
|
|
178
|
+
var ts = k("typeScale");
|
|
136
179
|
var base = 18;
|
|
137
180
|
var ratio = 1.125;
|
|
138
181
|
if (ts) {
|
package/src/app/page.tsx
CHANGED
|
@@ -1,267 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
3
|
+
import { Shell, DEFAULT_TABS } from "./shell";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default Page surface for the BADS shell. Wraps Shell with the canonical tab
|
|
7
|
+
* list. Forks that want different tabs should write their own page.tsx that
|
|
8
|
+
* imports Shell from @behavioral-agentic-design-system/core/app/shell and
|
|
9
|
+
* passes a custom `tabs` array (optionally splicing into DEFAULT_TABS).
|
|
10
|
+
*/
|
|
73
11
|
export default function DesignSystemPreview() {
|
|
74
|
-
|
|
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
|
-
);
|
|
12
|
+
return <Shell tabs={DEFAULT_TABS} />;
|
|
267
13
|
}
|