@behavioral-agentic-design-system/core 0.5.0 → 0.7.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 (61) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +39 -7
  3. package/scripts/bads-sync.mjs +1 -1
  4. package/scripts/build-fonts.cjs +97 -0
  5. package/scripts/build-tokens.cjs +202 -10
  6. package/src/api/brand-fonts.ts +301 -0
  7. package/src/api/brand-mark.ts +146 -0
  8. package/src/api/layers/file.ts +8 -5
  9. package/src/api/layers.ts +27 -4
  10. package/src/api/site-auth.ts +50 -0
  11. package/src/app/preview/cards/page.tsx +1 -1
  12. package/src/app/preview/components/page.tsx +78 -1
  13. package/src/app/preview/icons/page.tsx +5 -0
  14. package/src/app/shell.tsx +105 -39
  15. package/src/app/site-login/page.tsx +82 -0
  16. package/src/brand-fonts.css +5 -0
  17. package/src/components/Foundations/Motion.stories.tsx +66 -0
  18. package/src/components/brand-mark.tsx +64 -0
  19. package/src/components/customize/brand-mark-section.tsx +265 -0
  20. package/src/components/customize/font-pickers.tsx +293 -0
  21. package/src/components/customize/letter-spacing.tsx +3 -2
  22. package/src/components/customize/save-bar.tsx +11 -5
  23. package/src/components/customize/type-scale.tsx +3 -2
  24. package/src/components/customize-tab.tsx +330 -24
  25. package/src/components/dev-identity-badge.tsx +92 -0
  26. package/src/components/home-tab.tsx +1291 -380
  27. package/src/components/layers-tab.tsx +179 -12
  28. package/src/components/ui/alert.tsx +10 -2
  29. package/src/components/ui/bottom-sheet.tsx +124 -0
  30. package/src/components/ui/button.tsx +2 -2
  31. package/src/components/ui/calendar.tsx +1 -1
  32. package/src/components/ui/chart.tsx +118 -7
  33. package/src/components/ui/checkbox.tsx +3 -2
  34. package/src/components/ui/dialog.tsx +3 -3
  35. package/src/components/ui/index.ts +1 -0
  36. package/src/components/ui/radio-group.tsx +4 -3
  37. package/src/components/ui/sheet.tsx +1 -1
  38. package/src/components/ui/sidebar.tsx +6 -1
  39. package/src/components/ui/sonner.tsx +18 -0
  40. package/src/components/ui/switch.tsx +9 -3
  41. package/src/components/ui/tabs.tsx +7 -1
  42. package/src/fonts/HyperlegibleSans-Bold.woff2 +0 -0
  43. package/src/fonts/HyperlegibleSans-BoldItalic.woff2 +0 -0
  44. package/src/fonts/HyperlegibleSans-Italic.woff2 +0 -0
  45. package/src/fonts/HyperlegibleSans-Medium.woff2 +0 -0
  46. package/src/fonts/HyperlegibleSans-MediumItalic.woff2 +0 -0
  47. package/src/fonts/HyperlegibleSans-Regular.woff2 +0 -0
  48. package/src/fonts/InterVariable-Italic.woff2 +0 -0
  49. package/src/fonts/InterVariable.woff2 +0 -0
  50. package/src/fonts.css +99 -0
  51. package/src/hooks/use-global-brand-mark.ts +64 -0
  52. package/src/hooks/use-global-mono-font.ts +13 -3
  53. package/src/hooks/use-global-primary-color.ts +192 -9
  54. package/src/hooks/use-global-sans-font.ts +5 -3
  55. package/src/hooks/use-global-serif-font.ts +13 -3
  56. package/src/lib/storage.ts +29 -0
  57. package/src/lib/svg-sanitize.ts +272 -0
  58. package/src/styles.css +126 -6
  59. package/src/tokens.json +100 -9
  60. package/src/app/preview/mail/page.tsx +0 -4
  61. package/src/app/preview/pricing/page.tsx +0 -4
package/src/app/shell.tsx CHANGED
@@ -1,15 +1,35 @@
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";
13
33
 
14
34
  /**
15
35
  * Iframe-hosted preview surface. Listens for the parent's dark-mode state and
@@ -48,27 +68,31 @@ export function IframePreview({
48
68
  syncDarkMode();
49
69
  }, [syncDarkMode]);
50
70
 
71
+ // Single-scrollbar policy: the iframe fills its container vertically and
72
+ // owns the vertical scrollbar (its own document scrolls). The outer wrapper
73
+ // only scrolls horizontally, and only when `minWidth` forces the inner
74
+ // track wider than the viewport (Dashboard, Mail). Two layers of vertical
75
+ // scrolling produced the "double scrollbar on the right" bug — keeping the
76
+ // overflow on a single axis fixes it.
51
77
  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>
78
+ <div className="size-full relative overflow-x-auto overflow-y-hidden">
79
+ <div
80
+ style={{ minWidth: minWidth || "100%" }}
81
+ className="h-full w-full"
82
+ >
83
+ <iframe
84
+ ref={iframeRef}
85
+ src={initialSrcRef.current}
86
+ onLoad={() => {
87
+ syncDarkMode();
88
+ setLoaded(true);
89
+ }}
90
+ className="block h-full w-full border-0 transition-opacity duration-300 ease-out"
91
+ style={{
92
+ opacity: loaded ? 1 : 0,
93
+ }}
94
+ />
95
+ </div>
72
96
  </div>
73
97
  );
74
98
  }
@@ -80,8 +104,24 @@ export function IframePreview({
80
104
  */
81
105
  export type ShellTabContext = {
82
106
  dark: boolean;
107
+ goToTab: (value: string) => void;
83
108
  };
84
109
 
110
+ /**
111
+ * Lets tab content request a tab switch without prop-drilling through the
112
+ * render tree. Use when a button deep inside a tab (e.g. "Customize" CTA on
113
+ * the Home tab) needs to jump to another tab. The `goToTab` render-prop is
114
+ * still the right call for top-level tab components that already receive
115
+ * ShellTabContext directly.
116
+ *
117
+ * Falls back to a no-op outside Shell so Home stays usable in storybook.
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,14 +148,13 @@ 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" /> },
115
- { value: "mail", label: "Mail", hidden: "md", render: ({ dark }) => <IframePreview dark={dark} src="/preview/mail" minWidth="1300px" /> },
116
- { value: "pricing", label: "Pricing", render: ({ dark }) => <IframePreview dark={dark} src="/preview/pricing" /> },
117
155
  { value: "layers", label: "Layers", render: () => <LayersTab /> },
118
156
  { value: "colors", label: "Customize", render: () => <CustomizeTab /> },
157
+ { value: "icons", label: "Icons", render: ({ dark }) => <IframePreview dark={dark} src="/preview/icons" /> },
119
158
  ];
120
159
 
121
160
  /**
@@ -176,15 +215,25 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
176
215
  const prefersReduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
177
216
  const supports = typeof document !== "undefined" && "startViewTransition" in document;
178
217
 
179
- // Sync every iframe preview's dark class right now so its DOM matches the
180
- // new theme at the same instant the parent does — otherwise the iframe lags
181
- // behind React's useEffect and the transition captures stale iframe content.
218
+ // Sync iframes in the currently-active tab right now so the visible
219
+ // surface matches the new theme at the same instant the parent does —
220
+ // otherwise the iframe lags behind React's useEffect and the view
221
+ // transition captures stale content. Off-screen iframes (other tabs that
222
+ // were preloaded into the DOM) catch up via the per-IframePreview
223
+ // useEffect when React commits the new `dark` prop. Skipping the
224
+ // synchronous sync for those iframes matters when one of them holds
225
+ // expensive content (the Icons tab renders ~1,700 SVGs whose
226
+ // currentColor strokes all recompute on `.dark` toggle) — paying for
227
+ // that recompute every toggle, even when not visible, dominated the
228
+ // perceived toggle latency.
182
229
  const syncIframes = () => {
183
- document.querySelectorAll("iframe").forEach((f) => {
184
- try {
185
- f.contentDocument?.documentElement.classList.toggle("dark", next);
186
- } catch {}
187
- });
230
+ document
231
+ .querySelectorAll<HTMLIFrameElement>('[data-state="active"] iframe')
232
+ .forEach((f) => {
233
+ try {
234
+ f.contentDocument?.documentElement.classList.toggle("dark", next);
235
+ } catch {}
236
+ });
188
237
  };
189
238
  const syncHost = () => {
190
239
  root.classList.toggle("dark", next);
@@ -205,17 +254,19 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
205
254
  });
206
255
  };
207
256
 
208
- const ctx: ShellTabContext = { dark };
257
+ const ctx: ShellTabContext = { dark, goToTab: (value: string) => setActiveTab(value) };
258
+ const navValue = useMemo<ShellNav>(() => ({ setTab: setActiveTab }), []);
209
259
 
210
260
  return (
261
+ <ShellNavContext.Provider value={navValue}>
211
262
  <div className="min-h-screen bg-background flex flex-col">
212
263
  <header className="border-b bg-card shrink-0">
213
264
  <div className="flex h-14 items-center px-6">
214
265
  <div className="flex items-center gap-2">
215
266
  <div
216
- className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary"
267
+ className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary text-primary-foreground"
217
268
  >
218
- <Sparkles className="h-4 w-4 text-primary-foreground" />
269
+ <BrandMark size={20} />
219
270
  </div>
220
271
  <span className="text-lg font-semibold">{brand.name}</span>
221
272
  <Badge variant="outline" className="ml-2 text-xs">{brand.tagline}</Badge>
@@ -226,13 +277,27 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
226
277
  variant="ghost"
227
278
  size="sm"
228
279
  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)"
280
+ title="Open Storybook (requires `pnpm dev` or `pnpm storybook` to be running on :6080)"
230
281
  >
231
- <a href="http://localhost:6006" target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
282
+ <a href="http://localhost:6080" target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
232
283
  <BookOpen className="h-4 w-4 transition-all group-hover:scale-110" strokeWidth={1.5} />
233
284
  <span className="text-xs font-medium">Storybook</span>
234
285
  </a>
235
286
  </Button>
287
+ {brand.repo && (
288
+ <Button
289
+ asChild
290
+ variant="ghost"
291
+ size="sm"
292
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-foreground hover:!text-background hover:border-foreground"
293
+ title={`Open ${brand.repo.replace(/^https?:\/\//, "")} on GitHub`}
294
+ >
295
+ <a href={brand.repo} target="_blank" rel="noreferrer" aria-label="Open GitHub repo in a new tab">
296
+ <GithubMark className="h-4 w-4 transition-all group-hover:scale-110" />
297
+ <span className="text-xs font-medium">GitHub</span>
298
+ </a>
299
+ </Button>
300
+ )}
236
301
  <Button
237
302
  variant="ghost"
238
303
  size="icon"
@@ -289,5 +354,6 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
289
354
  </section>
290
355
  </Tabs>
291
356
  </div>
357
+ </ShellNavContext.Provider>
292
358
  );
293
359
  }
@@ -0,0 +1,82 @@
1
+ import { brand } from "@/brand.config";
2
+ import { BrandMark } from "@behavioral-agentic-design-system/core/components/brand-mark";
3
+ import {
4
+ Button,
5
+ Input,
6
+ } from "@behavioral-agentic-design-system/core/components/ui";
7
+ import {
8
+ Field,
9
+ FieldError,
10
+ FieldLabel,
11
+ } from "@behavioral-agentic-design-system/core/components/ui/field";
12
+
13
+ // Server-rendered password gate for the BADS demo deployment. Activated by
14
+ // middleware.ts when SITE_PASSWORD is set on the deployment target. Page is
15
+ // nested under the root layout so it inherits brand fonts + tokens — the
16
+ // gate feels like part of the system, not a generic basic-auth pop-up.
17
+
18
+ export default async function SiteLoginPage({
19
+ searchParams,
20
+ }: {
21
+ searchParams: Promise<{ next?: string; error?: string }>;
22
+ }) {
23
+ const { next = "/", error } = await searchParams;
24
+
25
+ return (
26
+ <main className="grid min-h-screen place-items-center bg-background px-6 py-12">
27
+ <div className="w-full max-w-sm space-y-8">
28
+ <div className="flex items-center gap-3">
29
+ <BrandMark className="size-8" />
30
+ <div className="flex flex-col">
31
+ <span className="text-base font-medium leading-tight">
32
+ {brand.name}
33
+ </span>
34
+ <span className="text-xs text-muted-foreground">
35
+ {brand.tagline}
36
+ </span>
37
+ </div>
38
+ </div>
39
+
40
+ <div className="space-y-2">
41
+ <h1 className="text-2xl font-semibold tracking-tight">
42
+ Password required
43
+ </h1>
44
+ <p className="text-sm text-muted-foreground">
45
+ This preview is gated while we tune it for the next round of
46
+ client reviews. Enter the shared password to continue.
47
+ </p>
48
+ </div>
49
+
50
+ <form
51
+ method="POST"
52
+ action="/api/site-auth"
53
+ className="space-y-4"
54
+ autoComplete="off"
55
+ >
56
+ <input type="hidden" name="next" value={next} />
57
+ <Field>
58
+ <FieldLabel htmlFor="site-password">Password</FieldLabel>
59
+ <Input
60
+ id="site-password"
61
+ name="password"
62
+ type="password"
63
+ autoComplete="off"
64
+ autoFocus
65
+ required
66
+ aria-invalid={error ? "true" : "false"}
67
+ aria-describedby={error ? "site-password-error" : undefined}
68
+ />
69
+ {error && (
70
+ <FieldError id="site-password-error">
71
+ That password didn&apos;t match. Try again.
72
+ </FieldError>
73
+ )}
74
+ </Field>
75
+ <Button type="submit" size="xl" className="w-full">
76
+ Continue
77
+ </Button>
78
+ </form>
79
+ </div>
80
+ </main>
81
+ );
82
+ }
@@ -0,0 +1,5 @@
1
+ /* GENERATED FROM brand-fonts.json — DO NOT EDIT BY HAND.
2
+ * Run `pnpm build:fonts` after changing brand-fonts.json (this happens
3
+ * automatically when fonts are added/removed via the Customize tab). */
4
+
5
+ /* No brand fonts registered yet. Add one via the Customize tab → font picker → "+". */
@@ -1,4 +1,5 @@
1
1
  import type { Meta, StoryObj } from "@storybook/react";
2
+ import type { CSSProperties } from "react";
2
3
  import { useState } from "react";
3
4
 
4
5
  const meta: Meta = {
@@ -128,6 +129,71 @@ export const Easings: Story = {
128
129
  },
129
130
  };
130
131
 
132
+ // Semantic motion layer — intent-named pairs emitted as --motion-<intent>-*.
133
+ // Each demo animates the property the intent is meant for, driven entirely by
134
+ // the CSS vars (no hardcoded numbers), so it tracks tokens.json automatically.
135
+ const SEMANTIC_MOTIONS = [
136
+ { name: "fade", prop: "opacity", from: "0", to: "1", note: "Overlays, content swaps, in-place appear" },
137
+ { name: "slide", prop: "transform", from: "translateY(24px)", to: "translateY(0)", note: "Sheets, drawers, toasts from an edge" },
138
+ { name: "scale", prop: "transform", from: "scale(0.85)", to: "scale(1)", note: "Popovers, menus, tooltips from origin" },
139
+ { name: "expand", prop: "transform", from: "scaleY(0)", to: "scaleY(1)", note: "Accordions, collapsibles, disclosure" },
140
+ { name: "spin", prop: "transform", from: "rotate(0deg)", to: "rotate(360deg)", note: "Loaders, busy chevrons (loops)" },
141
+ ] as const;
142
+
143
+ export const SemanticMotion: Story = {
144
+ parameters: {
145
+ docs: {
146
+ description: {
147
+ story:
148
+ "Intent-named motion: reach for --motion-<intent>-duration / -ease instead of raw numbers. Each box animates with only its intent's CSS vars. See layer-6 motion.md for the decision tree.",
149
+ },
150
+ },
151
+ },
152
+ render: () => {
153
+ const [tick, setTick] = useState(0);
154
+ return (
155
+ <div className="p-8 bg-background">
156
+ <div className="flex items-baseline justify-between mb-6">
157
+ <h3 className="text-sm font-semibold text-muted-foreground">Semantic motion (by intent)</h3>
158
+ <button
159
+ type="button"
160
+ onClick={() => setTick((t) => t + 1)}
161
+ className="text-sm font-medium underline underline-offset-4 hover:text-primary"
162
+ >
163
+ Replay
164
+ </button>
165
+ </div>
166
+ <div className="space-y-6">
167
+ {SEMANTIC_MOTIONS.map((m) => (
168
+ <div key={m.name} className="flex items-center gap-6">
169
+ <div className="w-44 shrink-0">
170
+ <code className="text-xs font-mono text-foreground">--motion-{m.name}-*</code>
171
+ <p className="text-xs text-muted-foreground font-mono mt-0.5">
172
+ duration / ease
173
+ </p>
174
+ </div>
175
+ <div className="relative h-12 w-12">
176
+ <div
177
+ key={tick}
178
+ className="h-12 w-12 rounded-md bg-primary"
179
+ style={{
180
+ transition: `${m.prop} var(--motion-${m.name}-duration) var(--motion-${m.name}-ease)`,
181
+ transformOrigin: m.name === "expand" ? "top" : "center",
182
+ // Flip from "from" to "to" on each replay (key remount) so
183
+ // the transition plays. Cast covers the dynamic prop key.
184
+ [m.prop]: tick % 2 === 0 ? m.to : m.from,
185
+ } as CSSProperties}
186
+ />
187
+ </div>
188
+ <p className="text-sm text-muted-foreground">{m.note}</p>
189
+ </div>
190
+ ))}
191
+ </div>
192
+ </div>
193
+ );
194
+ },
195
+ };
196
+
131
197
  export const ReducedMotion: Story = {
132
198
  parameters: {
133
199
  docs: {
@@ -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
+ }