@behavioral-agentic-design-system/core 0.8.1 → 0.8.4
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.
- package/package.json +3 -2
- package/scripts/build-tokens.cjs +126 -14
- package/src/app/layout.tsx +1 -0
- package/src/app/preview/cards/page.tsx +1 -1
- package/src/app/preview/components/page.tsx +89 -4
- package/src/app/shell.tsx +92 -26
- package/src/components/Foundations/Motion.stories.tsx +98 -56
- package/src/components/brand-mark.tsx +7 -1
- package/src/components/customize/brand-mark-section.tsx +14 -5
- package/src/components/customize/letter-spacing.tsx +1 -1
- package/src/components/customize/save-bar.tsx +1 -1
- package/src/components/customize-tab.tsx +1 -1
- package/src/components/home-tab.tsx +48 -36
- package/src/components/layers-tab.tsx +26 -7
- package/src/components/ui/alert.tsx +26 -14
- package/src/components/ui/button.tsx +7 -7
- package/src/components/ui/scroll-area.tsx +13 -1
- package/src/components/ui/sheet.tsx +4 -2
- package/src/components/ui/sonner.tsx +36 -9
- package/src/density.css +74 -0
- package/src/lib/brand-mark-tone.ts +140 -0
- package/src/styles.css +312 -12
- package/src/tokens.json +30 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4",
|
|
4
4
|
"description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"./styles.css": "./src/styles.css",
|
|
47
47
|
"./fonts.css": "./src/fonts.css",
|
|
48
48
|
"./brand-fonts.css": "./src/brand-fonts.css",
|
|
49
|
+
"./density.css": "./src/density.css",
|
|
49
50
|
"./fonts/*": "./src/fonts/*",
|
|
50
51
|
"./tokens.json": "./src/tokens.json",
|
|
51
52
|
"./tokens.default.json": "./src/tokens.default.json",
|
|
@@ -123,7 +124,7 @@
|
|
|
123
124
|
"lucide-react": "*",
|
|
124
125
|
"next-themes": "*",
|
|
125
126
|
"react": ">=18",
|
|
126
|
-
"react-day-picker": "
|
|
127
|
+
"react-day-picker": "^9.14.0",
|
|
127
128
|
"react-dom": ">=18",
|
|
128
129
|
"react-resizable-panels": "*",
|
|
129
130
|
"recharts": "*",
|
package/scripts/build-tokens.cjs
CHANGED
|
@@ -159,7 +159,7 @@ const shadowBlock = ` --shadow-opacity: ${shadowOpacity};
|
|
|
159
159
|
--shadow-md: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('md')}), 0 2px 4px -1px hsl(0 0% 0% / ${shadowAlpha('md')});
|
|
160
160
|
--shadow-lg: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('lg')}), 0 4px 6px -1px hsl(0 0% 0% / ${shadowAlpha('lg')});
|
|
161
161
|
--shadow-xl: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('xl')}), 0 8px 10px -1px hsl(0 0% 0% / ${shadowAlpha('xl')});
|
|
162
|
-
--shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('2xl')});`;
|
|
162
|
+
--shadow-2xl: 0 1px 3px 0px hsl(0 0% 0% / ${shadowAlpha('2xl')}), 0 16px 24px -1px hsl(0 0% 0% / ${shadowAlpha('2xl')});`;
|
|
163
163
|
|
|
164
164
|
// Animation tokens emitted into :root from tokens.json. Components reference
|
|
165
165
|
// var(--duration-*) and var(--ease-*) so Sir's edits in tokens.json (or any
|
|
@@ -380,17 +380,20 @@ const themeInline = `@theme inline {
|
|
|
380
380
|
}`;
|
|
381
381
|
|
|
382
382
|
const baseLayer = `@layer base {
|
|
383
|
-
/*
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
\`
|
|
393
|
-
|
|
383
|
+
/* Default border + outline color for every element. Wrapped in \`:where()\`
|
|
384
|
+
so the selector has ZERO specificity: it still overrides the browser
|
|
385
|
+
default (border-color: currentColor — preflight's \`border: 0 solid\` sets
|
|
386
|
+
width/style but never color), yet ANY border-color utility (\`border-primary\`,
|
|
387
|
+
\`border-destructive\`, \`border-red-500\`, ...) at (0,1,0) cleanly beats it.
|
|
388
|
+
|
|
389
|
+
History: this was \`:root *\` (0,1,0) to beat preflight regardless of import
|
|
390
|
+
order — but that specificity TIED every border-color utility and won by
|
|
391
|
+
source order, so EVERY \`border-<color>\` silently rendered as --border grey
|
|
392
|
+
(only \`!important\` or arbitrary-with-! escaped it). \`:where(:root *)\` keeps
|
|
393
|
+
the preflight win (currentColor is the initial value, not a real rule, so a
|
|
394
|
+
0-specificity declaration still overrides it) while letting utilities win.
|
|
395
|
+
See ledgers/research.jsonl 2026-06-04 for the full diagnosis. */
|
|
396
|
+
:where(:root *) {
|
|
394
397
|
@apply border-border outline-ring/50;
|
|
395
398
|
}
|
|
396
399
|
/* Bind html to --font-sans so the picker propagates everywhere — not just
|
|
@@ -526,6 +529,42 @@ const baseLayer = `@layer base {
|
|
|
526
529
|
color: GrayText;
|
|
527
530
|
}
|
|
528
531
|
}
|
|
532
|
+
/* Clickable cursor — every interactive primitive gets cursor: pointer
|
|
533
|
+
* so click affordance is visually consistent. Tailwind v4 dropped the
|
|
534
|
+
* implicit pointer on <button> from v3's preflight; this restores it
|
|
535
|
+
* + extends to every other clickable native element and ARIA widget
|
|
536
|
+
* role. Disabled state → cursor: not-allowed so "off" reads as
|
|
537
|
+
* intentional rather than broken.
|
|
538
|
+
*
|
|
539
|
+
* Promoted from swimtopia-prototypes globals.css (2026-06-10) per
|
|
540
|
+
* Sir's "if it's clickable, the cursor says so" rule. */
|
|
541
|
+
button:not(:disabled),
|
|
542
|
+
a[href]:not([aria-disabled="true"]),
|
|
543
|
+
[role="button"]:not([aria-disabled="true"]),
|
|
544
|
+
[role="link"]:not([aria-disabled="true"]),
|
|
545
|
+
[role="tab"]:not([aria-disabled="true"]),
|
|
546
|
+
[role="menuitem"]:not([aria-disabled="true"]),
|
|
547
|
+
[role="option"]:not([aria-disabled="true"]),
|
|
548
|
+
[role="checkbox"]:not([aria-disabled="true"]),
|
|
549
|
+
[role="radio"]:not([aria-disabled="true"]),
|
|
550
|
+
[role="switch"]:not([aria-disabled="true"]),
|
|
551
|
+
input[type="button"]:not(:disabled),
|
|
552
|
+
input[type="submit"]:not(:disabled),
|
|
553
|
+
input[type="reset"]:not(:disabled),
|
|
554
|
+
input[type="checkbox"]:not(:disabled),
|
|
555
|
+
input[type="radio"]:not(:disabled),
|
|
556
|
+
select:not(:disabled),
|
|
557
|
+
label[for],
|
|
558
|
+
summary {
|
|
559
|
+
cursor: pointer;
|
|
560
|
+
}
|
|
561
|
+
button:disabled,
|
|
562
|
+
input:disabled,
|
|
563
|
+
select:disabled,
|
|
564
|
+
textarea:disabled,
|
|
565
|
+
[aria-disabled="true"] {
|
|
566
|
+
cursor: not-allowed;
|
|
567
|
+
}
|
|
529
568
|
}
|
|
530
569
|
|
|
531
570
|
/* Global tracking offset — the Letter Spacing slider in the Customize
|
|
@@ -567,6 +606,55 @@ html, body {
|
|
|
567
606
|
::view-transition-new(root) { animation: none; }
|
|
568
607
|
}`;
|
|
569
608
|
|
|
609
|
+
// ---- Border-color utilities (workaround for a TURBOPACK bug) --------------
|
|
610
|
+
//
|
|
611
|
+
// ROOT CAUSE (confirmed 2026-06-09, see ledgers/research.jsonl): Next's
|
|
612
|
+
// Turbopack does NOT emit PLAIN named border-color utilities (`border-primary`,
|
|
613
|
+
// `border-destructive`, `border-l-primary`, ...). It keeps the `/opacity`
|
|
614
|
+
// variants (`border-primary/30`), arbitrary values (`border-[var(--x)]`), and
|
|
615
|
+
// every other utility family (`text-*`, `bg-*`, ...) — only the plain
|
|
616
|
+
// border-color set is dropped. The class lands on the element but no rule is
|
|
617
|
+
// emitted, so the color falls through to the `:where(:root *)` default and
|
|
618
|
+
// renders as --border grey. Proven by a same-source A/B: `@tailwindcss/postcss`
|
|
619
|
+
// (webpack / Storybook) generates `.border-primary {…}` fine; `next build`
|
|
620
|
+
// (Turbopack) does not. Nothing in this theme or the base reset causes it —
|
|
621
|
+
// ruled out via real builds (theme var-indirection, @apply-vs-raw reset).
|
|
622
|
+
//
|
|
623
|
+
// That made ~20 components render colored borders as grey (mostly hidden on
|
|
624
|
+
// filled controls, visible on outlined ones — checkbox/radio boxes, input
|
|
625
|
+
// error borders, selected-card borders, alerts).
|
|
626
|
+
//
|
|
627
|
+
// Rather than convert every call site to arbitrary values or drop Turbopack,
|
|
628
|
+
// we emit the plain utilities here, once, for the whole semantic palette — so
|
|
629
|
+
// every existing `border-<color>` across all components AND every downstream
|
|
630
|
+
// fork just works under Turbopack. Emitted in @layer utilities so they beat
|
|
631
|
+
// the base reset but still lose to a component's own higher-specificity state
|
|
632
|
+
// variants (e.g. hover:border-*). Revisit if/when Turbopack fixes the gap.
|
|
633
|
+
const BORDER_COLOR_NAMES = [
|
|
634
|
+
'background', 'foreground', 'card', 'card-foreground', 'popover',
|
|
635
|
+
'popover-foreground', 'primary', 'primary-foreground', 'link', 'secondary',
|
|
636
|
+
'secondary-foreground', 'muted', 'muted-foreground', 'accent',
|
|
637
|
+
'accent-foreground', 'destructive', 'destructive-foreground', 'success',
|
|
638
|
+
'warning', 'info', 'border', 'input', 'ring', 'chart-1', 'chart-2', 'chart-3',
|
|
639
|
+
'chart-4', 'chart-5', 'sidebar', 'sidebar-foreground', 'sidebar-primary',
|
|
640
|
+
'sidebar-primary-foreground', 'sidebar-accent', 'sidebar-accent-foreground',
|
|
641
|
+
'sidebar-border', 'sidebar-ring',
|
|
642
|
+
];
|
|
643
|
+
const borderColorUtilities = `@layer utilities {
|
|
644
|
+
${BORDER_COLOR_NAMES.map((c) => {
|
|
645
|
+
const v = `var(--${c})`;
|
|
646
|
+
return [
|
|
647
|
+
` .border-${c} { border-color: ${v}; }`,
|
|
648
|
+
` .border-x-${c} { border-inline-color: ${v}; }`,
|
|
649
|
+
` .border-y-${c} { border-block-color: ${v}; }`,
|
|
650
|
+
` .border-l-${c} { border-left-color: ${v}; }`,
|
|
651
|
+
` .border-r-${c} { border-right-color: ${v}; }`,
|
|
652
|
+
` .border-t-${c} { border-top-color: ${v}; }`,
|
|
653
|
+
` .border-b-${c} { border-bottom-color: ${v}; }`,
|
|
654
|
+
].join('\n');
|
|
655
|
+
}).join('\n')}
|
|
656
|
+
}`;
|
|
657
|
+
|
|
570
658
|
// ---- packages/core/src/styles.css (consumer-facing) ----------------------
|
|
571
659
|
|
|
572
660
|
const pkgCss = `${banner}
|
|
@@ -649,6 +737,8 @@ ${chartDerivationDark}
|
|
|
649
737
|
${themeInline}
|
|
650
738
|
|
|
651
739
|
${baseLayer}
|
|
740
|
+
|
|
741
|
+
${borderColorUtilities}
|
|
652
742
|
`;
|
|
653
743
|
|
|
654
744
|
fs.writeFileSync(PKG_CSS, pkgCss);
|
|
@@ -667,9 +757,25 @@ const appCss = `${banner}
|
|
|
667
757
|
* package read from the same canonical files. */
|
|
668
758
|
@import "../packages/core/src/fonts.css";
|
|
669
759
|
@import "../packages/core/src/brand-fonts.css";
|
|
670
|
-
@import "tailwindcss";
|
|
760
|
+
@import "tailwindcss" source(none);
|
|
671
761
|
@import "tw-animate-css";
|
|
672
762
|
|
|
763
|
+
/* Scope Tailwind's content scan to the preview app's actual UI source.
|
|
764
|
+
* source(none) disables Tailwind v4's automatic whole-project detection,
|
|
765
|
+
* which otherwise scans repo-root text/data dirs (ledgers/, content/, docs/,
|
|
766
|
+
* corrections/, prompts/, layer-*) and harvests code-like strings out of them.
|
|
767
|
+
* One such string — a literal arbitrary border value inside a
|
|
768
|
+
* ledgers/research.jsonl note — generated an invalid empty border-color: var()
|
|
769
|
+
* rule that crashed the CSS parser and 500'd every route. Listing the real
|
|
770
|
+
* source dirs explicitly is the same discipline packages/core/src/styles.css
|
|
771
|
+
* already uses (see its @source block) and keeps the scan deterministic. Paths
|
|
772
|
+
* resolve relative to this file (styles/globals.css). */
|
|
773
|
+
@source "../app/**/*.{ts,tsx}";
|
|
774
|
+
@source "../components/**/*.{ts,tsx}";
|
|
775
|
+
@source "../hooks/**/*.{ts,tsx}";
|
|
776
|
+
@source "../lib/**/*.{ts,tsx}";
|
|
777
|
+
@source "../packages/core/src/**/*.{ts,tsx}";
|
|
778
|
+
|
|
673
779
|
@custom-variant dark (&:is(.dark *));
|
|
674
780
|
|
|
675
781
|
:root {
|
|
@@ -709,9 +815,15 @@ ${themeInline}
|
|
|
709
815
|
|
|
710
816
|
${baseLayer}
|
|
711
817
|
|
|
818
|
+
${borderColorUtilities}
|
|
819
|
+
|
|
820
|
+
/* color-scheme only. The default border color comes from the :where(:root *)
|
|
821
|
+
* rule in the base layer above — do NOT set border-color here: an unlayered
|
|
822
|
+
* star-selector border-color beats every @layer utilities border-color utility
|
|
823
|
+
* (unlayered trumps layered regardless of specificity), which silently
|
|
824
|
+
* rendered all colored borders grey in the app. */
|
|
712
825
|
* {
|
|
713
826
|
color-scheme: light dark;
|
|
714
|
-
border-color: var(--color-border);
|
|
715
827
|
}
|
|
716
828
|
${clientExtras}`;
|
|
717
829
|
|
package/src/app/layout.tsx
CHANGED
|
@@ -3,6 +3,7 @@ import fs from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { Atkinson_Hyperlegible, Inter, JetBrains_Mono, Lora, Source_Serif_4 } from "next/font/google";
|
|
5
5
|
import "@/styles/globals.css";
|
|
6
|
+
import "../density.css";
|
|
6
7
|
import { brand } from "@/brand.config";
|
|
7
8
|
import Providers from "./providers";
|
|
8
9
|
import { FontReady } from "./font-ready";
|
|
@@ -35,7 +35,9 @@ import {
|
|
|
35
35
|
BottomSheetTitle,
|
|
36
36
|
BottomSheetTrigger,
|
|
37
37
|
} from "@behavioral-agentic-design-system/core/components/ui/bottom-sheet";
|
|
38
|
-
import { Sparkles, Info } from "lucide-react";
|
|
38
|
+
import { Sparkles, Info, CircleAlert } from "lucide-react";
|
|
39
|
+
import { Toaster } from "@behavioral-agentic-design-system/core/components/ui/sonner";
|
|
40
|
+
import { toast } from "sonner";
|
|
39
41
|
|
|
40
42
|
// Stable, deterministic data for ScrollArea — never use Math.random in
|
|
41
43
|
// SSR-rendered output, it causes hydration mismatches.
|
|
@@ -57,7 +59,7 @@ function Section({ title, children }: { title: string; children: React.ReactNode
|
|
|
57
59
|
export default function ComponentsPreview() {
|
|
58
60
|
return (
|
|
59
61
|
<div className="min-h-screen bg-background">
|
|
60
|
-
<div className="mx-auto max-w-5xl space-y-10 p-8">
|
|
62
|
+
<div className="mx-auto max-w-5xl space-y-10 p-4 sm:p-6 lg:p-8">
|
|
61
63
|
<header className="space-y-2">
|
|
62
64
|
<div className="flex items-center gap-2">
|
|
63
65
|
<Sparkles className="size-5 text-primary" />
|
|
@@ -176,13 +178,45 @@ export default function ComponentsPreview() {
|
|
|
176
178
|
</CardContent>
|
|
177
179
|
</Card>
|
|
178
180
|
<Alert>
|
|
179
|
-
<Info className="size-
|
|
181
|
+
<Info className="size-5" />
|
|
180
182
|
<AlertTitle>Heads up</AlertTitle>
|
|
181
|
-
<AlertDescription>
|
|
183
|
+
<AlertDescription>You can update settings any time.</AlertDescription>
|
|
184
|
+
</Alert>
|
|
185
|
+
<Alert variant="destructive">
|
|
186
|
+
<CircleAlert className="size-5" />
|
|
187
|
+
<AlertTitle>Save failed</AlertTitle>
|
|
188
|
+
<AlertDescription>Couldn't reach the server. Try again.</AlertDescription>
|
|
182
189
|
</Alert>
|
|
183
190
|
</div>
|
|
184
191
|
</Section>
|
|
185
192
|
|
|
193
|
+
<Section title="Density">
|
|
194
|
+
<p className="text-sm text-muted-foreground">
|
|
195
|
+
Opt in with <code className="font-mono text-xs">data-density="compact"</code> or{" "}
|
|
196
|
+
<code className="font-mono text-xs">"comfortable"</code>{" "}on any container. It tightens or
|
|
197
|
+
loosens non-interactive rhythm (card padding, gaps, table rows) — interactive
|
|
198
|
+
controls keep the 44×44 touch-target floor. Same card, three densities:
|
|
199
|
+
</p>
|
|
200
|
+
<div className="grid gap-4 sm:grid-cols-3">
|
|
201
|
+
{(["compact", undefined, "comfortable"] as const).map((d, i) => (
|
|
202
|
+
<div key={i} data-density={d}>
|
|
203
|
+
<p className="mb-2 text-xs uppercase tracking-wide text-muted-foreground">
|
|
204
|
+
{d ?? "default"}
|
|
205
|
+
</p>
|
|
206
|
+
<Card>
|
|
207
|
+
<CardHeader>
|
|
208
|
+
<CardTitle>Card title</CardTitle>
|
|
209
|
+
<CardDescription>One line of supporting copy.</CardDescription>
|
|
210
|
+
</CardHeader>
|
|
211
|
+
<CardContent>
|
|
212
|
+
<p className="text-sm text-muted-foreground">Card body content lives here.</p>
|
|
213
|
+
</CardContent>
|
|
214
|
+
</Card>
|
|
215
|
+
</div>
|
|
216
|
+
))}
|
|
217
|
+
</div>
|
|
218
|
+
</Section>
|
|
219
|
+
|
|
186
220
|
<Section title="Tabs & Dialog">
|
|
187
221
|
<Tabs defaultValue="one" className="w-full">
|
|
188
222
|
<TabsList>
|
|
@@ -303,6 +337,57 @@ export default function ComponentsPreview() {
|
|
|
303
337
|
</BottomSheet>
|
|
304
338
|
</div>
|
|
305
339
|
</Section>
|
|
340
|
+
|
|
341
|
+
<Section title="Toast (Sonner)">
|
|
342
|
+
<p className="mb-4 text-sm text-muted-foreground">
|
|
343
|
+
Status variants color the icon + a left accent bar in the matching
|
|
344
|
+
status token (success / warning / info / error). The surface and
|
|
345
|
+
body text stay neutral so copy keeps AAA contrast.
|
|
346
|
+
</p>
|
|
347
|
+
<div className="flex flex-wrap gap-3">
|
|
348
|
+
<Button
|
|
349
|
+
variant="outline"
|
|
350
|
+
onClick={() =>
|
|
351
|
+
toast.success("Changes saved", {
|
|
352
|
+
description: "Your settings are up to date.",
|
|
353
|
+
})
|
|
354
|
+
}
|
|
355
|
+
>
|
|
356
|
+
Success
|
|
357
|
+
</Button>
|
|
358
|
+
<Button
|
|
359
|
+
variant="outline"
|
|
360
|
+
onClick={() =>
|
|
361
|
+
toast.warning("Storage almost full", {
|
|
362
|
+
description: "You're using 92% of your plan's storage.",
|
|
363
|
+
})
|
|
364
|
+
}
|
|
365
|
+
>
|
|
366
|
+
Warning
|
|
367
|
+
</Button>
|
|
368
|
+
<Button
|
|
369
|
+
variant="outline"
|
|
370
|
+
onClick={() =>
|
|
371
|
+
toast.info("New version available", {
|
|
372
|
+
description: "Reload to get the latest components.",
|
|
373
|
+
})
|
|
374
|
+
}
|
|
375
|
+
>
|
|
376
|
+
Info
|
|
377
|
+
</Button>
|
|
378
|
+
<Button
|
|
379
|
+
variant="outline"
|
|
380
|
+
onClick={() =>
|
|
381
|
+
toast.error("Upload failed", {
|
|
382
|
+
description: "The file exceeds the 25MB limit.",
|
|
383
|
+
})
|
|
384
|
+
}
|
|
385
|
+
>
|
|
386
|
+
Error
|
|
387
|
+
</Button>
|
|
388
|
+
</div>
|
|
389
|
+
<Toaster />
|
|
390
|
+
</Section>
|
|
306
391
|
</div>
|
|
307
392
|
</div>
|
|
308
393
|
);
|
package/src/app/shell.tsx
CHANGED
|
@@ -34,6 +34,15 @@ import { OnboardingWizard } from "@behavioral-agentic-design-system/core/compone
|
|
|
34
34
|
|
|
35
35
|
const ONBOARDING_DISMISSED_KEY = "bads:onboarding-wizard:dismissed";
|
|
36
36
|
|
|
37
|
+
// Survives a full-page reload so the user lands back on the tab they were on.
|
|
38
|
+
// Several Customize-tab actions call window.location.reload() to re-read
|
|
39
|
+
// defaults cleanly (Reset all, brand-color applies, pin-to-brand.config) — and
|
|
40
|
+
// activeTab is plain React state, so without this every reload snaps back to
|
|
41
|
+
// the default tab. sessionStorage (not localStorage) keeps it session-scoped
|
|
42
|
+
// and outside the Customize tab's localStorage prefix-sweep, so Reset all can't
|
|
43
|
+
// wipe it before the reload it just triggered.
|
|
44
|
+
const ACTIVE_TAB_KEY = "bads:shell:active-tab";
|
|
45
|
+
|
|
37
46
|
const SETUP_PROMPT = `You are setting up a fresh BADS fork. Use the in-app onboarding brief that the user just completed as your source of truth. Do not re-ask questions that are already answered. Ask only for missing or contradictory details, then run the canonical setup steps in order: rename, source discovery, brand context, voice, microcopy, ethics, tokens, components, patterns, and Chromatic baseline.`;
|
|
38
47
|
|
|
39
48
|
/**
|
|
@@ -203,7 +212,11 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
203
212
|
} catch {}
|
|
204
213
|
setOnboardingDismissed(true);
|
|
205
214
|
};
|
|
206
|
-
|
|
215
|
+
// Temporarily hidden everywhere per Sir (2026-06-04): the wizard was popping
|
|
216
|
+
// on the deployed showcase. Flip ONBOARDING_WIZARD_ENABLED back to true to
|
|
217
|
+
// restore the fresh-fork setup wizard.
|
|
218
|
+
const ONBOARDING_WIZARD_ENABLED = false;
|
|
219
|
+
const showOnboarding = ONBOARDING_WIZARD_ENABLED && isFreshFork && !onboardingDismissed;
|
|
207
220
|
// Sticky-mount: once a tab has been viewed, keep it mounted forever so the
|
|
208
221
|
// iframe (or React tree) doesn't cold-load on every switch. TabsPanels
|
|
209
222
|
// cross-fades between mounted siblings, so subsequent switches are instant
|
|
@@ -213,6 +226,34 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
213
226
|
setSeen((prev) => (prev.has(activeTab) ? prev : new Set(prev).add(activeTab)));
|
|
214
227
|
}, [activeTab]);
|
|
215
228
|
|
|
229
|
+
// Tab changes flow through this so the choice is persisted for reload
|
|
230
|
+
// restoration. The restore effect below reads it back on mount. Persisting
|
|
231
|
+
// only on real changes (not on mount) means there's no race with the restore
|
|
232
|
+
// read — sessionStorage is never clobbered with the default before it's read.
|
|
233
|
+
const selectTab = useCallback((value: string) => {
|
|
234
|
+
setActiveTab(value);
|
|
235
|
+
try {
|
|
236
|
+
window.sessionStorage.setItem(ACTIVE_TAB_KEY, value);
|
|
237
|
+
} catch {}
|
|
238
|
+
}, []);
|
|
239
|
+
|
|
240
|
+
// Restore the pre-reload tab once on mount. Only restores a tab that still
|
|
241
|
+
// exists in this shell's tab set, so a fork that drops a tab between sessions
|
|
242
|
+
// falls back to the default instead of a blank panel.
|
|
243
|
+
useEffect(() => {
|
|
244
|
+
let stored: string | null = null;
|
|
245
|
+
try {
|
|
246
|
+
stored = window.sessionStorage.getItem(ACTIVE_TAB_KEY);
|
|
247
|
+
} catch {}
|
|
248
|
+
const target = stored;
|
|
249
|
+
if (target && target !== initialTab && tabs.some((t) => t.value === target)) {
|
|
250
|
+
setActiveTab(target);
|
|
251
|
+
setSeen((prev) => (prev.has(target) ? prev : new Set(prev).add(target)));
|
|
252
|
+
}
|
|
253
|
+
// Mount-only: restore the persisted tab a single time.
|
|
254
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
255
|
+
}, []);
|
|
256
|
+
|
|
216
257
|
// Background preload: after the active tab has fully painted and idled,
|
|
217
258
|
// mount every other tab so they load silently while the user is reading
|
|
218
259
|
// the home tab. By the time someone clicks any other tab, its iframe is
|
|
@@ -289,37 +330,62 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
289
330
|
});
|
|
290
331
|
};
|
|
291
332
|
|
|
292
|
-
const ctx: ShellTabContext = { dark, goToTab:
|
|
293
|
-
const navValue = useMemo<ShellNav>(() => ({ setTab:
|
|
333
|
+
const ctx: ShellTabContext = { dark, goToTab: selectTab };
|
|
334
|
+
const navValue = useMemo<ShellNav>(() => ({ setTab: selectTab }), [selectTab]);
|
|
335
|
+
|
|
336
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
337
|
+
|
|
338
|
+
// Storybook header link. In dev it points at the local Storybook server
|
|
339
|
+
// (localhost:6080, started by `pnpm dev` / `pnpm storybook`). In production
|
|
340
|
+
// the static Storybook is built into public/storybook/<commit-sha> by the
|
|
341
|
+
// `vercel-build` script and served same-origin at /storybook/<sha>. The SHA
|
|
342
|
+
// in the path is a cache-bust: every deploy gets a brand-new URL the browser
|
|
343
|
+
// has never fetched, so the whole Storybook bundle (manager + iframe shell +
|
|
344
|
+
// story index) loads fresh instead of serving a stale cached copy. The SHA
|
|
345
|
+
// is inlined here via NEXT_PUBLIC_STORYBOOK_VERSION (set to the same value by
|
|
346
|
+
// vercel-build); "dev" is the fallback for a non-Vercel prod build. Override
|
|
347
|
+
// per-fork with NEXT_PUBLIC_STORYBOOK_URL (a standalone deploy or Chromatic
|
|
348
|
+
// permalink); set it to "" to hide the link on a fork without Storybook.
|
|
349
|
+
const storybookUrl =
|
|
350
|
+
process.env.NEXT_PUBLIC_STORYBOOK_URL ??
|
|
351
|
+
(isDev
|
|
352
|
+
? "http://localhost:6080"
|
|
353
|
+
: `/storybook/${process.env.NEXT_PUBLIC_STORYBOOK_VERSION || "dev"}/index.html`);
|
|
354
|
+
|
|
355
|
+
// The GitHub link points at brand.repo, which 404s for anonymous visitors
|
|
356
|
+
// when the repo is private — so it stays dev-only. A fork with a public repo
|
|
357
|
+
// can drop `isDev &&` from its condition below.
|
|
294
358
|
|
|
295
359
|
return (
|
|
296
360
|
<ShellNavContext.Provider value={navValue}>
|
|
297
361
|
<div className="min-h-screen bg-background flex flex-col">
|
|
298
362
|
<header className="border-b bg-card shrink-0">
|
|
299
|
-
<div className="flex h-14 items-center px-6">
|
|
300
|
-
<div className="flex items-center gap-2">
|
|
363
|
+
<div className="flex h-14 items-center px-4 sm:px-6">
|
|
364
|
+
<div className="flex items-center gap-2 min-w-0">
|
|
301
365
|
<div
|
|
302
|
-
className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary text-primary-foreground"
|
|
366
|
+
className="h-8 w-8 rounded-lg flex items-center justify-center bg-primary text-primary-foreground shrink-0"
|
|
303
367
|
>
|
|
304
368
|
<BrandMark size={20} />
|
|
305
369
|
</div>
|
|
306
|
-
<span className="text-lg font-semibold">{brand.name}</span>
|
|
307
|
-
<Badge variant="outline" className="ml-2 text-xs">{brand.tagline}</Badge>
|
|
370
|
+
<span className="text-lg font-semibold truncate">{brand.name}</span>
|
|
371
|
+
<Badge variant="outline" className="ml-2 text-xs hidden sm:inline-flex">{brand.tagline}</Badge>
|
|
308
372
|
</div>
|
|
309
|
-
<div className="ml-auto flex items-center gap-2">
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
<
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
373
|
+
<div className="ml-auto flex items-center gap-1.5 sm:gap-2 shrink-0">
|
|
374
|
+
{storybookUrl && (
|
|
375
|
+
<Button
|
|
376
|
+
asChild
|
|
377
|
+
variant="ghost"
|
|
378
|
+
size="sm"
|
|
379
|
+
className="group h-8 gap-1.5 border border-foreground/30 hover:!bg-foreground hover:!text-background hover:border-foreground"
|
|
380
|
+
title="Open Storybook"
|
|
381
|
+
>
|
|
382
|
+
<a href={storybookUrl} target="_blank" rel="noreferrer" aria-label="Open Storybook in a new tab">
|
|
383
|
+
<BookOpen className="h-4 w-4 transition-all group-hover:scale-110" strokeWidth={1.5} />
|
|
384
|
+
<span className="text-xs font-medium hidden sm:inline">Storybook</span>
|
|
385
|
+
</a>
|
|
386
|
+
</Button>
|
|
387
|
+
)}
|
|
388
|
+
{isDev && brand.repo && (
|
|
323
389
|
<Button
|
|
324
390
|
asChild
|
|
325
391
|
variant="ghost"
|
|
@@ -329,7 +395,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
329
395
|
>
|
|
330
396
|
<a href={brand.repo} target="_blank" rel="noreferrer" aria-label="Open GitHub repo in a new tab">
|
|
331
397
|
<GithubMark className="h-4 w-4 transition-all group-hover:scale-110" />
|
|
332
|
-
<span className="text-xs font-medium">GitHub</span>
|
|
398
|
+
<span className="text-xs font-medium hidden sm:inline">GitHub</span>
|
|
333
399
|
</a>
|
|
334
400
|
</Button>
|
|
335
401
|
)}
|
|
@@ -352,14 +418,14 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
352
418
|
|
|
353
419
|
<Tabs
|
|
354
420
|
value={activeTab}
|
|
355
|
-
onValueChange={
|
|
421
|
+
onValueChange={selectTab}
|
|
356
422
|
// Slower cross-fade between mounted panels — 260ms feels deliberate
|
|
357
423
|
// without dragging. Read by the duration utility on TabsPanels.
|
|
358
424
|
style={{ "--tabs-fade-duration": "260ms" } as React.CSSProperties}
|
|
359
425
|
className="flex-1 flex flex-col overflow-hidden"
|
|
360
426
|
>
|
|
361
|
-
<div className="mt-2 mb-1 flex w-full items-center px-4">
|
|
362
|
-
<TabsList className="bg-background text-muted-foreground inline-flex w-
|
|
427
|
+
<div className="mt-2 mb-1 flex w-full items-center px-4 overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden">
|
|
428
|
+
<TabsList className="bg-background text-muted-foreground inline-flex w-max shrink-0 items-center justify-center rounded-full px-0">
|
|
363
429
|
{tabs.map((tab) => (
|
|
364
430
|
<TabsTrigger
|
|
365
431
|
key={tab.value}
|