@behavioral-agentic-design-system/core 0.5.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.
Files changed (42) hide show
  1. package/package.json +15 -8
  2. package/scripts/build-fonts.cjs +90 -0
  3. package/scripts/build-tokens.cjs +84 -8
  4. package/src/api/brand-fonts.ts +280 -0
  5. package/src/api/brand-mark.ts +146 -0
  6. package/src/api/layers/file.ts +4 -2
  7. package/src/api/layers.ts +23 -1
  8. package/src/app/font-ready.tsx +1 -1
  9. package/src/app/layout.tsx +3 -9
  10. package/src/app/preview/cards/page.tsx +1 -1
  11. package/src/app/preview/login/page.tsx +5 -0
  12. package/src/app/shell.tsx +90 -29
  13. package/src/components/admin-menu.stories.tsx +68 -0
  14. package/src/components/admin-menu.tsx +59 -0
  15. package/src/components/brand-mark.tsx +64 -0
  16. package/src/components/customize/brand-mark-section.tsx +265 -0
  17. package/src/components/customize/font-pickers.tsx +293 -0
  18. package/src/components/customize/save-bar.tsx +11 -5
  19. package/src/components/customize-tab.tsx +329 -24
  20. package/src/components/dev-identity-badge.tsx +92 -0
  21. package/src/components/home-tab.tsx +1022 -374
  22. package/src/components/layers-tab.tsx +38 -9
  23. package/src/components/ui/alert.tsx +10 -2
  24. package/src/components/ui/button.tsx +1 -1
  25. package/src/components/ui/calendar.tsx +1 -1
  26. package/src/components/ui/chart.tsx +13 -3
  27. package/src/components/ui/checkbox.tsx +1 -1
  28. package/src/components/ui/radio-group.tsx +1 -1
  29. package/src/components/ui/sidebar.tsx +6 -1
  30. package/src/components/ui/sonner.tsx +18 -0
  31. package/src/components/ui/switch.tsx +7 -1
  32. package/src/components/ui/tabs.tsx +1 -1
  33. package/src/hooks/use-global-brand-mark.ts +64 -0
  34. package/src/hooks/use-global-mono-font.ts +13 -3
  35. package/src/hooks/use-global-primary-color.ts +145 -8
  36. package/src/hooks/use-global-sans-font.ts +5 -3
  37. package/src/hooks/use-global-serif-font.ts +14 -4
  38. package/src/lib/storage.ts +31 -2
  39. package/src/lib/svg-sanitize.ts +272 -0
  40. package/src/styles.css +76 -46
  41. package/src/tokens.default.json +4 -4
  42. 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
+ }
@@ -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
- return /^layer-[\w-]+\//.test(norm) && /\.(md|json)$/.test(norm);
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)).sort(),
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
  }
@@ -27,7 +27,7 @@ export function FontReady() {
27
27
 
28
28
  let alreadyReady = false;
29
29
  try {
30
- alreadyReady = document.fonts.check("1em 'Hyperlegible Sans'");
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
  }
@@ -93,16 +93,9 @@ export default function RootLayout({
93
93
  <head>
94
94
  <link
95
95
  rel="preload"
96
- href="/fonts/HyperlegibleSans-Regular.woff2"
96
+ href="/fonts/SeasonCollectionVF-TRIAL.ttf"
97
97
  as="font"
98
- type="font/woff2"
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",
@@ -1,7 +1,7 @@
1
1
  import Cards from "@/components/examples/cards";
2
2
  export default function CardsPreview() {
3
3
  return (
4
- <div className="@container h-full w-full">
4
+ <div className="@container h-full w-full bg-muted">
5
5
  <Cards />
6
6
  </div>
7
7
  );
@@ -0,0 +1,5 @@
1
+ import Login from "@/components/examples/login/login";
2
+
3
+ export default function LoginPreview() {
4
+ return <Login />;
5
+ }
package/src/app/shell.tsx CHANGED
@@ -1,15 +1,36 @@
1
1
  "use client";
2
2
 
3
- import { useState, useEffect, useRef, useCallback } from "react";
3
+ import { useState, useEffect, useRef, useCallback, createContext, useContext, useMemo } from "react";
4
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
5
  import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
7
6
  import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
8
- import { Sparkles, Sun, Moon, BookOpen } from "lucide-react";
7
+ import { Sun, Moon, BookOpen } from "lucide-react";
8
+
9
+ /**
10
+ * Inline GitHub mark. Lucide dropped brand icons (Github / Twitter / etc.) in
11
+ * recent versions, so embedding the SVG directly insulates us from future
12
+ * lucide changes and keeps the header link rendering as the universally-
13
+ * recognized octocat. Uses currentColor so the icon inherits the surrounding
14
+ * Button's text color (including the hover-inverted state).
15
+ */
16
+ function GithubMark({ className }: { className?: string }) {
17
+ return (
18
+ <svg
19
+ viewBox="0 0 24 24"
20
+ fill="currentColor"
21
+ aria-hidden="true"
22
+ className={className}
23
+ >
24
+ <path d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" />
25
+ </svg>
26
+ );
27
+ }
9
28
  import { brand } from "@/brand.config";
10
29
  import { CustomizeTab } from "@behavioral-agentic-design-system/core/components/customize-tab";
11
30
  import { LayersTab } from "@behavioral-agentic-design-system/core/components/layers-tab";
12
31
  import { HomeTab } from "@behavioral-agentic-design-system/core/components/home-tab";
32
+ import { BrandMark } from "@behavioral-agentic-design-system/core/components/brand-mark";
33
+ import { AdminMenu } from "@behavioral-agentic-design-system/core/components/admin-menu";
13
34
 
14
35
  /**
15
36
  * Iframe-hosted preview surface. Listens for the parent's dark-mode state and
@@ -48,27 +69,31 @@ export function IframePreview({
48
69
  syncDarkMode();
49
70
  }, [syncDarkMode]);
50
71
 
72
+ // Single-scrollbar policy: the iframe fills its container vertically and
73
+ // owns the vertical scrollbar (its own document scrolls). The outer wrapper
74
+ // only scrolls horizontally, and only when `minWidth` forces the inner
75
+ // track wider than the viewport (Dashboard, Mail). Two layers of vertical
76
+ // scrolling produced the "double scrollbar on the right" bug — keeping the
77
+ // overflow on a single axis fixes it.
51
78
  return (
52
- <div className="size-full relative">
53
- <ScrollArea className="size-full">
54
- <div style={{ minWidth: minWidth || "100%" }} className="h-full">
55
- <iframe
56
- ref={iframeRef}
57
- src={initialSrcRef.current}
58
- onLoad={() => {
59
- syncDarkMode();
60
- setLoaded(true);
61
- }}
62
- className="w-full border-0 transition-opacity duration-300 ease-out"
63
- style={{
64
- height: "100vh",
65
- minHeight: "800px",
66
- opacity: loaded ? 1 : 0,
67
- }}
68
- />
69
- </div>
70
- {minWidth && <ScrollBar orientation="horizontal" />}
71
- </ScrollArea>
79
+ <div className="size-full relative overflow-x-auto overflow-y-hidden">
80
+ <div
81
+ style={{ minWidth: minWidth || "100%" }}
82
+ className="h-full w-full"
83
+ >
84
+ <iframe
85
+ ref={iframeRef}
86
+ src={initialSrcRef.current}
87
+ onLoad={() => {
88
+ syncDarkMode();
89
+ setLoaded(true);
90
+ }}
91
+ className="block h-full w-full border-0 transition-opacity duration-300 ease-out"
92
+ style={{
93
+ opacity: loaded ? 1 : 0,
94
+ }}
95
+ />
96
+ </div>
72
97
  </div>
73
98
  );
74
99
  }
@@ -80,8 +105,23 @@ export function IframePreview({
80
105
  */
81
106
  export type ShellTabContext = {
82
107
  dark: boolean;
108
+ goToTab: (value: string) => void;
83
109
  };
84
110
 
111
+ /**
112
+ * Lets tab content request a tab switch without prop-drilling. Used by the
113
+ * "What's next" cards on the Home tab to jump straight into Components or
114
+ * Customize when a user clicks the corresponding affordance.
115
+ *
116
+ * Falls back to a no-op when consumed outside Shell (e.g. storybook), so the
117
+ * Home tab stays usable in isolation.
118
+ */
119
+ type ShellNav = { setTab: (value: string) => void };
120
+ const ShellNavContext = createContext<ShellNav | null>(null);
121
+ export function useShellNav(): ShellNav {
122
+ return useContext(ShellNavContext) ?? { setTab: () => {} };
123
+ }
124
+
85
125
  /**
86
126
  * One tab in the Shell. `render` is called once per first-visit and stays
87
127
  * mounted afterwards (sticky-mount + cross-fade — see TabsPanels).
@@ -108,7 +148,7 @@ export type ShellProps = {
108
148
  * they need custom surfaces alongside the built-ins.
109
149
  */
110
150
  export const DEFAULT_TABS: ShellTab[] = [
111
- { value: "home", label: "Home", render: () => <HomeTab /> },
151
+ { value: "home", label: "Home", render: ({ goToTab }) => <HomeTab onBrowseComponents={() => goToTab("components")} /> },
112
152
  { value: "components", label: "Components", render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" /> },
113
153
  { value: "cards", label: "Cards", render: ({ dark }) => <IframePreview dark={dark} src="/preview/cards" /> },
114
154
  { value: "dashboard", label: "Dashboard", hidden: "md", render: ({ dark }) => <IframePreview dark={dark} src="/preview/dashboard" minWidth="1400px" /> },
@@ -205,17 +245,19 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
205
245
  });
206
246
  };
207
247
 
208
- const ctx: ShellTabContext = { dark };
248
+ const ctx: ShellTabContext = { dark, goToTab: (value: string) => setActiveTab(value) };
249
+ const navValue = useMemo<ShellNav>(() => ({ setTab: setActiveTab }), []);
209
250
 
210
251
  return (
252
+ <ShellNavContext.Provider value={navValue}>
211
253
  <div className="min-h-screen bg-background flex flex-col">
212
254
  <header className="border-b bg-card shrink-0">
213
255
  <div className="flex h-14 items-center px-6">
214
256
  <div className="flex items-center gap-2">
215
257
  <div
216
- className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary"
258
+ className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary text-primary-foreground"
217
259
  >
218
- <Sparkles className="h-4 w-4 text-primary-foreground" />
260
+ <BrandMark size={20} />
219
261
  </div>
220
262
  <span className="text-lg font-semibold">{brand.name}</span>
221
263
  <Badge variant="outline" className="ml-2 text-xs">{brand.tagline}</Badge>
@@ -226,13 +268,27 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
226
268
  variant="ghost"
227
269
  size="sm"
228
270
  className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-foreground hover:!text-background hover:border-foreground"
229
- title="Open Storybook (requires `pnpm dev` or `pnpm storybook` to be running on :6006)"
271
+ title="Open Storybook (requires `pnpm dev` or `pnpm storybook` to be running on :6007)"
230
272
  >
231
- <a href="http://localhost:6006" target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
273
+ <a href="http://localhost:6007" target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
232
274
  <BookOpen className="h-4 w-4 transition-all group-hover:scale-110" strokeWidth={1.5} />
233
275
  <span className="text-xs font-medium">Storybook</span>
234
276
  </a>
235
277
  </Button>
278
+ {brand.repo && (
279
+ <Button
280
+ asChild
281
+ variant="ghost"
282
+ size="sm"
283
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-foreground hover:!text-background hover:border-foreground"
284
+ title={`Open ${brand.repo.replace(/^https?:\/\//, "")} on GitHub`}
285
+ >
286
+ <a href={brand.repo} target="_blank" rel="noreferrer" aria-label="Open GitHub repo in a new tab">
287
+ <GithubMark className="h-4 w-4 transition-all group-hover:scale-110" />
288
+ <span className="text-xs font-medium">GitHub</span>
289
+ </a>
290
+ </Button>
291
+ )}
236
292
  <Button
237
293
  variant="ghost"
238
294
  size="icon"
@@ -288,6 +344,11 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
288
344
  </div>
289
345
  </section>
290
346
  </Tabs>
347
+
348
+ <div className="fixed bottom-4 right-4 flex items-end gap-2">
349
+ <AdminMenu />
350
+ </div>
291
351
  </div>
352
+ </ShellNavContext.Provider>
292
353
  );
293
354
  }
@@ -0,0 +1,68 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { AdminMenu } from "./admin-menu";
3
+
4
+ const meta: Meta<typeof AdminMenu> = {
5
+ title: "Components/AdminMenu",
6
+ component: AdminMenu,
7
+ tags: ["autodocs"],
8
+ parameters: {
9
+ layout: "padded",
10
+ },
11
+ };
12
+
13
+ export default meta;
14
+ type Story = StoryObj<typeof meta>;
15
+
16
+ export const Default: Story = {};
17
+
18
+ export const WithLabel: Story = {
19
+ args: {
20
+ label: "Admin",
21
+ },
22
+ };
23
+
24
+ export const WithChildren: Story = {
25
+ render: () => (
26
+ <AdminMenu>
27
+ <div className="space-y-2">
28
+ <button className="w-full px-2 py-1.5 text-sm font-medium text-left rounded hover:bg-muted transition-colors">
29
+ View 1: Calm
30
+ </button>
31
+ <button className="w-full px-2 py-1.5 text-sm font-medium text-left rounded hover:bg-muted transition-colors">
32
+ View 2: Rich
33
+ </button>
34
+ <button className="w-full px-2 py-1.5 text-sm font-medium text-left rounded hover:bg-muted transition-colors">
35
+ View 3: Editorial
36
+ </button>
37
+ </div>
38
+ </AdminMenu>
39
+ ),
40
+ };
41
+
42
+ export const RealisticUse: Story = {
43
+ render: () => (
44
+ <div className="relative w-full h-96 border border-dashed border-muted-foreground/30 rounded-lg flex items-center justify-center bg-muted/20">
45
+ <div className="absolute bottom-4 right-4">
46
+ <AdminMenu>
47
+ <div className="space-y-2">
48
+ <div className="text-xs font-semibold text-muted-foreground uppercase tracking-wide mb-3 px-2">
49
+ Navigation Views
50
+ </div>
51
+ <button className="w-full px-2 py-1.5 text-sm rounded hover:bg-muted transition-colors text-left">
52
+ Calm View
53
+ </button>
54
+ <button className="w-full px-2 py-1.5 text-sm rounded hover:bg-muted transition-colors text-left">
55
+ Rich View
56
+ </button>
57
+ <button className="w-full px-2 py-1.5 text-sm rounded hover:bg-muted transition-colors text-left">
58
+ Editorial View
59
+ </button>
60
+ </div>
61
+ </AdminMenu>
62
+ </div>
63
+ <span className="text-sm text-muted-foreground">
64
+ AdminMenu positioned bottom-right with children
65
+ </span>
66
+ </div>
67
+ ),
68
+ };
@@ -0,0 +1,59 @@
1
+ "use client";
2
+
3
+ import { useState } from "react";
4
+ import { Settings, X } from "lucide-react";
5
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
6
+ import {
7
+ Popover,
8
+ PopoverContent,
9
+ PopoverTrigger,
10
+ } from "@behavioral-agentic-design-system/core/components/ui/popover";
11
+
12
+ export type AdminMenuChildren = React.ReactNode;
13
+
14
+ export type AdminMenuProps = {
15
+ children?: AdminMenuChildren;
16
+ /**
17
+ * Optional text shown next to the gear icon. When omitted the trigger
18
+ * stays icon-only (44×44px). When provided the button widens to fit the
19
+ * label while preserving the AAA touch target.
20
+ */
21
+ label?: string;
22
+ };
23
+
24
+ export function AdminMenu({ children, label }: AdminMenuProps) {
25
+ const [open, setOpen] = useState(false);
26
+ const hasLabel = Boolean(label);
27
+
28
+ // bg-card/95 + backdrop-blur-md mirrors the DevIdentityBadge treatment so
29
+ // the trigger stays legible on any background — flat surfaces, gradient
30
+ // hero blocks, photo backgrounds, anywhere a fork wants to drop it. Ghost
31
+ // variants disappear against busy backgrounds; the resting fill prevents
32
+ // that without changing the hover invert.
33
+ return (
34
+ <Popover open={open} onOpenChange={setOpen}>
35
+ <PopoverTrigger asChild>
36
+ <Button
37
+ variant="ghost"
38
+ size={hasLabel ? "sm" : "icon"}
39
+ className={
40
+ hasLabel
41
+ ? "group h-8 gap-1.5 border border-border bg-card/95 backdrop-blur-md shadow-sm hover:!bg-foreground hover:!text-background hover:border-foreground"
42
+ : "group size-8 border border-border bg-card/95 backdrop-blur-md shadow-sm hover:!bg-foreground hover:!text-background hover:border-foreground"
43
+ }
44
+ aria-label={open ? "Close admin menu" : "Open admin menu"}
45
+ >
46
+ {open ? (
47
+ <X className="h-4 w-4 transition-all group-hover:scale-110" strokeWidth={1.5} />
48
+ ) : (
49
+ <Settings className="h-4 w-4 transition-all group-hover:scale-110" strokeWidth={1.5} />
50
+ )}
51
+ {hasLabel && <span className="text-xs font-medium">{label}</span>}
52
+ </Button>
53
+ </PopoverTrigger>
54
+ <PopoverContent align="end" side="top" className="w-64 p-3">
55
+ {children}
56
+ </PopoverContent>
57
+ </Popover>
58
+ );
59
+ }
@@ -0,0 +1,64 @@
1
+ "use client";
2
+
3
+ import { Sparkles } from "lucide-react";
4
+ import { brand } from "@/brand.config";
5
+ import { cn } from "@behavioral-agentic-design-system/core/lib/utils";
6
+ import { useGlobalBrandMarkSvg } from "@behavioral-agentic-design-system/core/hooks/use-global-brand-mark";
7
+
8
+ /**
9
+ * Brand mark / logo component. Renders the saved SVG from the live brand-mark
10
+ * override when present, otherwise the SVG declared in brand-mark.json, and
11
+ * falls back to the default Sparkles icon when no mark is configured.
12
+ *
13
+ * Theming: when the source SVG is monotone, the API rewrites all `fill` /
14
+ * `stroke` to `currentColor` so the mark adopts the surrounding text color.
15
+ * Multi-color marks are preserved exactly.
16
+ *
17
+ * Sizing: `size` controls both width and height in pixels (default 32). The
18
+ * inner SVG fills the wrapper via CSS, so any viewBox is preserved.
19
+ */
20
+ export function BrandMark({
21
+ size = 32,
22
+ className,
23
+ title,
24
+ }: {
25
+ /** Pixel size for both width and height. Defaults to 32. */
26
+ size?: number;
27
+ className?: string;
28
+ /** Optional accessible label. Defaults to `${brand.name} logo`. */
29
+ title?: string;
30
+ }) {
31
+ const svg = useGlobalBrandMarkSvg();
32
+ const label = title ?? `${brand.name} logo`;
33
+
34
+ if (svg) {
35
+ return (
36
+ <span
37
+ role="img"
38
+ aria-label={label}
39
+ className={cn("inline-flex items-center justify-center [&>svg]:h-full [&>svg]:w-full", className)}
40
+ style={{ width: size, height: size }}
41
+ // SVG is sanitized server-side in /api/brand-mark before it lands in
42
+ // brand-mark.json — script tags, on* handlers, and dangerous URL
43
+ // protocols are stripped. Safe to inline render.
44
+ dangerouslySetInnerHTML={{ __html: svg }}
45
+ />
46
+ );
47
+ }
48
+
49
+ return (
50
+ <span
51
+ role="img"
52
+ aria-label={label}
53
+ className={cn("inline-flex items-center justify-center", className)}
54
+ style={{ width: size, height: size }}
55
+ >
56
+ <Sparkles
57
+ // Lucide expects px width/height. Match the wrapper so the icon fills it.
58
+ width={size * 0.55}
59
+ height={size * 0.55}
60
+ strokeWidth={1.5}
61
+ />
62
+ </span>
63
+ );
64
+ }