@behavioral-agentic-design-system/core 0.48.0 → 0.49.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 (212) hide show
  1. package/package.json +1 -1
  2. package/scripts/build-tokens.cjs +24 -3
  3. package/scripts/ux-smoke.mjs +5 -1
  4. package/src/api/save-tokens.ts +170 -24
  5. package/src/app/layout.tsx +12 -1
  6. package/src/app/preview/components/page.tsx +25 -18
  7. package/src/app/preview/global-font-client.tsx +2 -0
  8. package/src/app/providers.tsx +2 -0
  9. package/src/app/shell.tsx +50 -156
  10. package/src/components/customize/brand-mark-section.tsx +65 -95
  11. package/src/components/customize/font-pickers.tsx +25 -2
  12. package/src/components/customize/save-bar.tsx +120 -7
  13. package/src/components/customize/theme-io.tsx +62 -21
  14. package/src/components/customize-tab.tsx +3 -1
  15. package/src/components/home-recent.tsx +58 -25
  16. package/src/components/motion/reveal.tsx +168 -12
  17. package/src/components/studio/control-panel.tsx +98 -19
  18. package/src/components/studio/import-theme-dialog.tsx +167 -0
  19. package/src/components/studio/tokens-panel.tsx +215 -0
  20. package/src/components/studio/types.ts +5 -2
  21. package/src/components/studio/use-studio-tweaks.ts +36 -4
  22. package/src/components/studio/use-token-edits.ts +160 -0
  23. package/src/components/ui/toggle-tip.tsx +38 -29
  24. package/src/data/component-stories.json +1214 -0
  25. package/src/data/docs-index.ts +7 -2
  26. package/src/data/hidden-views.ts +22 -0
  27. package/src/data/history.json +32 -32
  28. package/src/data/sticker-sheet.json +1878 -1821
  29. package/src/fonts/Figtree-OFL.txt +93 -0
  30. package/src/fonts/figtree-latin-ext-wght-normal.woff2 +0 -0
  31. package/src/fonts/figtree-latin-wght-italic.woff2 +0 -0
  32. package/src/fonts/figtree-latin-wght-normal.woff2 +0 -0
  33. package/src/fonts-cdn.css +3 -1
  34. package/src/fonts.css +44 -0
  35. package/src/hooks/use-global-heading-font.ts +104 -0
  36. package/src/hooks/use-global-sans-font.ts +8 -3
  37. package/src/hooks/use-global-theme.ts +2 -2
  38. package/src/hooks/use-token-overrides.ts +62 -14
  39. package/src/lib/css-color.ts +42 -0
  40. package/src/lib/storybook-url.ts +28 -0
  41. package/src/lib/theme-editor.ts +7 -1
  42. package/src/lib/theme-import.ts +99 -0
  43. package/src/lib/theme-transition.ts +93 -0
  44. package/src/lib/token-list.ts +133 -0
  45. package/src/lib/token-value.ts +31 -0
  46. package/src/stories/Accordion.stories.tsx +1 -1
  47. package/src/stories/Affix.stories.tsx +1 -1
  48. package/src/stories/AiBadge.stories.tsx +1 -1
  49. package/src/stories/Alert.stories.tsx +1 -1
  50. package/src/stories/AlertDialog.stories.tsx +1 -1
  51. package/src/stories/AngleSlider.stories.tsx +1 -1
  52. package/src/stories/AnnouncementBar.stories.tsx +2 -2
  53. package/src/stories/AspectRatio.stories.tsx +1 -1
  54. package/src/stories/Attachment.stories.tsx +1 -1
  55. package/src/stories/Autocomplete.stories.tsx +1 -1
  56. package/src/stories/Avatar.stories.tsx +1 -1
  57. package/src/stories/Badge.stories.tsx +1 -1
  58. package/src/stories/Blockquote.stories.tsx +1 -1
  59. package/src/stories/Burger.stories.tsx +1 -1
  60. package/src/stories/Button.stories.tsx +1 -1
  61. package/src/stories/ButtonGroup.stories.tsx +1 -1
  62. package/src/stories/Calendar.stories.tsx +1 -1
  63. package/src/stories/Callout.stories.tsx +1 -1
  64. package/src/stories/Canvas.stories.tsx +1 -1
  65. package/src/stories/Card.stories.tsx +1 -1
  66. package/src/stories/Carousel.stories.tsx +1 -1
  67. package/src/stories/Cascader.stories.tsx +1 -1
  68. package/src/stories/Chart.stories.tsx +1 -1
  69. package/src/stories/ChatBubble.stories.tsx +1 -1
  70. package/src/stories/ChatMarker.stories.tsx +1 -1
  71. package/src/stories/Checkbox.stories.tsx +1 -1
  72. package/src/stories/CheckboxCard.stories.tsx +1 -1
  73. package/src/stories/CheckboxGroup.stories.tsx +1 -1
  74. package/src/stories/Chip.stories.tsx +1 -1
  75. package/src/stories/CircularProgress.stories.tsx +1 -1
  76. package/src/stories/Clipboard.stories.tsx +1 -1
  77. package/src/stories/CloseButton.stories.tsx +1 -1
  78. package/src/stories/Code.stories.tsx +1 -1
  79. package/src/stories/Collapsible.stories.tsx +1 -1
  80. package/src/stories/ColorPicker.stories.tsx +1 -1
  81. package/src/stories/ColorSwatch.stories.tsx +1 -1
  82. package/src/stories/Combobox.stories.tsx +1 -1
  83. package/src/stories/Container.stories.tsx +1 -1
  84. package/src/stories/ContextMenu.stories.tsx +1 -1
  85. package/src/stories/CopyButton.stories.tsx +1 -1
  86. package/src/stories/DataList.stories.tsx +1 -1
  87. package/src/stories/DataTable.stories.tsx +1 -1
  88. package/src/stories/DateField.stories.tsx +1 -1
  89. package/src/stories/DatePicker.stories.tsx +1 -1
  90. package/src/stories/DateRangePicker.stories.tsx +1 -1
  91. package/src/stories/Dialog.stories.tsx +1 -1
  92. package/src/stories/Drawer.stories.tsx +1 -1
  93. package/src/stories/DropdownMenu.stories.tsx +1 -1
  94. package/src/stories/Editable.stories.tsx +1 -1
  95. package/src/stories/EmptyState.stories.tsx +1 -1
  96. package/src/stories/FacetedFilter.stories.tsx +1 -1
  97. package/src/stories/Field.stories.tsx +1 -1
  98. package/src/stories/Fieldset.stories.tsx +1 -1
  99. package/src/stories/FileButton.stories.tsx +1 -1
  100. package/src/stories/FileUpload.stories.tsx +1 -1
  101. package/src/stories/FloatLabel.stories.tsx +1 -1
  102. package/src/stories/FloatingActionButton.stories.tsx +1 -1
  103. package/src/stories/FloatingIndicator.stories.tsx +1 -1
  104. package/src/stories/FloatingPanel.stories.tsx +1 -1
  105. package/src/stories/FocusTrap.stories.tsx +1 -1
  106. package/src/stories/FormatByte.stories.tsx +1 -1
  107. package/src/stories/FormatDate.stories.tsx +1 -1
  108. package/src/stories/FormatNumber.stories.tsx +1 -1
  109. package/src/stories/FormatRelativeTime.stories.tsx +1 -1
  110. package/src/stories/GaugeChart.stories.tsx +1 -1
  111. package/src/stories/Grid.stories.tsx +1 -1
  112. package/src/stories/Heatmap.stories.tsx +1 -1
  113. package/src/stories/Highlight.stories.tsx +1 -1
  114. package/src/stories/HoverCard.stories.tsx +1 -1
  115. package/src/stories/Icon.stories.tsx +1 -1
  116. package/src/stories/Image.stories.tsx +1 -1
  117. package/src/stories/Indicator.stories.tsx +1 -1
  118. package/src/stories/InfiniteScroll.stories.tsx +1 -1
  119. package/src/stories/InlineEdit.stories.tsx +1 -1
  120. package/src/stories/Input.stories.tsx +1 -1
  121. package/src/stories/InputClearButton.stories.tsx +1 -1
  122. package/src/stories/InputGroup.stories.tsx +1 -1
  123. package/src/stories/JsonInput.stories.tsx +1 -1
  124. package/src/stories/Kbd.stories.tsx +1 -1
  125. package/src/stories/KeyboardShortcut.stories.tsx +1 -1
  126. package/src/stories/Label.stories.tsx +1 -1
  127. package/src/stories/List.stories.tsx +1 -1
  128. package/src/stories/Listbox.stories.tsx +1 -1
  129. package/src/stories/LoadingDots.stories.tsx +1 -1
  130. package/src/stories/LoadingOverlay.stories.tsx +1 -1
  131. package/src/stories/Mark.stories.tsx +1 -1
  132. package/src/stories/MarkdownPreview.stories.tsx +1 -1
  133. package/src/stories/Marquee.stories.tsx +1 -1
  134. package/src/stories/Masonry.stories.tsx +1 -1
  135. package/src/stories/Meter.stories.tsx +1 -1
  136. package/src/stories/MonthPicker.stories.tsx +1 -1
  137. package/src/stories/MotionToggle.stories.tsx +1 -1
  138. package/src/stories/MultiSelect.stories.tsx +1 -1
  139. package/src/stories/NativeSelect.stories.tsx +1 -1
  140. package/src/stories/NavigationProgress.stories.tsx +1 -1
  141. package/src/stories/Notification.stories.tsx +1 -1
  142. package/src/stories/NumberField.stories.tsx +1 -1
  143. package/src/stories/NumberInput.stories.tsx +1 -1
  144. package/src/stories/OtpInput.stories.tsx +1 -1
  145. package/src/stories/Overlay.stories.tsx +1 -1
  146. package/src/stories/PageHeader.stories.tsx +1 -1
  147. package/src/stories/PasswordInput.stories.tsx +1 -1
  148. package/src/stories/PasswordStrengthInput.stories.tsx +1 -1
  149. package/src/stories/PhoneInput.stories.tsx +1 -1
  150. package/src/stories/Pill.stories.tsx +1 -1
  151. package/src/stories/PinInput.stories.tsx +1 -1
  152. package/src/stories/Popover.stories.tsx +1 -1
  153. package/src/stories/Portal.stories.tsx +1 -1
  154. package/src/stories/Presence.stories.tsx +1 -1
  155. package/src/stories/Progress.stories.tsx +1 -1
  156. package/src/stories/ProgressStack.stories.tsx +1 -1
  157. package/src/stories/Prose.stories.tsx +1 -1
  158. package/src/stories/QrCode.stories.tsx +1 -1
  159. package/src/stories/Questionnaire.stories.tsx +1 -1
  160. package/src/stories/RadioGroup.stories.tsx +1 -1
  161. package/src/stories/RatingGroup.stories.tsx +1 -1
  162. package/src/stories/Resizable.stories.tsx +1 -1
  163. package/src/stories/Result.stories.tsx +1 -1
  164. package/src/stories/Reveal.stories.tsx +1 -1
  165. package/src/stories/RollingNumber.stories.tsx +1 -1
  166. package/src/stories/ScrollArea.stories.tsx +1 -1
  167. package/src/stories/ScrollProgress.stories.tsx +1 -1
  168. package/src/stories/SearchInput.stories.tsx +1 -1
  169. package/src/stories/SegmentedControl.stories.tsx +1 -1
  170. package/src/stories/Select.stories.tsx +1 -1
  171. package/src/stories/Separator.stories.tsx +1 -1
  172. package/src/stories/Sheet.stories.tsx +1 -1
  173. package/src/stories/SignaturePad.stories.tsx +1 -1
  174. package/src/stories/SimpleGrid.stories.tsx +1 -1
  175. package/src/stories/Skeleton.stories.tsx +1 -1
  176. package/src/stories/SkeletonTable.stories.tsx +1 -1
  177. package/src/stories/Slider.stories.tsx +1 -1
  178. package/src/stories/Snackbar.stories.tsx +1 -1
  179. package/src/stories/Sonner.stories.tsx +1 -1
  180. package/src/stories/SortableList.stories.tsx +1 -1
  181. package/src/stories/Sparkline.stories.tsx +1 -1
  182. package/src/stories/Spinner.stories.tsx +1 -1
  183. package/src/stories/Spoiler.stories.tsx +1 -1
  184. package/src/stories/Squircle.stories.tsx +1 -1
  185. package/src/stories/Stack.stories.tsx +1 -1
  186. package/src/stories/StatusBadge.stories.tsx +1 -1
  187. package/src/stories/Switch.stories.tsx +1 -1
  188. package/src/stories/Table.stories.tsx +1 -1
  189. package/src/stories/Tag.stories.tsx +1 -1
  190. package/src/stories/TagsInput.stories.tsx +1 -1
  191. package/src/stories/Text.stories.tsx +1 -1
  192. package/src/stories/Textarea.stories.tsx +1 -1
  193. package/src/stories/ThemeIcon.stories.tsx +1 -1
  194. package/src/stories/TimePicker.stories.tsx +1 -1
  195. package/src/stories/Timeline.stories.tsx +1 -1
  196. package/src/stories/Timer.stories.tsx +1 -1
  197. package/src/stories/Toggle.stories.tsx +1 -1
  198. package/src/stories/ToggleGroup.stories.tsx +1 -1
  199. package/src/stories/ToggleTip.stories.tsx +106 -1
  200. package/src/stories/Tooltip.stories.tsx +56 -1
  201. package/src/stories/TransferList.stories.tsx +1 -1
  202. package/src/stories/TreeSelect.stories.tsx +1 -1
  203. package/src/stories/TypingIndicator.stories.tsx +1 -1
  204. package/src/stories/VisuallyHidden.stories.tsx +1 -1
  205. package/src/stories/Watermark.stories.tsx +1 -1
  206. package/src/stories/WeekPicker.stories.tsx +1 -1
  207. package/src/stories/WordRotate.stories.tsx +1 -1
  208. package/src/stories/YearPicker.stories.tsx +1 -1
  209. package/src/stories/story-groups.json +216 -224
  210. package/src/styles.css +20 -3
  211. package/src/tokens.default.json +6 -1
  212. package/src/tokens.json +7 -2
package/src/app/shell.tsx CHANGED
@@ -34,6 +34,9 @@ import { brand } from "@/brand.config";
34
34
  import Studio from "../components/studio/studio";
35
35
  import { LayersTab } from "@behavioral-agentic-design-system/core/components/layers-tab";
36
36
  import { HomeTab } from "@behavioral-agentic-design-system/core/components/home-tab";
37
+ import { runThemeTransition } from "@behavioral-agentic-design-system/core/lib/theme-transition";
38
+ import { isViewHidden } from "@behavioral-agentic-design-system/core/data/hidden-views";
39
+ import { storybookBaseUrl } from "@behavioral-agentic-design-system/core/lib/storybook-url";
37
40
  import { DocsTab } from "@behavioral-agentic-design-system/core/components/docs-tab";
38
41
  import { BrandMark } from "@behavioral-agentic-design-system/core/components/brand-mark";
39
42
  import { OnboardingWizard } from "@behavioral-agentic-design-system/core/components/onboarding-wizard";
@@ -227,6 +230,15 @@ export type ShellProps = {
227
230
  * Studio not mounted yet) and a live event follows (it covers one already mounted), the same pairing the Docs
228
231
  * tab uses for "bads:docs:navigate".
229
232
  */
233
+ /** Where the iris grows from: the pointer, or the middle of the toggle for keyboard activation (detail 0). */
234
+ function originOf(event: React.MouseEvent): { x: number; y: number } {
235
+ if (event.detail === 0 || (event.clientX === 0 && event.clientY === 0)) {
236
+ const r = (event.currentTarget as HTMLElement).getBoundingClientRect();
237
+ return { x: r.left + r.width / 2, y: r.top + r.height / 2 };
238
+ }
239
+ return { x: event.clientX, y: event.clientY };
240
+ }
241
+
230
242
  function openRecent(kind: "primitive" | "composition", goToTab: (value: string) => void) {
231
243
  if (kind === "primitive") {
232
244
  goToTab("components");
@@ -241,7 +253,7 @@ function openRecent(kind: "primitive" | "composition", goToTab: (value: string)
241
253
  goToTab("studio");
242
254
  }
243
255
 
244
- export const DEFAULT_TABS: ShellTab[] = [
256
+ const ALL_TABS: ShellTab[] = [
245
257
  { value: "home", label: "Home", icon: House, render: ({ goToTab }) => <HomeTab onBrowseDocs={() => goToTab("docs")} onBrowseComponents={() => goToTab("components")} onOpenRecent={(item) => openRecent(item.kind, goToTab)} /> },
246
258
 
247
259
  // Studio absorbs what Customize, Cards and Dashboard used to be: you tune a
@@ -250,10 +262,9 @@ export const DEFAULT_TABS: ShellTab[] = [
250
262
  { value: "components", label: "Components", group: "build", icon: Blocks, count: COMPONENT_COUNT, render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" title="Components preview" /> },
251
263
  { value: "sticker-sheet", label: "Sticker sheet", group: "build", icon: SwatchBook, noPreload: true, render: () => <IframePreview dark={false} src="/preview/sticker-sheet" title="Sticker sheet preview" /> },
252
264
 
253
- // Typography was a route with no way to reach it — /preview/typography has
254
- // rendered fine and been unlinked. The Foundations group is where it belongs.
265
+ // Typography is hidden (data/hidden-views.ts), so Foundations has no rail items. Icons lives under Build.
255
266
  { value: "typography", label: "Typography", group: "foundations", icon: Type, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/typography" title="Typography preview" /> },
256
- { value: "icons", label: "Icons", group: "foundations", icon: Shapes, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/icons" title="Icons preview" /> },
267
+ { value: "icons", label: "Icons", group: "build", icon: Shapes, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/icons" title="Icons preview" /> },
257
268
 
258
269
  { value: "docs", label: "Docs", group: "reference", icon: FileText, render: () => <DocsTab /> },
259
270
  { value: "layers", label: "Layers", group: "reference", icon: LayersIcon, render: () => <LayersTab /> },
@@ -264,6 +275,9 @@ export const DEFAULT_TABS: ShellTab[] = [
264
275
  { value: "history", label: "History", group: "reference", icon: GitCommitHorizontal, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/history" title="Project history" /> },
265
276
  ];
266
277
 
278
+ /** The canonical tabs minus any view hidden in data/hidden-views.ts (the sticker sheet today). */
279
+ export const DEFAULT_TABS: ShellTab[] = ALL_TABS.filter((t) => !isViewHidden(t.value));
280
+
267
281
  /**
268
282
  * The BADS preview shell — header (brand + Storybook + dark toggle) plus a
269
283
  * sticky-mount cross-fade tab bar. Pass any `tabs` array to override the
@@ -280,7 +294,7 @@ export const DEFAULT_TABS: ShellTab[] = [
280
294
  * Icons render at the system stroke width of 1.5 — see AGENTS.md "Icons".
281
295
  */
282
296
  const RAIL_ITEM =
283
- "relative flex w-full min-h-9 items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm font-medium transition-colors before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=inactive]:text-muted-foreground hover:data-[state=inactive]:bg-muted hover:data-[state=inactive]:text-foreground";
297
+ "relative flex w-full min-h-8 items-center gap-2.5 rounded-md px-2.5 py-1 text-sm font-medium transition-colors before:absolute before:inset-x-0 before:-inset-y-1.5 before:content-[''] data-[state=active]:bg-primary data-[state=active]:text-primary-foreground data-[state=inactive]:text-muted-foreground hover:data-[state=inactive]:bg-muted hover:data-[state=inactive]:text-foreground";
284
298
 
285
299
  function RailTrigger({ tab, className }: { tab: ShellTab; className: string }) {
286
300
  const Icon = tab.icon;
@@ -302,7 +316,7 @@ function RailTrigger({ tab, className }: { tab: ShellTab; className: string }) {
302
316
 
303
317
  /** An external destination in the rail: same row as a tab, but a link that leaves the site. */
304
318
  const RAIL_LINK =
305
- "relative flex w-full min-h-9 items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm font-medium text-muted-foreground transition-colors before:absolute before:inset-x-0 before:-inset-y-1 before:content-[''] hover:bg-muted hover:text-foreground";
319
+ "relative flex w-full min-h-8 items-center gap-2.5 rounded-md px-2.5 py-1 text-sm font-medium text-muted-foreground transition-colors before:absolute before:inset-x-0 before:-inset-y-1.5 before:content-[''] hover:bg-muted hover:text-foreground";
306
320
 
307
321
  type RailLinkItem = { label: string; href: string; icon: React.ComponentType<{ className?: string; strokeWidth?: number }> };
308
322
 
@@ -483,8 +497,6 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
483
497
  const toggleDark = (event: React.MouseEvent) => {
484
498
  const next = !dark;
485
499
  const root = document.documentElement;
486
- const prefersReduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
487
- const supports = typeof document !== "undefined" && "startViewTransition" in document;
488
500
 
489
501
  // Iframe retheme is split by visibility. Only iframes in the ACTIVE tab
490
502
  // panel paint into the view-transition snapshot, so only they sync
@@ -528,149 +540,35 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
528
540
  root.classList.toggle("dark", next);
529
541
  };
530
542
 
531
- if (!supports || prefersReduce) {
532
- syncHost();
533
- syncAllIframesToHost();
534
- setDark(next);
535
- return;
536
- }
537
-
538
- // A root-level View Transition snapshots only the host document's render
539
- // tree — cross-document content (every IframePreview-backed tab) never
540
- // gets rasterized into the ::view-transition pseudo tree, no matter when
541
- // its theme class flips. syncVisibleIframes above exists to avoid a
542
- // *stutter* (flip timing), which is orthogonal to this: the chrome wipes
543
- // cleanly along the iris while the iframe's content just snaps to the new
544
- // theme outside the animation entirely — a hard seam at the tab boundary.
545
- // There's no way to pull iframe content into the host's snapshot, so an
546
- // iframe-hosted active tab skips the iris and cross-fades color
547
- // properties on host + iframe together instead: inject a brief transition
548
- // into both documents, force a reflow so the pre-flip colors are the
549
- // animation's start state, then flip. Non-iframe tabs (Home) keep the iris.
550
- const activePanelHasIframe = !!document.querySelector(
551
- '[role="tabpanel"][data-state="active"] iframe',
552
- );
553
- if (activePanelHasIframe) {
554
- const CROSSFADE_MS = 340;
555
- const css = `*,*::before,*::after{transition:background-color ${CROSSFADE_MS}ms ease,color ${CROSSFADE_MS}ms ease,border-color ${CROSSFADE_MS}ms ease,fill ${CROSSFADE_MS}ms ease,stroke ${CROSSFADE_MS}ms ease!important}`;
556
- const styleTags: { doc: Document; style: HTMLStyleElement }[] = [];
557
- const injectInto = (doc: Document) => {
558
- try {
559
- const style = doc.createElement("style");
560
- style.textContent = css;
561
- doc.head.appendChild(style);
562
- styleTags.push({ doc, style });
563
- } catch {}
564
- };
565
- injectInto(document);
566
- const visibleIframeDocs: Document[] = [];
567
- document.querySelectorAll<HTMLIFrameElement>("iframe").forEach((f) => {
568
- if (inInactivePanel(f) || f.dataset.themeIndependent === "true") return;
569
- try {
570
- const doc = f.contentDocument;
571
- if (doc) {
572
- injectInto(doc);
573
- visibleIframeDocs.push(doc);
574
- }
575
- } catch {}
576
- });
577
- // Force a synchronous reflow on every doc touched above so the pre-flip
578
- // colors are the transition's baseline — otherwise the flip below and
579
- // the injected transition could land in the same frame with no "from"
580
- // state to fade from.
581
- void document.body.offsetHeight;
582
- visibleIframeDocs.forEach((doc) => {
583
- try {
584
- void doc.body?.offsetHeight;
585
- } catch {}
586
- });
587
- syncHost();
588
- syncVisibleIframes();
589
- setDark(next);
590
- window.setTimeout(() => {
591
- styleTags.forEach(({ doc, style }) => {
592
- try {
593
- doc.head.removeChild(style);
594
- } catch {}
595
- });
596
- // Converge any sticky-mounted-but-hidden iframes too, same as the
597
- // iris path's deferred convergeAfterTeardown — they were invisible
598
- // for this whole fade, so this repaint is free.
599
- syncAllIframesToHost();
600
- }, CROSSFADE_MS + 80);
601
- return;
602
- }
603
-
604
- root.style.setProperty("--x", `${event.clientX}px`);
605
- root.style.setProperty("--y", `${event.clientY}px`);
606
- // Exact wipe radius: distance from the click to the farthest viewport
607
- // corner, +3%. The old blanket 150vmax always covered, but on wide
608
- // screens it overshot the needed radius by ~40%, so the eased timeline
609
- // spent its whole tail growing an invisible circle — the far side of the
610
- // screen swept past in ~1 frame (12ms) and read as an end-of-wipe pop.
611
- // With +3%, the farthest corner is covered right where ease-in-out's
612
- // deceleration flattens (~t=0.9): the far-side crossing stretches to
613
- // ~3-4 frames of visible, slowing sweep, and the last ~10% of the
614
- // timeline is dropped-frame insurance before teardown. Keep the buffer
615
- // small — every extra % here steals deceleration from the visible sweep
616
- // (1.12 was tried first: crossing stayed a 2-frame blink).
617
- // (See the theme-reveal comment in build-tokens.cjs.)
618
- const cx = event.clientX;
619
- const cy = event.clientY;
620
- const radius = Math.hypot(
621
- Math.max(cx, window.innerWidth - cx),
622
- Math.max(cy, window.innerHeight - cy)
623
- );
624
- const r = Math.ceil(radius * 1.03);
625
- root.style.setProperty("--r", `${r}px`);
626
- const transition = (document as Document & {
627
- startViewTransition: (cb: () => void) => { finished: Promise<void>; ready: Promise<void> };
628
- }).startViewTransition(() => {
629
- syncHost();
630
- syncVisibleIframes();
631
- setDark(next);
543
+ // One iris for every tab. A root view transition snapshots the rendered page, and that includes same-origin
544
+ // iframe content (Studio, Components, Icons): the new theme class is flipped in the host AND the visible
545
+ // iframes inside the callback, so their pixels are in the new snapshot and the circle reveals them too.
546
+ // History: 0583c56e (2026-10-14) assumed iframe content could not be captured and swapped iframe-hosted tabs
547
+ // to a 340ms injected `* { transition: ... }` cross-fade. That is the staggered toggle: different elements
548
+ // fade at different moments, and heavy pages finish late. It is gone; lib/theme-transition.ts suppresses
549
+ // per-element transitions for the length of the switch instead, so nothing staggers.
550
+ const frameDocs: Document[] = [];
551
+ document.querySelectorAll<HTMLIFrameElement>("iframe").forEach((f) => {
552
+ if (inInactivePanel(f) || f.dataset.themeIndependent === "true") return;
553
+ try {
554
+ if (f.contentDocument) frameDocs.push(f.contentDocument);
555
+ } catch {}
632
556
  });
633
- // Drive the reveal's ORIGIN from JS (literal px), not from --x/--y read
634
- // inside the CSS keyframe. Current Chrome stopped propagating custom
635
- // properties set on <html> into the ::view-transition pseudo tree, so the
636
- // keyframe's `circle(... at var(--x,50%) var(--y,50%))` fell back to 50%
637
- // 50% and the wipe started dead-center instead of at the toggle (WebKit
638
- // still inherits them, which is why it only broke in Chrome). The WAAPI
639
- // animation carries the same duration/easing/radius as the CSS keyframe
640
- // (so the theme-old-out tail-guard's 92%/98% offsets still line up) and,
641
- // being a scripted animation, wins the cascade over the CSS one — which
642
- // stays as the coordinate-free fallback for engines without pseudoElement
643
- // support. `ready` starts before the first animation frame paints, so the
644
- // WAAPI origin is in place before any centered CSS frame is visible.
645
- transition.ready.then(
557
+ runThemeTransition(
646
558
  () => {
647
- try {
648
- root.animate(
649
- {
650
- clipPath: [
651
- `circle(0px at ${cx}px ${cy}px)`,
652
- `circle(${r}px at ${cx}px ${cy}px)`,
653
- ],
654
- },
655
- {
656
- duration: 400,
657
- easing: "ease-in-out",
658
- fill: "forwards",
659
- pseudoElement: "::view-transition-new(root)",
660
- }
661
- );
662
- } catch {}
559
+ syncHost();
560
+ syncVisibleIframes();
561
+ setDark(next);
562
+ },
563
+ {
564
+ // Keyboard activation reports clientX/Y as 0, so fall back to the centre of the button.
565
+ ...originOf(event),
566
+ docs: frameDocs,
567
+ // Hidden sticky-mounted iframes are rethemed after the switch, when the repaint is free. Two rAFs so the
568
+ // overlay-teardown frame paints first.
569
+ onFinished: () => requestAnimationFrame(() => requestAnimationFrame(syncAllIframesToHost)),
663
570
  },
664
- () => {}
665
571
  );
666
- // `finished` rejects when a newer transition skips this one — converge
667
- // either way. Two rAFs past `finished` so the overlay-teardown frame
668
- // paints before the hidden-iframe recalc lands: with the exact radius the
669
- // teardown now coincides with the visually complete wipe, and a blocked
670
- // teardown frame would hold the last animation frame on screen.
671
- const convergeAfterTeardown = () =>
672
- requestAnimationFrame(() => requestAnimationFrame(syncAllIframesToHost));
673
- transition.finished.then(convergeAfterTeardown, convergeAfterTeardown);
674
572
  };
675
573
 
676
574
  const ctx: ShellTabContext = { dark, goToTab: selectTab };
@@ -689,11 +587,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
689
587
  // vercel-build); "dev" is the fallback for a non-Vercel prod build. Override
690
588
  // per-fork with NEXT_PUBLIC_STORYBOOK_URL (a standalone deploy or Chromatic
691
589
  // permalink); set it to "" to hide the link on a fork without Storybook.
692
- const storybookUrl =
693
- process.env.NEXT_PUBLIC_STORYBOOK_URL ??
694
- (isDev
695
- ? "http://localhost:6080"
696
- : `/storybook/${process.env.NEXT_PUBLIC_STORYBOOK_VERSION || "dev"}/index.html`);
590
+ const storybookUrl = storybookBaseUrl();
697
591
 
698
592
  // External destinations that live in the rail instead of the footer: Storybook leads Reference, and any
699
593
  // brand.headerLinks entry that names a `group` (upstream's Prototypes link names "build") joins that group.
@@ -883,7 +777,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
883
777
  with a 44px hit area painted past them (RAIL_ITEM); the gap between groups is what makes
884
778
  them read as groups, so it is wider than the gap between rows. */}
885
779
  {tabs.some((t) => !t.group) ? (
886
- <TabsList aria-label="Overview" className="flex h-auto w-full flex-col items-stretch gap-1 bg-transparent p-0">
780
+ <TabsList aria-label="Overview" className="flex h-auto w-full flex-col items-stretch gap-0.5 bg-transparent p-0">
887
781
  {tabs
888
782
  .filter((t) => !t.group)
889
783
  .map((tab) => (
@@ -891,13 +785,13 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
891
785
  ))}
892
786
  </TabsList>
893
787
  ) : null}
894
- {SHELL_GROUPS.map((group) => {
788
+ {SHELL_GROUPS.filter((group) => !isViewHidden(group.id)).map((group) => {
895
789
  const groupTabs = tabs.filter((t) => t.group === group.id);
896
790
  const links = railLinks.filter((l) => l.group === group.id);
897
791
  if (groupTabs.length === 0 && links.length === 0) return null;
898
792
  const labelId = `rail-group-${group.id}`;
899
793
  return (
900
- <div key={group.id} role="group" aria-labelledby={labelId} className="mt-6 flex flex-col gap-1">
794
+ <div key={group.id} role="group" aria-labelledby={labelId} className="mt-6 flex flex-col gap-0.5">
901
795
  <div id={labelId} className="px-2 pb-0.5 text-xs font-medium tracking-wider text-muted-foreground uppercase">
902
796
  {group.label}
903
797
  </div>
@@ -905,7 +799,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
905
799
  <RailLink key={l.href} link={l} />
906
800
  ))}
907
801
  {groupTabs.length > 0 ? (
908
- <TabsList aria-label={group.label} className="flex h-auto w-full flex-col items-stretch gap-1 bg-transparent p-0">
802
+ <TabsList aria-label={group.label} className="flex h-auto w-full flex-col items-stretch gap-0.5 bg-transparent p-0">
909
803
  {groupTabs.map((tab) => (
910
804
  <RailTrigger key={tab.value} tab={tab} className={RAIL_ITEM} />
911
805
  ))}
@@ -53,11 +53,11 @@ export function BrandMarkSection() {
53
53
  const handleFile = async (file: File | null) => {
54
54
  if (!file) return;
55
55
  if (!file.name.toLowerCase().endsWith(".svg") && file.type !== "image/svg+xml") {
56
- setStatus({ kind: "error", message: "Pick an .svg file" });
56
+ setStatus({ kind: "error", message: "Choose an .svg file" });
57
57
  return;
58
58
  }
59
59
  if (file.size > 200_000) {
60
- setStatus({ kind: "error", message: "SVG exceeds 200KB cap" });
60
+ setStatus({ kind: "error", message: "SVG is over 200 KB" });
61
61
  return;
62
62
  }
63
63
  const text = await file.text();
@@ -68,7 +68,7 @@ export function BrandMarkSection() {
68
68
  const handleSave = async () => {
69
69
  const svg = draft.trim();
70
70
  if (!svg) {
71
- setStatus({ kind: "error", message: "Paste or upload an SVG first" });
71
+ setStatus({ kind: "error", message: "Paste or choose an SVG first" });
72
72
  return;
73
73
  }
74
74
  setStatus({ kind: "saving" });
@@ -122,106 +122,76 @@ export function BrandMarkSection() {
122
122
  return savedSvg;
123
123
  })();
124
124
 
125
+ // /api/brand-mark writes brand-mark.json and answers 403 outside development, so the section is a local-dev
126
+ // tool: on a deployed site there is nothing it could save.
127
+ if (process.env.NODE_ENV !== "development") return null;
128
+
125
129
  return (
126
- <section>
127
- <div className="flex items-center justify-between mb-2">
128
- <h2 className="text-2xl font-semibold tracking-tight">Brand Mark</h2>
130
+ <section aria-labelledby="brand-mark-heading" className="flex min-w-0 flex-col gap-3">
131
+ <div className="flex min-w-0 items-center justify-between gap-2">
132
+ <h3 id="brand-mark-heading" className="text-sm font-semibold text-foreground">Brand mark</h3>
129
133
  {savedSvg && (
130
- <Button variant="outline" size="sm" onClick={handleReset} className="text-xs">
131
- <RotateCcw className="h-3 w-3 mr-1.5" strokeWidth={1.5} />
134
+ <Button type="button" variant="ghost" size="xl" onClick={handleReset}>
135
+ <RotateCcw className="mr-1.5 size-3.5" strokeWidth={1.5} aria-hidden="true" />
132
136
  Reset
133
137
  </Button>
134
138
  )}
135
139
  </div>
136
- <p className="text-sm text-muted-foreground mb-8 max-w-prose">
137
- Paste SVG markup or upload an <code className="font-mono text-xs">.svg</code> file.
138
- Monotone marks (one color throughout) get rewritten to{" "}
139
- <code className="font-mono text-xs">currentColor</code> so the logo adopts the
140
- surrounding text color. A fixed-color mark that would be too low-contrast to see
141
- auto-inverts in the offending theme (a black mark flips to white in dark mode).
142
- Multi-color marks are preserved exactly. Saves to{" "}
143
- <code className="font-mono text-xs">brand-mark.json</code>.
140
+ <p className="text-xs text-muted-foreground">
141
+ Paste SVG or choose a file. One-color marks follow the text color.
144
142
  </p>
145
143
 
146
- <div className="grid gap-6 @2xl/panel:grid-cols-2">
147
- {/* Inputs column */}
148
- <div className="flex flex-col gap-4">
149
- <div className="flex flex-col gap-2">
150
- <label htmlFor="brand-mark-paste" className="text-sm font-medium">
151
- SVG markup
152
- </label>
153
- <Textarea
154
- id="brand-mark-paste"
155
- value={draft}
156
- onChange={(e) => {
157
- setDraft(e.target.value);
158
- if (status.kind === "error" || status.kind === "success") {
159
- setStatus({ kind: "idle" });
160
- }
161
- }}
162
- placeholder='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">…</svg>'
163
- className="min-h-[180px] max-h-[200px] overflow-auto font-mono text-xs"
164
- />
165
- </div>
166
-
167
- <div className="flex flex-col gap-2">
168
- <span className="text-sm font-medium">or upload</span>
169
- <div className="flex items-center gap-2">
170
- <input
171
- ref={fileInputRef}
172
- type="file"
173
- accept=".svg,image/svg+xml"
174
- onChange={(e) => handleFile(e.target.files?.[0] ?? null)}
175
- className="hidden"
176
- id="brand-mark-file"
177
- />
178
- <Button
179
- type="button"
180
- variant="outline"
181
- size="sm"
182
- onClick={() => fileInputRef.current?.click()}
183
- >
184
- <Upload className="h-3.5 w-3.5 mr-1.5" strokeWidth={1.5} />
185
- Choose .svg file
186
- </Button>
187
- <span className="text-xs text-muted-foreground">200KB max</span>
188
- </div>
189
- </div>
144
+ <div className="grid grid-cols-2 gap-3">
145
+ <PreviewTile mode="light" svg={previewSvg} />
146
+ <PreviewTile mode="dark" svg={previewSvg} />
147
+ </div>
190
148
 
191
- <div className="flex items-center gap-3 pt-2">
192
- <Button onClick={handleSave} disabled={status.kind === "saving" || !draft.trim()}>
193
- {status.kind === "saving" ? "Saving…" : "Save to brand"}
194
- </Button>
195
- {status.kind === "success" && (
196
- <span className="inline-flex items-center gap-1.5 text-sm text-emerald-700 dark:text-emerald-400">
197
- <Check className="h-4 w-4" strokeWidth={1.5} />
198
- Saved.{" "}
199
- {status.monotone
200
- ? "Monotone — adopts theme color."
201
- : `${status.colorCount} colors preserved.`}
202
- </span>
203
- )}
204
- {status.kind === "error" && (
205
- <span className="inline-flex items-center gap-1.5 text-sm text-destructive">
206
- <AlertCircle className="h-4 w-4" strokeWidth={1.5} />
207
- {status.message}
208
- </span>
209
- )}
210
- </div>
211
- </div>
149
+ <Textarea
150
+ id="brand-mark-paste"
151
+ aria-label="SVG markup"
152
+ value={draft}
153
+ onChange={(e) => {
154
+ setDraft(e.target.value);
155
+ if (status.kind === "error" || status.kind === "success") setStatus({ kind: "idle" });
156
+ }}
157
+ placeholder="Paste SVG markup here"
158
+ spellCheck={false}
159
+ className="h-28 resize-none overflow-auto font-mono text-xs"
160
+ />
212
161
 
213
- {/* Preview column */}
214
- <div className="flex flex-col gap-4">
215
- <span className="text-sm font-medium">Preview</span>
216
- <div className="grid grid-cols-2 gap-3">
217
- <PreviewTile mode="light" svg={previewSvg} />
218
- <PreviewTile mode="dark" svg={previewSvg} />
219
- </div>
220
- <p className="text-xs text-muted-foreground">
221
- Header renders at 20px. Login screens and storybook use larger sizes — the
222
- mark scales with the surrounding type.
223
- </p>
224
- </div>
162
+ <div className="flex flex-wrap items-center gap-2">
163
+ <input
164
+ ref={fileInputRef}
165
+ type="file"
166
+ accept=".svg,image/svg+xml"
167
+ onChange={(e) => handleFile(e.target.files?.[0] ?? null)}
168
+ className="sr-only"
169
+ tabIndex={-1}
170
+ aria-hidden="true"
171
+ id="brand-mark-file"
172
+ />
173
+ <Button type="button" variant="outline" size="xl" onClick={() => fileInputRef.current?.click()}>
174
+ <Upload className="mr-1.5 size-3.5" strokeWidth={1.5} aria-hidden="true" />
175
+ Choose file
176
+ </Button>
177
+ <Button type="button" size="xl" onClick={handleSave} disabled={status.kind === "saving" || !draft.trim()}>
178
+ {status.kind === "saving" ? "Saving" : "Save mark"}
179
+ </Button>
180
+ </div>
181
+ <div role="status" aria-live="polite" className="min-h-5 text-xs">
182
+ {status.kind === "success" && (
183
+ <span className="inline-flex items-center gap-1.5 text-foreground">
184
+ <Check className="size-3.5" strokeWidth={1.5} aria-hidden="true" />
185
+ Saved.{" "}
186
+ {status.monotone ? "Follows the text color." : `${status.colorCount} colors kept.`}
187
+ </span>
188
+ )}
189
+ {status.kind === "error" && (
190
+ <span className="inline-flex items-center gap-1.5 text-destructive">
191
+ <AlertCircle className="size-3.5" strokeWidth={1.5} aria-hidden="true" />
192
+ {status.message}
193
+ </span>
194
+ )}
225
195
  </div>
226
196
  </section>
227
197
  );
@@ -231,7 +201,7 @@ function PreviewTile({ mode, svg }: { mode: "light" | "dark"; svg: string | null
231
201
  const isLight = mode === "light";
232
202
  return (
233
203
  <div
234
- className={`flex flex-col items-center justify-center gap-4 rounded-lg border p-6 ${
204
+ className={`flex flex-col items-center justify-center gap-2 rounded-lg border p-3 ${
235
205
  isLight ? "bg-white text-zinc-900" : "bg-zinc-950 text-zinc-50"
236
206
  }`}
237
207
  >
@@ -241,7 +211,7 @@ function PreviewTile({ mode, svg }: { mode: "light" | "dark"; svg: string | null
241
211
  {/* 32px size — matches header rhythm */}
242
212
  <Mark size={32} svg={svg} mode={mode} />
243
213
  {/* 96px size — login/branded surfaces */}
244
- <Mark size={96} svg={svg} mode={mode} />
214
+ <Mark size={48} svg={svg} mode={mode} />
245
215
  </div>
246
216
  <span className="text-xs opacity-60">{isLight ? "Light" : "Dark"}</span>
247
217
  </div>
@@ -7,6 +7,11 @@ import {
7
7
  useGlobalSansFont,
8
8
  type SansFontKey,
9
9
  } from "@behavioral-agentic-design-system/core/hooks/use-global-sans-font";
10
+ import {
11
+ HEADING_FONT_OPTIONS,
12
+ useGlobalHeadingFont,
13
+ type HeadingFontKey,
14
+ } from "@behavioral-agentic-design-system/core/hooks/use-global-heading-font";
10
15
  import {
11
16
  SERIF_FONT_OPTIONS,
12
17
  useGlobalSerifFont,
@@ -357,9 +362,9 @@ export function SansFontPicker() {
357
362
  const { font, setFont } = useGlobalSansFont();
358
363
  return (
359
364
  <div>
360
- <h4 className="text-base font-semibold mb-2">Sans</h4>
365
+ <h4 className="text-base font-semibold mb-2">Body</h4>
361
366
  <p className="text-sm text-muted-foreground mb-5 max-w-prose">
362
- The primary sans font. Applies via <code>--font-sans</code>.
367
+ The body and UI font. Applies via <code>--font-sans</code>.
363
368
  </p>
364
369
  <FontCardGrid<SansFontKey>
365
370
  options={SANS_FONT_OPTIONS}
@@ -371,6 +376,24 @@ export function SansFontPicker() {
371
376
  );
372
377
  }
373
378
 
379
+ export function HeadingFontPicker() {
380
+ const { font, setFont } = useGlobalHeadingFont();
381
+ return (
382
+ <div>
383
+ <h4 className="text-base font-semibold mb-2">Heading</h4>
384
+ <p className="text-sm text-muted-foreground mb-5 max-w-prose">
385
+ The font for h1 to h6. Applies via <code>--font-heading</code>,
386
+ independent of the body font below.
387
+ </p>
388
+ <FontCardGrid<HeadingFontKey>
389
+ options={HEADING_FONT_OPTIONS}
390
+ active={font}
391
+ onSelect={setFont}
392
+ />
393
+ </div>
394
+ );
395
+ }
396
+
374
397
  export function SerifFontPicker() {
375
398
  const { font, setFont } = useGlobalSerifFont();
376
399
  return (