@behavioral-agentic-design-system/core 0.4.0 → 0.6.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 +16 -8
- package/scripts/build-fonts.cjs +90 -0
- package/scripts/build-tokens.cjs +99 -8
- package/src/api/brand-fonts.ts +280 -0
- package/src/api/brand-mark.ts +146 -0
- package/src/api/layers/file.ts +4 -2
- package/src/api/layers.ts +23 -1
- package/src/app/font-ready.tsx +1 -1
- package/src/app/layout.tsx +3 -9
- package/src/app/page.tsx +9 -263
- package/src/app/preview/cards/page.tsx +1 -1
- package/src/app/preview/login/page.tsx +5 -0
- package/src/app/shell.tsx +354 -0
- package/src/components/admin-menu.stories.tsx +68 -0
- package/src/components/admin-menu.tsx +59 -0
- package/src/components/brand-mark.tsx +64 -0
- package/src/components/customize/brand-mark-section.tsx +265 -0
- package/src/components/customize/font-pickers.tsx +293 -0
- package/src/components/customize/save-bar.tsx +11 -5
- package/src/components/customize-tab.tsx +331 -26
- package/src/components/dev-identity-badge.tsx +92 -0
- package/src/components/home-tab.tsx +1022 -374
- package/src/components/layers-tab.tsx +38 -9
- package/src/components/ui/alert.tsx +10 -2
- package/src/components/ui/button.tsx +1 -1
- package/src/components/ui/calendar.tsx +1 -1
- package/src/components/ui/chart.tsx +13 -3
- package/src/components/ui/checkbox.tsx +1 -1
- package/src/components/ui/radio-group.tsx +1 -1
- package/src/components/ui/sidebar.tsx +6 -1
- package/src/components/ui/sonner.tsx +18 -0
- package/src/components/ui/switch.tsx +7 -1
- package/src/components/ui/tabs.tsx +1 -1
- package/src/hooks/use-global-brand-mark.ts +64 -0
- package/src/hooks/use-global-mono-font.ts +13 -3
- package/src/hooks/use-global-primary-color.ts +145 -8
- package/src/hooks/use-global-sans-font.ts +5 -3
- package/src/hooks/use-global-serif-font.ts +14 -4
- package/src/lib/storage.ts +31 -2
- package/src/lib/svg-sanitize.ts +272 -0
- package/src/styles.css +91 -46
- package/src/tokens.default.json +4 -4
- package/src/tokens.json +172 -78
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { NextResponse } from "next/server";
|
|
4
|
+
import { sanitizeSvg } from "@behavioral-agentic-design-system/core/lib/svg-sanitize";
|
|
5
|
+
|
|
6
|
+
const MARK_PATH = path.join(process.cwd(), "brand-mark.json");
|
|
7
|
+
const PUBLIC_PATH = path.join(process.cwd(), "public", "brand-mark.svg");
|
|
8
|
+
|
|
9
|
+
type MarkFile = {
|
|
10
|
+
$comment?: string;
|
|
11
|
+
svg: string | null;
|
|
12
|
+
original: string | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
async function readFile(): Promise<MarkFile> {
|
|
16
|
+
const raw = await fs.readFile(MARK_PATH, "utf8");
|
|
17
|
+
const parsed = JSON.parse(raw) as MarkFile;
|
|
18
|
+
return {
|
|
19
|
+
$comment: parsed.$comment,
|
|
20
|
+
svg: parsed.svg ?? null,
|
|
21
|
+
original: parsed.original ?? null,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function writeFile(file: MarkFile) {
|
|
26
|
+
await fs.writeFile(MARK_PATH, JSON.stringify(file, null, 2) + "\n", "utf8");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function writePublic(svg: string | null) {
|
|
30
|
+
if (svg === null) {
|
|
31
|
+
try {
|
|
32
|
+
await fs.unlink(PUBLIC_PATH);
|
|
33
|
+
} catch {
|
|
34
|
+
// already absent
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
await fs.mkdir(path.dirname(PUBLIC_PATH), { recursive: true });
|
|
39
|
+
await fs.writeFile(PUBLIC_PATH, svg, "utf8");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function GET() {
|
|
43
|
+
if (process.env.NODE_ENV !== "development") {
|
|
44
|
+
return NextResponse.json({ ok: false, error: "dev-only" }, { status: 403 });
|
|
45
|
+
}
|
|
46
|
+
try {
|
|
47
|
+
const file = await readFile();
|
|
48
|
+
return NextResponse.json({ ok: true, svg: file.svg, original: file.original });
|
|
49
|
+
} catch (err) {
|
|
50
|
+
return NextResponse.json(
|
|
51
|
+
{ ok: false, error: (err as Error).message },
|
|
52
|
+
{ status: 500 },
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export async function POST(request: Request) {
|
|
58
|
+
if (process.env.NODE_ENV !== "development") {
|
|
59
|
+
return NextResponse.json({ ok: false, error: "dev-only" }, { status: 403 });
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let body: { svg?: string };
|
|
63
|
+
try {
|
|
64
|
+
body = (await request.json()) as { svg?: string };
|
|
65
|
+
} catch {
|
|
66
|
+
return NextResponse.json({ ok: false, error: "Invalid JSON" }, { status: 400 });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const original = (body.svg ?? "").trim();
|
|
70
|
+
if (!original) {
|
|
71
|
+
return NextResponse.json(
|
|
72
|
+
{ ok: false, error: "Missing svg field" },
|
|
73
|
+
{ status: 400 },
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
if (original.length > 200_000) {
|
|
77
|
+
return NextResponse.json(
|
|
78
|
+
{ ok: false, error: "SVG exceeds 200KB cap" },
|
|
79
|
+
{ status: 413 },
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const result = sanitizeSvg(original);
|
|
84
|
+
if (!result.ok) {
|
|
85
|
+
return NextResponse.json({ ok: false, error: result.error }, { status: 400 });
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
let existing: MarkFile;
|
|
89
|
+
try {
|
|
90
|
+
existing = await readFile();
|
|
91
|
+
} catch {
|
|
92
|
+
existing = { svg: null, original: null };
|
|
93
|
+
}
|
|
94
|
+
const next: MarkFile = {
|
|
95
|
+
$comment: existing.$comment,
|
|
96
|
+
svg: result.svg,
|
|
97
|
+
original,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
await writeFile(next);
|
|
102
|
+
await writePublic(result.svg);
|
|
103
|
+
} catch (err) {
|
|
104
|
+
return NextResponse.json(
|
|
105
|
+
{ ok: false, error: `Write failed: ${(err as Error).message}` },
|
|
106
|
+
{ status: 500 },
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return NextResponse.json({
|
|
111
|
+
ok: true,
|
|
112
|
+
svg: next.svg,
|
|
113
|
+
original: next.original,
|
|
114
|
+
monotone: result.monotone,
|
|
115
|
+
colorCount: result.colorCount,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export async function DELETE() {
|
|
120
|
+
if (process.env.NODE_ENV !== "development") {
|
|
121
|
+
return NextResponse.json({ ok: false, error: "dev-only" }, { status: 403 });
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
let existing: MarkFile;
|
|
125
|
+
try {
|
|
126
|
+
existing = await readFile();
|
|
127
|
+
} catch {
|
|
128
|
+
existing = { svg: null, original: null };
|
|
129
|
+
}
|
|
130
|
+
const cleared: MarkFile = {
|
|
131
|
+
$comment: existing.$comment,
|
|
132
|
+
svg: null,
|
|
133
|
+
original: null,
|
|
134
|
+
};
|
|
135
|
+
try {
|
|
136
|
+
await writeFile(cleared);
|
|
137
|
+
await writePublic(null);
|
|
138
|
+
} catch (err) {
|
|
139
|
+
return NextResponse.json(
|
|
140
|
+
{ ok: false, error: `Write failed: ${(err as Error).message}` },
|
|
141
|
+
{ status: 500 },
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return NextResponse.json({ ok: true, svg: null, original: null });
|
|
146
|
+
}
|
package/src/api/layers/file.ts
CHANGED
|
@@ -7,10 +7,12 @@ const execAsync = promisify(exec);
|
|
|
7
7
|
const ROOT = process.cwd();
|
|
8
8
|
|
|
9
9
|
function isAllowed(rel: string) {
|
|
10
|
-
// Only allow paths inside layer-*/ to prevent traversal abuse.
|
|
10
|
+
// Only allow paths inside layer-*/ or specific allowlisted files to prevent traversal abuse.
|
|
11
11
|
const norm = path.normalize(rel);
|
|
12
12
|
if (norm.startsWith("..") || path.isAbsolute(norm)) return false;
|
|
13
|
-
|
|
13
|
+
const isLayerFile = /^layer-[\w-]+\//.test(norm) && /\.(md|json)$/.test(norm);
|
|
14
|
+
const isTokensFile = norm === "packages/core/src/tokens.json";
|
|
15
|
+
return isLayerFile || isTokensFile;
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
export async function GET(request: Request) {
|
package/src/api/layers.ts
CHANGED
|
@@ -29,6 +29,17 @@ function listFiles(dir: string): string[] {
|
|
|
29
29
|
return out;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
function sortLayerFiles(slug: string, files: string[]): string[] {
|
|
33
|
+
// Brand Voice: intro.md first, then framework.md, then others alphabetically
|
|
34
|
+
if (slug === "layer-1-brand-voice") {
|
|
35
|
+
const intro = files.find((f) => f.endsWith("intro.md"));
|
|
36
|
+
const framework = files.find((f) => f.endsWith("framework.md"));
|
|
37
|
+
const rest = files.filter((f) => !f.endsWith("intro.md") && !f.endsWith("framework.md")).sort();
|
|
38
|
+
return [intro, framework, ...rest].filter(Boolean) as string[];
|
|
39
|
+
}
|
|
40
|
+
return files.sort();
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
function prettifyLayerName(slug: string) {
|
|
33
44
|
// "layer-2-ethics-responsibility" → "2 · Ethics & Responsibility"
|
|
34
45
|
const [, num, ...rest] = slug.split("-");
|
|
@@ -43,7 +54,18 @@ export async function GET() {
|
|
|
43
54
|
const layers = listLayers().map((slug) => ({
|
|
44
55
|
slug,
|
|
45
56
|
label: prettifyLayerName(slug),
|
|
46
|
-
files: listFiles(path.join(ROOT, slug))
|
|
57
|
+
files: sortLayerFiles(slug, listFiles(path.join(ROOT, slug))),
|
|
47
58
|
}));
|
|
59
|
+
|
|
60
|
+
// Add tokens.json from Foundation layer (layer-3)
|
|
61
|
+
const foundationIndex = layers.findIndex((l) => l.slug === "layer-3-foundation");
|
|
62
|
+
if (foundationIndex !== -1) {
|
|
63
|
+
const tokensPath = path.join(ROOT, "packages/core/src/tokens.json");
|
|
64
|
+
if (fs.existsSync(tokensPath)) {
|
|
65
|
+
layers[foundationIndex].files.push("packages/core/src/tokens.json");
|
|
66
|
+
layers[foundationIndex].files = sortLayerFiles(layers[foundationIndex].slug, layers[foundationIndex].files);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
48
70
|
return Response.json({ layers });
|
|
49
71
|
}
|
package/src/app/font-ready.tsx
CHANGED
|
@@ -27,7 +27,7 @@ export function FontReady() {
|
|
|
27
27
|
|
|
28
28
|
let alreadyReady = false;
|
|
29
29
|
try {
|
|
30
|
-
alreadyReady = document.fonts.check("1em '
|
|
30
|
+
alreadyReady = document.fonts.check("1em 'Season'");
|
|
31
31
|
} catch {
|
|
32
32
|
// fonts.check throws if the font name is unknown — treat as not ready.
|
|
33
33
|
}
|
package/src/app/layout.tsx
CHANGED
|
@@ -93,16 +93,9 @@ export default function RootLayout({
|
|
|
93
93
|
<head>
|
|
94
94
|
<link
|
|
95
95
|
rel="preload"
|
|
96
|
-
href="/fonts/
|
|
96
|
+
href="/fonts/SeasonCollectionVF-TRIAL.ttf"
|
|
97
97
|
as="font"
|
|
98
|
-
type="font/
|
|
99
|
-
crossOrigin=""
|
|
100
|
-
/>
|
|
101
|
-
<link
|
|
102
|
-
rel="preload"
|
|
103
|
-
href="/fonts/HyperlegibleSans-Bold.woff2"
|
|
104
|
-
as="font"
|
|
105
|
-
type="font/woff2"
|
|
98
|
+
type="font/ttf"
|
|
106
99
|
crossOrigin=""
|
|
107
100
|
/>
|
|
108
101
|
<script
|
|
@@ -138,6 +131,7 @@ export default function RootLayout({
|
|
|
138
131
|
system: "ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif"
|
|
139
132
|
}, ${JSON.stringify(brandSansMap)});
|
|
140
133
|
var SERIF = {
|
|
134
|
+
"season-serif": "'Season Serif', 'Season', ui-serif, Georgia, serif",
|
|
141
135
|
georgia: "Georgia, ui-serif, serif",
|
|
142
136
|
lora: "var(--font-lora), 'Lora', Georgia, ui-serif, serif",
|
|
143
137
|
"source-serif": "var(--font-source-serif), 'Source Serif 4', Georgia, ui-serif, serif",
|
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
|
}
|