@behavioral-agentic-design-system/core 0.39.0 → 0.40.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 (78) hide show
  1. package/package.json +8 -3
  2. package/scripts/a11y-lint.cjs +93 -39
  3. package/scripts/a11y-ratchet.mjs +10 -23
  4. package/scripts/bads-components.mjs +118 -0
  5. package/scripts/build-tokens.cjs +175 -17
  6. package/scripts/check-stories.mjs +1 -1
  7. package/scripts/health-report.mjs +52 -10
  8. package/scripts/lib/scan-roots.cjs +143 -0
  9. package/scripts/lint-component-source.mjs +100 -0
  10. package/scripts/lint-microanimation.mjs +267 -0
  11. package/scripts/lint-slop.mjs +21 -28
  12. package/scripts/lint-token-intent.mjs +10 -16
  13. package/scripts/size-audit.cjs +94 -27
  14. package/scripts/source-of-truth.cjs +58 -0
  15. package/scripts/ux-smoke.mjs +438 -0
  16. package/scripts/wcag-audit.cjs +49 -1
  17. package/src/api/layers/file.ts +2 -0
  18. package/src/app/preview/components/page.tsx +972 -0
  19. package/src/app/preview/health/page.tsx +8 -5
  20. package/src/app/preview/history/page.tsx +11 -0
  21. package/src/app/shell.tsx +261 -87
  22. package/src/components/customize/brand-mark-section.tsx +4 -2
  23. package/src/components/customize/design-controls.tsx +1 -1
  24. package/src/components/customize/discipline-section.tsx +91 -0
  25. package/src/components/customize/font-pickers.tsx +1 -1
  26. package/src/components/customize/letter-spacing.tsx +1 -1
  27. package/src/components/customize/save-bar.tsx +2 -2
  28. package/src/components/customize/theme-io.tsx +7 -7
  29. package/src/components/customize/type-scale.tsx +1 -1
  30. package/src/components/customize-tab.tsx +9 -4
  31. package/src/components/home-tab.tsx +3 -0
  32. package/src/components/ui/accordion.tsx +7 -0
  33. package/src/components/ui/alert.tsx +1 -0
  34. package/src/components/ui/announcement-bar.tsx +256 -0
  35. package/src/components/ui/badge.tsx +1 -0
  36. package/src/components/ui/callout.tsx +218 -0
  37. package/src/components/ui/chart.tsx +2 -14
  38. package/src/components/ui/color-picker.tsx +1 -1
  39. package/src/components/ui/format-relative-time.tsx +139 -0
  40. package/src/components/ui/grid.tsx +255 -0
  41. package/src/components/ui/icon.tsx +108 -0
  42. package/src/components/ui/index.ts +8 -0
  43. package/src/components/ui/page-header.tsx +63 -0
  44. package/src/components/ui/portal.tsx +111 -0
  45. package/src/components/ui/presence.tsx +172 -0
  46. package/src/components/ui/progress-stack.tsx +258 -0
  47. package/src/components/ui/select.tsx +89 -4
  48. package/src/components/ui/separator.tsx +1 -0
  49. package/src/components/ui/slider.tsx +83 -3
  50. package/src/components/ui/sparkline.tsx +15 -15
  51. package/src/components/ui/textarea.tsx +28 -1
  52. package/src/data/docs-index.ts +5 -0
  53. package/src/data/history.json +269 -0
  54. package/src/hooks/use-reduced-motion.ts +6 -0
  55. package/src/stories/Accordion.stories.tsx +59 -0
  56. package/src/stories/Alert.stories.tsx +3 -1
  57. package/src/stories/AnnouncementBar.stories.tsx +261 -0
  58. package/src/stories/Badge.stories.tsx +3 -0
  59. package/src/stories/Calendar.stories.tsx +1 -1
  60. package/src/stories/Callout.stories.tsx +219 -0
  61. package/src/stories/Chart.stories.tsx +4 -0
  62. package/src/stories/ColorPicker.stories.tsx +23 -0
  63. package/src/stories/FormatRelativeTime.stories.tsx +116 -0
  64. package/src/stories/Grid.stories.tsx +197 -0
  65. package/src/stories/Icon.stories.tsx +175 -0
  66. package/src/stories/MultiSelect.stories.tsx +1 -1
  67. package/src/stories/PageHeader.stories.tsx +102 -0
  68. package/src/stories/Portal.stories.tsx +189 -0
  69. package/src/stories/Presence.stories.tsx +228 -0
  70. package/src/stories/ProgressStack.stories.tsx +287 -0
  71. package/src/stories/Select.stories.tsx +25 -0
  72. package/src/stories/Separator.stories.tsx +3 -0
  73. package/src/stories/Sheet.stories.tsx +9 -3
  74. package/src/stories/Slider.stories.tsx +54 -5
  75. package/src/stories/Sparkline.stories.tsx +39 -0
  76. package/src/stories/Textarea.stories.tsx +18 -0
  77. package/src/stories/story-groups.json +14 -5
  78. package/src/styles.css +133 -12
@@ -175,21 +175,24 @@ export default function HealthPage() {
175
175
  <h2 className="text-lg font-semibold">Open drift ({drift.length})</h2>
176
176
  {drift.length === 0 ? (
177
177
  <p className="text-sm text-muted-foreground">
178
- Drift ledger is clear. Rows land here from the token-intent lint and month-over-month score drops.
178
+ Drift ledger is clear. Rows land here from the token-intent lint, month-over-month score drops, and
179
+ eval agreement runs that split on a rule.
179
180
  </p>
180
181
  ) : (
181
182
  <Card>
182
183
  <CardContent className="divide-y divide-border p-0">
183
184
  {drift.map((d, i) => (
184
- <div key={i} className="flex items-start gap-3 p-4">
185
- <Badge variant={d.severity === "high" ? "destructive" : "secondary"}>{d.source}</Badge>
186
- <div className="min-w-0">
185
+ <div key={i} className="flex flex-col gap-2 p-4 sm:flex-row sm:items-start sm:gap-3">
186
+ <Badge className="self-start" variant={d.severity === "high" ? "destructive" : "secondary"}>
187
+ {d.source}
188
+ </Badge>
189
+ <div className="min-w-0 sm:flex-1">
187
190
  <p className="truncate text-sm font-medium" title={d.target}>
188
191
  {d.target}
189
192
  </p>
190
193
  <p className="text-sm text-muted-foreground">{d.signal}</p>
191
194
  </div>
192
- <span className="ml-auto shrink-0 text-sm text-muted-foreground">{d.date}</span>
195
+ <span className="shrink-0 text-sm text-muted-foreground sm:ml-auto">{d.date}</span>
193
196
  </div>
194
197
  ))}
195
198
  </CardContent>
@@ -0,0 +1,11 @@
1
+ "use client";
2
+
3
+ import dynamic from "next/dynamic";
4
+
5
+ const HistoryTimeline = dynamic(() => import("@/components/examples/history/history-timeline"), {
6
+ ssr: false,
7
+ });
8
+
9
+ export default function HistoryPreview() {
10
+ return <HistoryTimeline />;
11
+ }
package/src/app/shell.tsx CHANGED
@@ -3,9 +3,13 @@
3
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
5
  import { Sheet, SheetContent, SheetHeader, SheetTitle } from "@behavioral-agentic-design-system/core/components/ui/sheet";
6
- 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 { Sun, Moon, BookOpen, X, ExternalLink, Menu } from "lucide-react";
7
+ import {
8
+ Sun, Moon, BookOpen, X, ExternalLink, Menu,
9
+ House, Blocks, LayoutGrid, LayoutDashboard,
10
+ Type, Shapes, FileText, Layers as LayersIcon, Activity, GitCommitHorizontal, SlidersHorizontal as StudioIcon,
11
+ } from "lucide-react";
12
+ import registry from "@/layer-5-component-registry/component-registry.json";
9
13
 
10
14
  /**
11
15
  * Inline GitHub mark. Lucide dropped brand icons (Github / Twitter / etc.) in
@@ -27,7 +31,7 @@ function GithubMark({ className }: { className?: string }) {
27
31
  );
28
32
  }
29
33
  import { brand } from "@/brand.config";
30
- import { CustomizeTab } from "@behavioral-agentic-design-system/core/components/customize-tab";
34
+ import Studio from "@/components/examples/studio/studio";
31
35
  import { LayersTab } from "@behavioral-agentic-design-system/core/components/layers-tab";
32
36
  import { HomeTab } from "@behavioral-agentic-design-system/core/components/home-tab";
33
37
  import { DocsTab } from "@behavioral-agentic-design-system/core/components/docs-tab";
@@ -171,9 +175,41 @@ export type ShellTab = {
171
175
  * every toggle. Trade-off: a brief reload when you revisit the tab.
172
176
  */
173
177
  noPreload?: boolean;
178
+ /**
179
+ * Which rail group this destination sits under. Omit for the ungrouped
180
+ * entries that sit above the first group label (Home).
181
+ *
182
+ * The rail is a vertical TabsList, so grouping is presentation only — every
183
+ * tab is still a Radix trigger and the panel machinery is untouched. Adding
184
+ * this was additive on purpose: a fork that already passes its own `tabs`
185
+ * array keeps working, its entries simply land in the ungrouped block.
186
+ */
187
+ group?: "build" | "foundations" | "reference";
188
+ /** Rail glyph. Lucide, rendered at the system stroke width of 1.5. */
189
+ icon?: React.ComponentType<{ className?: string; strokeWidth?: number }>;
190
+ /**
191
+ * Live count shown right-aligned in the rail. Design Studio keeps its two
192
+ * headline numbers permanently in the chrome rather than on a dashboard
193
+ * nobody opens; this is that idea. Only pass a number that is genuinely
194
+ * derived — a decorative count is worse than none.
195
+ */
196
+ count?: number;
174
197
  render: (ctx: ShellTabContext) => React.ReactNode;
175
198
  };
176
199
 
200
+ /** Rail group labels, in render order. Ungrouped tabs render above all of them. */
201
+ export const SHELL_GROUPS: readonly {
202
+ id: "build" | "foundations" | "reference";
203
+ label: string;
204
+ }[] = [
205
+ { id: "build", label: "Build" },
206
+ { id: "foundations", label: "Foundations" },
207
+ { id: "reference", label: "Reference" },
208
+ ];
209
+
210
+ /** Derived, not decorative — the registry is the source of truth. */
211
+ const COMPONENT_COUNT = Object.keys(registry as Record<string, unknown>).length;
212
+
177
213
  export type ShellProps = {
178
214
  tabs: ShellTab[];
179
215
  /** Optional initial tab value. Defaults to the first tab. */
@@ -186,14 +222,25 @@ export type ShellProps = {
186
222
  * they need custom surfaces alongside the built-ins.
187
223
  */
188
224
  export const DEFAULT_TABS: ShellTab[] = [
189
- { value: "home", label: "Home", render: ({ goToTab }) => <HomeTab onBrowseDocs={() => goToTab("docs")} onBrowseComponents={() => goToTab("components")} /> },
190
- { value: "docs", label: "Docs", render: () => <DocsTab /> },
191
- { value: "components", label: "Components", render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" title="Components preview" /> },
192
- { value: "cards", label: "Cards", render: ({ dark }) => <IframePreview dark={dark} src="/preview/cards" title="Cards preview" /> },
193
- { value: "dashboard", label: "Dashboard", hidden: "md", render: ({ dark }) => <IframePreview dark={dark} src="/preview/dashboard" minWidth="1400px" title="Dashboard preview" /> },
194
- { value: "layers", label: "Layers", render: () => <LayersTab /> },
195
- { value: "icons", label: "Icons", noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/icons" title="Icons preview" /> },
196
- { value: "customize", label: "Customize", render: () => <CustomizeTab /> },
225
+ { value: "home", label: "Home", icon: House, render: ({ goToTab }) => <HomeTab onBrowseDocs={() => goToTab("docs")} onBrowseComponents={() => goToTab("components")} /> },
226
+
227
+ // Studio absorbs what Customize, Cards and Dashboard used to be: you tune a
228
+ // value and the specimens beside it repaint, instead of navigating to find out.
229
+ { value: "studio", label: "Studio", group: "build", icon: StudioIcon, render: () => <Studio /> },
230
+ { value: "components", label: "Components", group: "build", icon: Blocks, count: COMPONENT_COUNT, render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" title="Components preview" /> },
231
+
232
+ // Typography was a route with no way to reach it — /preview/typography has
233
+ // rendered fine and been unlinked. The Foundations group is where it belongs.
234
+ { value: "typography", label: "Typography", group: "foundations", icon: Type, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/typography" title="Typography preview" /> },
235
+ { value: "icons", label: "Icons", group: "foundations", icon: Shapes, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/icons" title="Icons preview" /> },
236
+
237
+ { value: "docs", label: "Docs", group: "reference", icon: FileText, render: () => <DocsTab /> },
238
+ { value: "layers", label: "Layers", group: "reference", icon: LayersIcon, render: () => <LayersTab /> },
239
+ // Same story as Typography: /preview/health rendered and was unreachable.
240
+ { value: "health", label: "Health", group: "reference", icon: Activity, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/health" title="System health" /> },
241
+ // Generated from the repo by scripts/build-history.mjs — counts and commits,
242
+ // nothing authored twice. See docs/design-studio-teardown.md item 6.
243
+ { value: "history", label: "History", group: "reference", icon: GitCommitHorizontal, noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/history" title="Project history" /> },
197
244
  ];
198
245
 
199
246
  /**
@@ -206,12 +253,36 @@ export const DEFAULT_TABS: ShellTab[] = [
206
253
  * Shell directly when you need custom tabs (e.g. Components, Tokens, Changelog
207
254
  * for a design-system docs site).
208
255
  */
256
+
257
+ /**
258
+ * A rail destination: glyph, label, and (only when genuinely derived) a count.
259
+ * Icons render at the system stroke width of 1.5 — see CLAUDE.md "Icons".
260
+ */
261
+ const RAIL_ITEM =
262
+ "flex w-full min-h-11 items-center gap-2.5 rounded-md px-2.5 py-2 text-sm font-medium transition-colors 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";
263
+
264
+ function RailTrigger({ tab, className }: { tab: ShellTab; className: string }) {
265
+ const Icon = tab.icon;
266
+ return (
267
+ <TabsTrigger value={tab.value} className={className}>
268
+ {Icon ? <Icon className="size-4 shrink-0" strokeWidth={1.5} /> : null}
269
+ <span className="min-w-0 flex-1 truncate text-left">{tab.label}</span>
270
+ {typeof tab.count === "number" ? (
271
+ <span className="shrink-0 text-xs tabular-nums text-muted-foreground">
272
+ {tab.count}
273
+ </span>
274
+ ) : null}
275
+ </TabsTrigger>
276
+ );
277
+ }
278
+
209
279
  export function Shell({ tabs, defaultTab }: ShellProps) {
210
280
  const initialTab = defaultTab ?? tabs[0]?.value ?? "home";
211
281
  const [activeTab, setActiveTab] = useState(initialTab);
212
282
  const [dark, setDark] = useState(false);
213
- // Mobile nav: below md the tab strip collapses into a hamburger + Sheet.
283
+ // Mobile nav: below md the rail collapses into a hamburger + Sheet.
214
284
  const [mobileNavOpen, setMobileNavOpen] = useState(false);
285
+
215
286
  // Fresh-fork onboarding: only render when brand still says "BADS" (the rename
216
287
  // hasn't run yet) AND the user hasn't dismissed the wizard this session.
217
288
  // Renamed forks never see this — they've already gone through onboarding.
@@ -534,45 +605,46 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
534
605
  share this layout and must keep their own document scroll. */}
535
606
  <div className="h-dvh overflow-hidden bg-background flex flex-col">
536
607
  {/* Skip-to-content: visually hidden until focused so keyboard users can
537
- bypass the header and tab strip and jump straight to the panel area. */}
608
+ bypass the rail and jump straight to the panel area. */}
538
609
  <a
539
610
  href="#main-content"
540
611
  className="sr-only focus:not-sr-only focus:absolute focus:z-50 focus:top-2 focus:left-2 focus:rounded-md focus:bg-primary focus:px-3 focus:py-2 focus:text-primary-foreground"
541
612
  >
542
613
  Skip to main content
543
614
  </a>
544
- <header className="border-b bg-card shrink-0">
545
- <div className="flex h-14 items-center px-4 sm:px-6">
546
- <div className="flex items-center gap-2 min-w-0">
547
- {brand.logo?.lockup ? (
548
- // Full lockup slot: a brand whose identity is a combined
549
- // mark+wordmark renders it as ONE sanitized SVG, sized to the
550
- // header. This preserves the artwork's intrinsic alignment and
551
- // replaces the boxed mark + product-name. The wordmark's
552
- // currentColor follows chrome text (legible light/dark); any
553
- // brand-colored mark fills are preserved. Sanitized server-side
554
- // by /api/brand-mark before it lands in brand.config, same as
555
- // `logo.svg` — safe to inline render.
556
- <span
557
- role="img"
558
- aria-label={`${brand.name} logo`}
559
- className="flex h-7 items-center shrink-0 min-w-0 text-foreground [&>svg]:h-full [&>svg]:w-auto [&>svg]:max-w-full"
560
- dangerouslySetInnerHTML={{ __html: brand.logo.lockup }}
561
- />
562
- ) : (
563
- <>
564
- <div
565
- className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary text-primary-foreground shrink-0"
566
- >
567
- <BrandMark size={20} />
568
- </div>
569
- <span className="text-lg font-semibold truncate">{brand.name}</span>
570
- </>
571
- )}
572
- {brand.tagline ? (
573
- <Badge variant="outline" className="ml-2 text-xs hidden sm:inline-flex">{brand.tagline}</Badge>
574
- ) : null}
575
- </div>
615
+ <Tabs
616
+ value={activeTab}
617
+ onValueChange={selectTab}
618
+ // The rail IS the tab list, so the tabs are genuinely vertical. This is
619
+ // not cosmetic: Radix switches roving focus to ArrowUp/ArrowDown, which
620
+ // is what a vertical tablist owes a keyboard user. It also clears
621
+ // `data-orientation="horizontal"`, whose base class on the Tabs root
622
+ // (`data-[orientation=horizontal]:flex-col`) otherwise forces a column
623
+ // and wins over `md:flex-row` — the rail rendered above the content
624
+ // rather than beside it until this was set.
625
+ orientation="vertical"
626
+ // Slower cross-fade between mounted panels — 260ms feels deliberate
627
+ // without dragging. Read by the duration utility on TabsPanels.
628
+ style={{ "--tabs-fade-duration": "260ms" } as React.CSSProperties}
629
+ // gap-0 overrides the Tabs root's default gap-2: the rail already owns
630
+ // its own border and padding, so a gap would open a seam beside it.
631
+ className="flex-1 flex flex-col md:flex-row min-h-0 gap-0 overflow-hidden"
632
+ >
633
+ {/* Mobile (<md): a compact bar. The rail is desktop-only; below md it
634
+ collapses into the Sheet drawer, as the tab strip used to. */}
635
+ <div className="flex h-14 shrink-0 items-center gap-2 border-b bg-card px-4 md:hidden">
636
+ <Button
637
+ variant="ghost"
638
+ size="icon"
639
+ onClick={() => setMobileNavOpen(true)}
640
+ aria-label="Open navigation menu"
641
+ className="size-8 shrink-0 border border-foreground/30"
642
+ >
643
+ <Menu className="h-4 w-4" strokeWidth={1.5} />
644
+ </Button>
645
+ <span className="truncate text-sm font-medium text-foreground">
646
+ {tabs.find((t) => t.value === activeTab)?.label}
647
+ </span>
576
648
  <div className="ml-auto flex items-center gap-1.5 sm:gap-2 shrink-0">
577
649
  {/* Fork-configurable header links — set `headerLinks` in brand.config
578
650
  to add buttons (e.g. a link to a fork's prototypes site) without
@@ -629,57 +701,158 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
629
701
  aria-label={dark ? "Switch to light mode" : "Switch to dark mode"}
630
702
  >
631
703
  {dark ? (
632
- <Sun className="h-4 w-4" />
704
+ <Sun className="h-4 w-4" strokeWidth={1.5} />
633
705
  ) : (
634
- <Moon className="h-4 w-4" />
706
+ <Moon className="h-4 w-4" strokeWidth={1.5} />
635
707
  )}
636
708
  </Button>
637
709
  </div>
638
710
  </div>
639
- </header>
640
711
 
641
- <Tabs
642
- value={activeTab}
643
- onValueChange={selectTab}
644
- // Slower cross-fade between mounted panels — 260ms feels deliberate
645
- // without dragging. Read by the duration utility on TabsPanels.
646
- style={{ "--tabs-fade-duration": "260ms" } as React.CSSProperties}
647
- className="flex-1 flex flex-col overflow-hidden"
648
- >
649
- {/* Mobile (<md): hamburger + active-tab label. The full tab strip is
650
- hard to use on a phone, so it collapses into a Sheet drawer. */}
651
- <div className="mt-2 mb-1 flex w-full items-center gap-2 px-4 md:hidden">
652
- <Button
653
- variant="ghost"
654
- size="icon"
655
- onClick={() => setMobileNavOpen(true)}
656
- aria-label="Open navigation menu"
657
- className="size-8 shrink-0 border border-foreground/30"
658
- >
659
- <Menu className="h-4 w-4" strokeWidth={1.5} />
660
- </Button>
661
- <span className="truncate text-sm font-medium text-foreground">
662
- {tabs.find((t) => t.value === activeTab)?.label}
663
- </span>
664
- </div>
712
+ {/* Desktop (md+): the rail. It is a flex SIBLING with shrink-0, not a
713
+ sticky or fixed element, so it rides the root View Transition
714
+ snapshot exactly as the old header did and needs no
715
+ view-transition-name. Naming it would be the trap CLAUDE.md
716
+ documents under "Theme transition and sticky chrome", not the fix.
717
+ The panel area scrolls inside itself, which is what keeps the rail
718
+ out of sticky-chrome territory in the first place. */}
719
+ <aside className="hidden w-72 shrink-0 flex-col bg-card md:flex">
720
+ <div className="flex shrink-0 items-center px-4 py-3">
721
+ <div className="flex items-center gap-2 min-w-0">
722
+ {brand.logo?.lockup ? (
723
+ // Full lockup slot: a brand whose identity is a combined
724
+ // mark+wordmark renders it as ONE sanitized SVG, sized to the
725
+ // header. This preserves the artwork's intrinsic alignment and
726
+ // replaces the boxed mark + product-name. The wordmark's
727
+ // currentColor follows chrome text (legible light/dark); any
728
+ // brand-colored mark fills are preserved. Sanitized server-side
729
+ // by /api/brand-mark before it lands in brand.config, same as
730
+ // `logo.svg` — safe to inline render.
731
+ <span
732
+ role="img"
733
+ aria-label={`${brand.name} logo`}
734
+ className="flex h-7 items-center shrink-0 min-w-0 text-foreground [&>svg]:h-full [&>svg]:w-auto [&>svg]:max-w-full"
735
+ dangerouslySetInnerHTML={{ __html: brand.logo.lockup }}
736
+ />
737
+ ) : (
738
+ <>
739
+ <div
740
+ className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary text-primary-foreground shrink-0"
741
+ >
742
+ <BrandMark size={20} />
743
+ </div>
744
+ {/* Name over tagline. The old header ran these side by side
745
+ with the tagline in a Badge pill, which needs more width
746
+ than a 240px rail has — the pill overflowed the rail and
747
+ crossed its right border. Stacking keeps the tagline
748
+ (it is brand identity, not decoration) and truncate keeps
749
+ an arbitrary-length fork tagline inside the rail. */}
750
+ <span className="flex min-w-0 flex-col leading-tight">
751
+ <span className="text-base font-semibold">{brand.name}</span>
752
+ {brand.tagline ? (
753
+ <span className="text-xs text-muted-foreground">{brand.tagline}</span>
754
+ ) : null}
755
+ </span>
756
+ </>
757
+ )}
758
+ </div>
759
+ </div>
665
760
 
666
- {/* Desktop (md+): the horizontal tab strip. */}
667
- <div className="mt-2 mb-1 hidden w-full items-center px-4 overflow-x-auto scrollbar-none md:flex">
668
- <TabsList className="bg-background text-muted-foreground inline-flex w-max shrink-0 items-center justify-center rounded-full px-0">
669
- {tabs.map((tab) => (
670
- <TabsTrigger
671
- key={tab.value}
672
- value={tab.value}
673
- 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 ${
674
- tab.hidden === "md" ? "hidden md:inline-flex" : "inline-flex"
675
- }`}
761
+ <nav aria-label="Sections" className="min-h-0 flex-1 overflow-y-auto px-3 py-3">
762
+ <TabsList aria-label="Sections" className="flex h-auto w-full flex-col items-stretch gap-0.5 bg-transparent p-0">
763
+ {tabs
764
+ .filter((t) => !t.group)
765
+ .map((tab) => (
766
+ <RailTrigger key={tab.value} tab={tab} className={RAIL_ITEM} />
767
+ ))}
768
+ {SHELL_GROUPS.map((group) => {
769
+ const groupTabs = tabs.filter((t) => t.group === group.id);
770
+ if (groupTabs.length === 0) return null;
771
+ return (
772
+ // role="presentation" keeps these wrappers and their labels out
773
+ // of the tablist content model, which allows `tab` children only.
774
+ // axe tolerates the nesting, so a green axe run is not evidence.
775
+ <div key={group.id} role="presentation" className="mt-4 flex flex-col gap-0.5">
776
+ <div aria-hidden="true" className="px-2 pb-1.5 text-xs font-medium tracking-wider text-muted-foreground uppercase">
777
+ {group.label}
778
+ </div>
779
+ {groupTabs.map((tab) => (
780
+ <RailTrigger key={tab.value} tab={tab} className={RAIL_ITEM} />
781
+ ))}
782
+ </div>
783
+ );
784
+ })}
785
+ </TabsList>
786
+ </nav>
787
+
788
+ <div className="shrink-0 p-3">
789
+ <div className="flex flex-wrap items-center gap-1.5 sm:gap-2 shrink-0">
790
+ {/* Fork-configurable header links — set `headerLinks` in brand.config
791
+ to add buttons (e.g. a link to a fork's prototypes site) without
792
+ shadowing this shell. Read defensively so forks that don't set it
793
+ are unaffected. */}
794
+ {((brand as { headerLinks?: { label: string; href: string }[] }).headerLinks ?? []).map((link) => (
795
+ <Button
796
+ key={link.href}
797
+ asChild
798
+ variant="ghost"
799
+ size="sm"
800
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
801
+ title={`Open ${link.label}`}
676
802
  >
677
- {tab.label}
678
- </TabsTrigger>
803
+ <a href={link.href} target="_blank" rel="noreferrer" aria-label={`Open ${link.label} in a new tab`}>
804
+ <ExternalLink className="h-4 w-4" strokeWidth={1.5} />
805
+ <span className="text-xs font-medium hidden sm:inline">{link.label}</span>
806
+ </a>
807
+ </Button>
679
808
  ))}
680
- </TabsList>
681
- </div>
809
+ {storybookUrl && (
810
+ <Button
811
+ asChild
812
+ variant="ghost"
813
+ size="sm"
814
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
815
+ title="Open Storybook"
816
+ >
817
+ <a href={storybookUrl} target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
818
+ <BookOpen className="h-4 w-4" strokeWidth={1.5} />
819
+ <span className="text-xs font-medium hidden sm:inline">Storybook</span>
820
+ </a>
821
+ </Button>
822
+ )}
823
+ {isDev && brand.repo && (
824
+ <Button
825
+ asChild
826
+ variant="ghost"
827
+ size="sm"
828
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
829
+ title={`Open ${brand.repo.replace(/^https?:\/\//, "")} on GitHub`}
830
+ >
831
+ <a href={brand.repo} target="_blank" rel="noreferrer" aria-label="Open GitHub repo in a new tab">
832
+ <GithubMark className="h-4 w-4" />
833
+ <span className="text-xs font-medium hidden sm:inline">GitHub</span>
834
+ </a>
835
+ </Button>
836
+ )}
837
+ <Button
838
+ variant="ghost"
839
+ size="icon"
840
+ onClick={toggleDark}
841
+ className="group size-8 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
842
+ aria-label={dark ? "Switch to light mode" : "Switch to dark mode"}
843
+ >
844
+ {dark ? (
845
+ <Sun className="h-4 w-4" strokeWidth={1.5} />
846
+ ) : (
847
+ <Moon className="h-4 w-4" strokeWidth={1.5} />
848
+ )}
849
+ </Button>
850
+ </div>
851
+ </div>
852
+ </aside>
682
853
 
854
+ {/* Main column. Owns its own scroll so the rail never moves with it. */}
855
+ <div className="flex min-w-0 flex-1 flex-col">
683
856
  <section id="main-content" tabIndex={-1} className="relative flex-1 min-h-0 w-full overflow-hidden scrollbar-gutter-stable">
684
857
  <div className="absolute inset-x-4 top-1 bottom-4 isolate overflow-hidden rounded-lg">
685
858
  <TabsPanels>
@@ -709,6 +882,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
709
882
  </TabsPanels>
710
883
  </div>
711
884
  </section>
885
+ </div>
712
886
  </Tabs>
713
887
 
714
888
  {/* Mobile navigation drawer — the tab list as a Sheet for small screens.
@@ -719,7 +893,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
719
893
  <SheetHeader>
720
894
  <SheetTitle>{brand.name}</SheetTitle>
721
895
  </SheetHeader>
722
- <nav className="mt-4 flex flex-col gap-1 px-2">
896
+ <nav aria-label="Sections" className="mt-4 flex flex-col gap-1 px-2">
723
897
  {tabs
724
898
  .filter((tab) => tab.hidden !== "md")
725
899
  .map((tab) => (
@@ -143,7 +143,7 @@ export function BrandMarkSection() {
143
143
  <code className="font-mono text-xs">brand-mark.json</code>.
144
144
  </p>
145
145
 
146
- <div className="grid gap-6 lg:grid-cols-2">
146
+ <div className="grid gap-6 @2xl/panel:grid-cols-2">
147
147
  {/* Inputs column */}
148
148
  <div className="flex flex-col gap-4">
149
149
  <div className="flex flex-col gap-2">
@@ -235,7 +235,9 @@ function PreviewTile({ mode, svg }: { mode: "light" | "dark"; svg: string | null
235
235
  isLight ? "bg-white text-zinc-900" : "bg-zinc-950 text-zinc-50"
236
236
  }`}
237
237
  >
238
- <div className="flex items-center gap-4">
238
+ {/* wrap: this row is re-housed into Studio's ~400px controls column,
239
+ narrower than the full-width tab it was built for. */}
240
+ <div className="flex flex-wrap items-center gap-4">
239
241
  {/* 32px size — matches header rhythm */}
240
242
  <Mark size={32} svg={svg} mode={mode} />
241
243
  {/* 96px size — login/branded surfaces */}
@@ -132,7 +132,7 @@ export function DesignControlsPanel() {
132
132
  preview screen and persist on refresh.
133
133
  </p>
134
134
 
135
- <div className="grid grid-cols-1 lg:grid-cols-2 gap-x-10 gap-y-8">
135
+ <div className="grid grid-cols-1 @2xl/panel:grid-cols-2 gap-x-10 gap-y-8">
136
136
  <ControlRow
137
137
  label="Border Radius"
138
138
  description="Drives every rounded corner. sm/md/lg/xl scale from this base."
@@ -0,0 +1,91 @@
1
+ "use client";
2
+
3
+ import { useCallback, useEffect, useState } from "react";
4
+ import { brand } from "@/brand.config";
5
+ import {
6
+ SegmentedControl,
7
+ SegmentedControlItem,
8
+ } from "@behavioral-agentic-design-system/core/components/ui/segmented-control";
9
+
10
+ /**
11
+ * Active-discipline picker.
12
+ *
13
+ * Lives in Customize, not in the shell rail. Discipline is a setting, not a
14
+ * destination: it changes which rule tree an agent loads for the work, and it
15
+ * changes rarely. Putting it in the chrome implied it was a mode you flip
16
+ * between while browsing, which it is not.
17
+ *
18
+ * This is signal 1 ("explicit") of the router in
19
+ * `disciplines/_router/router.config.ts`. It writes two places:
20
+ *
21
+ * - `localStorage` under DISCIPLINE_KEY, so the choice survives a reload.
22
+ * - `<html data-discipline>`, so stylesheets and anything reading the DOM can
23
+ * branch on it without importing from React.
24
+ *
25
+ * The enabled list comes from `brand.config.disciplines`, which is also the
26
+ * router's signal-4 fallback — one declaration of what a fork supports. A fork
27
+ * that lists a single discipline renders nothing here at all.
28
+ */
29
+
30
+ /** Persisted in localStorage, not session: a discipline is a standing choice. */
31
+ export const DISCIPLINE_KEY = "bads:shell:discipline";
32
+
33
+ export function DisciplineSection() {
34
+ const config = (brand as {
35
+ disciplines?: { enabled?: readonly string[]; default?: string };
36
+ }).disciplines;
37
+ const enabled: readonly string[] = config?.enabled ?? [];
38
+ const [discipline, setDiscipline] = useState(config?.default ?? enabled[0] ?? "product");
39
+
40
+ useEffect(() => {
41
+ if (enabled.length < 2) return;
42
+ let stored: string | null = null;
43
+ try {
44
+ stored = window.localStorage.getItem(DISCIPLINE_KEY);
45
+ } catch {
46
+ // Storage disabled (Safari private, lockdown mode) — keep the default.
47
+ }
48
+ const next = stored && enabled.includes(stored) ? stored : discipline;
49
+ setDiscipline(next);
50
+ document.documentElement.dataset.discipline = next;
51
+ // `enabled` and `discipline` are read once, at mount, on purpose: this
52
+ // effect restores the persisted choice and must not re-run when the user
53
+ // changes it (selectDiscipline already owns that path).
54
+ // eslint-disable-next-line react-hooks/exhaustive-deps
55
+ }, []);
56
+
57
+ const selectDiscipline = useCallback((next: string) => {
58
+ setDiscipline(next);
59
+ document.documentElement.dataset.discipline = next;
60
+ try {
61
+ window.localStorage.setItem(DISCIPLINE_KEY, next);
62
+ } catch {
63
+ // Non-fatal: the choice still holds for this session.
64
+ }
65
+ }, []);
66
+
67
+ // One discipline means there is nothing to choose. Render nothing rather than
68
+ // a control with a single option.
69
+ if (enabled.length < 2) return null;
70
+
71
+ return (
72
+ <div>
73
+ <h2 className="mb-2 text-base font-semibold">Discipline</h2>
74
+ <p className="mb-4 text-sm text-muted-foreground">
75
+ Which rule tree agents load. Both keep the accessibility and ethics floors.
76
+ </p>
77
+ <SegmentedControl
78
+ value={discipline}
79
+ onValueChange={selectDiscipline}
80
+ label="Active discipline"
81
+ className="max-w-sm"
82
+ >
83
+ {enabled.map((d) => (
84
+ <SegmentedControlItem key={d} value={d} className="flex-1 capitalize">
85
+ {d}
86
+ </SegmentedControlItem>
87
+ ))}
88
+ </SegmentedControl>
89
+ </div>
90
+ );
91
+ }
@@ -320,7 +320,7 @@ function FontCardGrid<K extends string>({
320
320
  }) {
321
321
  const keys = Object.keys(options) as K[];
322
322
  return (
323
- <div className="grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-3">
323
+ <div className="grid grid-cols-2 @lg/panel:grid-cols-3 @2xl/panel:grid-cols-4 @3xl/panel:grid-cols-5 gap-3">
324
324
  {keys.map((key) => {
325
325
  const opt = options[key];
326
326
  const isActive = key === active;
@@ -47,7 +47,7 @@ export function LetterSpacingPanel() {
47
47
  labels all retrack live as you slide.
48
48
  </p>
49
49
 
50
- <div className="grid grid-cols-1 lg:grid-cols-2 gap-x-10 gap-y-8 mb-10">
50
+ <div className="grid grid-cols-1 @2xl/panel:grid-cols-2 gap-x-10 gap-y-8 mb-10">
51
51
  <div className="space-y-3">
52
52
  <div className="flex items-baseline justify-between gap-3">
53
53
  <label className="text-sm font-semibold">Tracking</label>