@behavioral-agentic-design-system/core 0.39.0 → 0.39.1

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.
@@ -26,7 +26,7 @@
26
26
  * Run:
27
27
  * pnpm size-audit # report violations, exit 1 on fail
28
28
  * pnpm size-audit:warn # report but exit 0 (advisory)
29
- * node scripts/size-audit.js path/to.tsx # scan a specific file
29
+ * node packages/core/scripts/size-audit.cjs path/to.tsx # scan a specific file
30
30
  *
31
31
  * Rule code: BADS-2. (BADS-1 = raw <button> not using BADS Button.)
32
32
  */
@@ -35,38 +35,21 @@
35
35
 
36
36
  const fs = require('fs');
37
37
  const path = require('path');
38
+ const { resolveScanFiles, guardEmptyScan } = require('./lib/scan-roots.cjs');
38
39
 
39
40
  // Packaged as the `bads-size-audit` bin: runs against the CONSUMER repo
40
41
  // (cwd), so prototype repos and client forks get the CTA size contract
41
42
  // without copying the script. Pass scan roots as positional args
42
- // (`bads-size-audit app components`) or rely on the defaults below.
43
+ // (`bads-size-audit app components`) or rely on the shared defaults in
44
+ // ./lib/scan-roots.cjs (also set BADS_LINT_ROOTS). That file explains why
45
+ // the roots are centralized: this script, a11y-lint, lint-slop,
46
+ // a11y-ratchet and lint-token-intent used to keep drifted copies of the
47
+ // same list.
43
48
  const ROOT = process.cwd();
44
49
  const advisory = process.argv.includes('--warn');
45
- const argPaths = process.argv.slice(2).filter((a) => !a.startsWith('--'));
46
- const argRoots = argPaths.filter((p) => fs.existsSync(p) && fs.statSync(p).isDirectory());
47
- const explicitPaths = argPaths.filter((p) => !argRoots.includes(p));
48
-
49
- const SCAN_ROOTS = argRoots.length
50
- ? argRoots
51
- : ['app', 'components', 'src'].filter((r) => fs.existsSync(path.join(ROOT, r)));
52
-
53
- function walk(dir, out = []) {
54
- if (!fs.existsSync(dir)) return out;
55
- for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
56
- if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
57
- const full = path.join(dir, entry.name);
58
- if (entry.isDirectory()) {
59
- walk(full, out);
60
- } else if (/\.tsx?$/.test(entry.name)) {
61
- out.push(full);
62
- }
63
- }
64
- return out;
65
- }
66
50
 
67
- const files = explicitPaths.length
68
- ? explicitPaths.map((p) => path.resolve(p))
69
- : SCAN_ROOTS.flatMap((r) => walk(path.join(ROOT, r)));
51
+ const scan = resolveScanFiles({ root: ROOT, argv: process.argv.slice(2), allowDirArgs: true });
52
+ const files = scan.files;
70
53
 
71
54
  const issues = [];
72
55
 
@@ -124,7 +107,12 @@ for (const file of files) {
124
107
  }
125
108
 
126
109
  if (issues.length === 0) {
127
- console.log('✓ size-audit: every CTA reads at text-sm. No size divergence.');
110
+ if (guardEmptyScan(scan, 'size-audit')) { /* exited */ }
111
+ console.log(
112
+ scan.files.length
113
+ ? '✓ size-audit: every CTA reads at text-sm. No size divergence.'
114
+ : '✓ size-audit: every CTA reads at text-sm (0 files matched under existing scan roots).'
115
+ );
128
116
  process.exit(0);
129
117
  }
130
118
 
@@ -47,6 +47,7 @@ function isAllowed(rel: string) {
47
47
  if (norm === "packages/core/src/tokens.json") return true;
48
48
  if (/^layer-[\w-]+\//.test(norm) && /\.(md|json)$/.test(norm)) return true;
49
49
  if (/^docs\/[\w.-]+\.md$/.test(norm)) return true;
50
+ if (/^disciplines\/[\w./-]+\.(md|json)$/.test(norm)) return true;
50
51
  if (/^prompts\/[\w.-]+\.md$/.test(norm)) return true;
51
52
  if (/^\.claude\/skills\/[\w.-]+\/SKILL\.md$/.test(norm)) return true;
52
53
  if (/^(ledgers|aggregator|automation|roi)\/README\.md$/.test(norm)) return true;
@@ -4174,7 +4174,11 @@ export default function ComponentsPreview() {
4174
4174
  <ColorSwatch color="#171717" size="lg" aria-label="Selected: near-black">
4175
4175
  <CheckIcon strokeWidth={1.5} className="text-white" />
4176
4176
  </ColorSwatch>
4177
+ {/* Picker's own label pattern (see CLAUDE.md -> Customize Tab):
4178
+ shows the user's raw hex pick back as text, not a style
4179
+ value — SC 1.4.6 doesn't apply to displayed data. */}
4177
4180
  <span className="tabular-nums text-muted-foreground">
4181
+ {/* allow-hex-literal */}
4178
4182
  #171717 · selected
4179
4183
  </span>
4180
4184
  </div>
@@ -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, SlidersHorizontal,
10
+ Type, Shapes, FileText, Layers as LayersIcon, Activity, GitCommitHorizontal,
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
@@ -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
+ { value: "components", label: "Components", group: "build", icon: Blocks, count: COMPONENT_COUNT, render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" title="Components preview" /> },
228
+ { value: "cards", label: "Cards", group: "build", icon: LayoutGrid, render: ({ dark }) => <IframePreview dark={dark} src="/preview/cards" title="Cards preview" /> },
229
+ { value: "dashboard", label: "Dashboard", group: "build", icon: LayoutDashboard, hidden: "md", render: ({ dark }) => <IframePreview dark={dark} src="/preview/dashboard" minWidth="1400px" title="Dashboard preview" /> },
230
+ { value: "customize", label: "Customize", group: "build", icon: SlidersHorizontal, render: () => <CustomizeTab /> },
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,160 @@ 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-60 shrink-0 flex-col border-r bg-card md:flex">
720
+ <div className="flex h-14 shrink-0 items-center border-b px-4">
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="truncate text-base font-semibold">{brand.name}</span>
752
+ {brand.tagline ? (
753
+ <span className="truncate text-xs text-muted-foreground" title={brand.tagline}>
754
+ {brand.tagline}
755
+ </span>
756
+ ) : null}
757
+ </span>
758
+ </>
759
+ )}
760
+ </div>
761
+ </div>
665
762
 
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
- }`}
763
+ <nav aria-label="Sections" className="min-h-0 flex-1 overflow-y-auto px-3 py-3">
764
+ <TabsList aria-label="Sections" className="flex h-auto w-full flex-col items-stretch gap-0.5 bg-transparent p-0">
765
+ {tabs
766
+ .filter((t) => !t.group)
767
+ .map((tab) => (
768
+ <RailTrigger key={tab.value} tab={tab} className={RAIL_ITEM} />
769
+ ))}
770
+ {SHELL_GROUPS.map((group) => {
771
+ const groupTabs = tabs.filter((t) => t.group === group.id);
772
+ if (groupTabs.length === 0) return null;
773
+ return (
774
+ // role="presentation" keeps these wrappers and their labels out
775
+ // of the tablist content model, which allows `tab` children only.
776
+ // axe tolerates the nesting, so a green axe run is not evidence.
777
+ <div key={group.id} role="presentation" className="mt-4 flex flex-col gap-0.5">
778
+ <div aria-hidden="true" className="px-2 pb-1.5 text-xs font-medium tracking-wider text-muted-foreground uppercase">
779
+ {group.label}
780
+ </div>
781
+ {groupTabs.map((tab) => (
782
+ <RailTrigger key={tab.value} tab={tab} className={RAIL_ITEM} />
783
+ ))}
784
+ </div>
785
+ );
786
+ })}
787
+ </TabsList>
788
+ </nav>
789
+
790
+ <div className="shrink-0 border-t p-3">
791
+ <div className="flex flex-wrap items-center gap-1.5 sm:gap-2 shrink-0">
792
+ {/* Fork-configurable header links — set `headerLinks` in brand.config
793
+ to add buttons (e.g. a link to a fork's prototypes site) without
794
+ shadowing this shell. Read defensively so forks that don't set it
795
+ are unaffected. */}
796
+ {((brand as { headerLinks?: { label: string; href: string }[] }).headerLinks ?? []).map((link) => (
797
+ <Button
798
+ key={link.href}
799
+ asChild
800
+ variant="ghost"
801
+ size="sm"
802
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
803
+ title={`Open ${link.label}`}
676
804
  >
677
- {tab.label}
678
- </TabsTrigger>
805
+ <a href={link.href} target="_blank" rel="noreferrer" aria-label={`Open ${link.label} in a new tab`}>
806
+ <ExternalLink className="h-4 w-4" strokeWidth={1.5} />
807
+ <span className="text-xs font-medium hidden sm:inline">{link.label}</span>
808
+ </a>
809
+ </Button>
679
810
  ))}
680
- </TabsList>
681
- </div>
811
+ {storybookUrl && (
812
+ <Button
813
+ asChild
814
+ variant="ghost"
815
+ size="sm"
816
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
817
+ title="Open Storybook"
818
+ >
819
+ <a href={storybookUrl} target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
820
+ <BookOpen className="h-4 w-4" strokeWidth={1.5} />
821
+ <span className="text-xs font-medium hidden sm:inline">Storybook</span>
822
+ </a>
823
+ </Button>
824
+ )}
825
+ {isDev && brand.repo && (
826
+ <Button
827
+ asChild
828
+ variant="ghost"
829
+ size="sm"
830
+ className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
831
+ title={`Open ${brand.repo.replace(/^https?:\/\//, "")} on GitHub`}
832
+ >
833
+ <a href={brand.repo} target="_blank" rel="noreferrer" aria-label="Open GitHub repo in a new tab">
834
+ <GithubMark className="h-4 w-4" />
835
+ <span className="text-xs font-medium hidden sm:inline">GitHub</span>
836
+ </a>
837
+ </Button>
838
+ )}
839
+ <Button
840
+ variant="ghost"
841
+ size="icon"
842
+ onClick={toggleDark}
843
+ className="group size-8 border border-foreground/30 hover:!bg-primary hover:!text-primary-foreground hover:border-primary"
844
+ aria-label={dark ? "Switch to light mode" : "Switch to dark mode"}
845
+ >
846
+ {dark ? (
847
+ <Sun className="h-4 w-4" strokeWidth={1.5} />
848
+ ) : (
849
+ <Moon className="h-4 w-4" strokeWidth={1.5} />
850
+ )}
851
+ </Button>
852
+ </div>
853
+ </div>
854
+ </aside>
682
855
 
856
+ {/* Main column. Owns its own scroll so the rail never moves with it. */}
857
+ <div className="flex min-w-0 flex-1 flex-col">
683
858
  <section id="main-content" tabIndex={-1} className="relative flex-1 min-h-0 w-full overflow-hidden scrollbar-gutter-stable">
684
859
  <div className="absolute inset-x-4 top-1 bottom-4 isolate overflow-hidden rounded-lg">
685
860
  <TabsPanels>
@@ -709,6 +884,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
709
884
  </TabsPanels>
710
885
  </div>
711
886
  </section>
887
+ </div>
712
888
  </Tabs>
713
889
 
714
890
  {/* Mobile navigation drawer — the tab list as a Sheet for small screens.
@@ -719,7 +895,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
719
895
  <SheetHeader>
720
896
  <SheetTitle>{brand.name}</SheetTitle>
721
897
  </SheetHeader>
722
- <nav className="mt-4 flex flex-col gap-1 px-2">
898
+ <nav aria-label="Sections" className="mt-4 flex flex-col gap-1 px-2">
723
899
  {tabs
724
900
  .filter((tab) => tab.hidden !== "md")
725
901
  .map((tab) => (