@behavioral-agentic-design-system/core 0.2.1 → 0.3.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.
Files changed (49) hide show
  1. package/package.json +37 -4
  2. package/scripts/bads-sync.mjs +81 -0
  3. package/scripts/build-tokens.cjs +487 -0
  4. package/src/api/bads-update-check.ts +151 -0
  5. package/src/api/brand-colors.ts +180 -0
  6. package/src/api/layers/file.ts +71 -0
  7. package/src/api/layers.ts +49 -0
  8. package/src/api/save-tokens.ts +280 -0
  9. package/src/app/font-ready.tsx +51 -0
  10. package/src/app/layout.tsx +152 -0
  11. package/src/app/page.tsx +267 -0
  12. package/src/app/preview/cards/page.tsx +8 -0
  13. package/src/app/preview/components/page.tsx +232 -0
  14. package/src/app/preview/dark-mode-client.tsx +24 -0
  15. package/src/app/preview/dashboard/page.tsx +4 -0
  16. package/src/app/preview/global-font-client.tsx +36 -0
  17. package/src/app/preview/layout.tsx +13 -0
  18. package/src/app/preview/mail/page.tsx +4 -0
  19. package/src/app/preview/pricing/page.tsx +4 -0
  20. package/src/app/preview/typography/page.tsx +11 -0
  21. package/src/app/providers.tsx +49 -0
  22. package/src/components/Foundations/Colors.stories.tsx +85 -0
  23. package/src/components/Foundations/Motion.stories.tsx +169 -0
  24. package/src/components/Foundations/Radius.stories.tsx +36 -0
  25. package/src/components/Foundations/Shadows.stories.tsx +30 -0
  26. package/src/components/Foundations/Spacing.stories.tsx +35 -0
  27. package/src/components/Foundations/Typography.stories.tsx +68 -0
  28. package/src/components/bads-update-banner.tsx +120 -0
  29. package/src/components/customize/design-controls.tsx +165 -0
  30. package/src/components/customize/font-pickers.tsx +118 -0
  31. package/src/components/customize/letter-spacing.tsx +105 -0
  32. package/src/components/customize/save-bar.tsx +379 -0
  33. package/src/components/customize/theme-io.tsx +245 -0
  34. package/src/components/customize/type-scale.tsx +134 -0
  35. package/src/components/customize-tab.tsx +502 -0
  36. package/src/components/home-tab.tsx +1227 -0
  37. package/src/components/layers-tab.tsx +225 -0
  38. package/src/components/ui/alert.tsx +5 -1
  39. package/src/hooks/use-global-design-controls.ts +117 -0
  40. package/src/hooks/use-global-mono-font.ts +73 -0
  41. package/src/hooks/use-global-primary-color.ts +544 -0
  42. package/src/hooks/use-global-sans-font.ts +98 -0
  43. package/src/hooks/use-global-serif-font.ts +77 -0
  44. package/src/hooks/use-global-theme.ts +259 -0
  45. package/src/hooks/use-global-type-scale.ts +141 -0
  46. package/src/hooks/use-sync-type-scale.ts +51 -0
  47. package/src/hooks/use-token-overrides.ts +98 -0
  48. package/src/styles.css +40 -6
  49. package/src/tokens.json +86 -5
@@ -0,0 +1,85 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+
3
+ const meta: Meta = {
4
+ title: "Foundations/Colors",
5
+ parameters: { layout: "fullscreen" },
6
+ };
7
+ export default meta;
8
+ type Story = StoryObj<typeof meta>;
9
+
10
+ const GROUPS: Record<string, { name: string; var: string; bg: string; fg?: string }[]> = {
11
+ "Primary": [
12
+ { name: "Background", var: "--background", bg: "bg-background", fg: "text-foreground" },
13
+ { name: "Foreground", var: "--foreground", bg: "bg-foreground", fg: "text-background" },
14
+ { name: "Primary", var: "--primary", bg: "bg-primary", fg: "text-primary-foreground" },
15
+ { name: "Primary FG", var: "--primary-foreground", bg: "bg-primary-foreground", fg: "text-primary" },
16
+ ],
17
+ "Secondary & Accent": [
18
+ { name: "Secondary", var: "--secondary", bg: "bg-secondary", fg: "text-secondary-foreground" },
19
+ { name: "Secondary FG", var: "--secondary-foreground", bg: "bg-secondary-foreground", fg: "text-secondary" },
20
+ { name: "Accent", var: "--accent", bg: "bg-accent", fg: "text-accent-foreground" },
21
+ { name: "Accent FG", var: "--accent-foreground", bg: "bg-accent-foreground", fg: "text-accent" },
22
+ ],
23
+ "UI Surfaces": [
24
+ { name: "Card", var: "--card", bg: "bg-card", fg: "text-card-foreground" },
25
+ { name: "Card FG", var: "--card-foreground", bg: "bg-card-foreground", fg: "text-card" },
26
+ { name: "Popover", var: "--popover", bg: "bg-popover", fg: "text-popover-foreground" },
27
+ { name: "Popover FG", var: "--popover-foreground", bg: "bg-popover-foreground", fg: "text-popover" },
28
+ { name: "Muted", var: "--muted", bg: "bg-muted", fg: "text-muted-foreground" },
29
+ { name: "Muted FG", var: "--muted-foreground", bg: "bg-muted-foreground", fg: "text-muted" },
30
+ ],
31
+ "Utility": [
32
+ { name: "Border", var: "--border", bg: "bg-border" },
33
+ { name: "Input", var: "--input", bg: "bg-input" },
34
+ { name: "Ring", var: "--ring", bg: "bg-ring" },
35
+ ],
36
+ "Status": [
37
+ { name: "Destructive", var: "--destructive", bg: "bg-destructive", fg: "text-destructive-foreground" },
38
+ { name: "Destructive FG", var: "--destructive-foreground", bg: "bg-destructive-foreground", fg: "text-destructive" },
39
+ ],
40
+ "Charts": [
41
+ { name: "Chart 1", var: "--chart-1", bg: "bg-chart-1", fg: "text-white" },
42
+ { name: "Chart 2", var: "--chart-2", bg: "bg-chart-2", fg: "text-white" },
43
+ { name: "Chart 3", var: "--chart-3", bg: "bg-chart-3", fg: "text-white" },
44
+ { name: "Chart 4", var: "--chart-4", bg: "bg-chart-4", fg: "text-white" },
45
+ { name: "Chart 5", var: "--chart-5", bg: "bg-chart-5", fg: "text-white" },
46
+ ],
47
+ "Sidebar": [
48
+ { name: "Sidebar", var: "--sidebar", bg: "bg-sidebar", fg: "text-sidebar-foreground" },
49
+ { name: "Sidebar FG", var: "--sidebar-foreground", bg: "bg-sidebar-foreground", fg: "text-sidebar" },
50
+ { name: "Sidebar Primary", var: "--sidebar-primary", bg: "bg-sidebar-primary", fg: "text-sidebar-primary-foreground" },
51
+ { name: "Sidebar Primary FG", var: "--sidebar-primary-foreground", bg: "bg-sidebar-primary-foreground", fg: "text-sidebar-primary" },
52
+ { name: "Sidebar Accent", var: "--sidebar-accent", bg: "bg-sidebar-accent", fg: "text-sidebar-accent-foreground" },
53
+ { name: "Sidebar Accent FG", var: "--sidebar-accent-foreground", bg: "bg-sidebar-accent-foreground", fg: "text-sidebar-accent" },
54
+ { name: "Sidebar Border", var: "--sidebar-border", bg: "bg-sidebar-border" },
55
+ { name: "Sidebar Ring", var: "--sidebar-ring", bg: "bg-sidebar-ring" },
56
+ ],
57
+ };
58
+
59
+ function Swatch({ name, var: v, bg, fg }: { name: string; var: string; bg: string; fg?: string }) {
60
+ return (
61
+ <div className="flex flex-col">
62
+ <div className={`h-20 rounded-lg border border-border ${bg} ${fg ?? ""} flex items-end p-2.5`}>
63
+ <span className="text-sm font-medium">{name}</span>
64
+ </div>
65
+ <p className="text-xs text-muted-foreground font-mono mt-1.5">{v}</p>
66
+ </div>
67
+ );
68
+ }
69
+
70
+ export const All: Story = {
71
+ render: () => (
72
+ <div className="p-8 space-y-8 bg-background">
73
+ {Object.entries(GROUPS).map(([title, swatches]) => (
74
+ <section key={title}>
75
+ <h3 className="text-sm font-semibold text-muted-foreground mb-3">{title}</h3>
76
+ <div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-3">
77
+ {swatches.map((s) => (
78
+ <Swatch key={s.var} {...s} />
79
+ ))}
80
+ </div>
81
+ </section>
82
+ ))}
83
+ </div>
84
+ ),
85
+ };
@@ -0,0 +1,169 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { useState } from "react";
3
+
4
+ const meta: Meta = {
5
+ title: "Foundations/Motion",
6
+ parameters: { layout: "fullscreen" },
7
+ };
8
+ export default meta;
9
+ type Story = StoryObj<typeof meta>;
10
+
11
+ const DURATIONS = [
12
+ { name: "fast", value: "150ms", note: "Hovers, focus rings, micro-feedback" },
13
+ { name: "base", value: "200ms", note: "Default for opens/closes, theme swaps" },
14
+ { name: "slow", value: "300ms", note: "Sheets, dialogs, larger surface motion" },
15
+ ];
16
+
17
+ const EASINGS = [
18
+ {
19
+ name: "ease-in",
20
+ value: "cubic-bezier(0.4, 0, 1, 1)",
21
+ note: "Exit motion (element leaving screen)",
22
+ },
23
+ {
24
+ name: "ease-out",
25
+ value: "cubic-bezier(0, 0, 0.2, 1)",
26
+ note: "Entrance motion (element arriving)",
27
+ },
28
+ {
29
+ name: "ease-in-out",
30
+ value: "cubic-bezier(0.4, 0, 0.2, 1)",
31
+ note: "In-place motion (toggles, transitions)",
32
+ },
33
+ {
34
+ name: "ease-spring",
35
+ value: "cubic-bezier(0.34, 1.56, 0.64, 1)",
36
+ note: "Playful overshoot (drag-drop, success states)",
37
+ },
38
+ ];
39
+
40
+ function DemoBox({
41
+ duration,
42
+ easing,
43
+ trigger,
44
+ }: {
45
+ duration: string;
46
+ easing: string;
47
+ trigger: number;
48
+ }) {
49
+ return (
50
+ <div
51
+ key={trigger}
52
+ className="h-12 w-12 rounded-md bg-primary"
53
+ style={{
54
+ transition: `transform ${duration} ${easing}`,
55
+ transform: trigger % 2 === 0 ? "translateX(0)" : "translateX(180px)",
56
+ }}
57
+ />
58
+ );
59
+ }
60
+
61
+ export const Durations: Story = {
62
+ render: () => {
63
+ const [tick, setTick] = useState(0);
64
+ return (
65
+ <div className="p-8 bg-background">
66
+ <div className="flex items-baseline justify-between mb-6">
67
+ <h3 className="text-sm font-semibold text-muted-foreground">Duration scale</h3>
68
+ <button
69
+ type="button"
70
+ onClick={() => setTick((t) => t + 1)}
71
+ className="text-sm font-medium underline underline-offset-4 hover:text-primary"
72
+ >
73
+ Replay
74
+ </button>
75
+ </div>
76
+ <div className="space-y-6">
77
+ {DURATIONS.map((d) => (
78
+ <div key={d.name} className="flex items-center gap-6">
79
+ <div className="w-32 shrink-0">
80
+ <code className="text-xs font-mono text-foreground">--duration-{d.name}</code>
81
+ <p className="text-xs text-muted-foreground font-mono mt-0.5">{d.value}</p>
82
+ </div>
83
+ <div className="relative h-12 flex-1 max-w-[260px]">
84
+ <DemoBox duration={d.value} easing="cubic-bezier(0, 0, 0.2, 1)" trigger={tick} />
85
+ </div>
86
+ <p className="text-sm text-muted-foreground">{d.note}</p>
87
+ </div>
88
+ ))}
89
+ </div>
90
+ </div>
91
+ );
92
+ },
93
+ };
94
+
95
+ export const Easings: Story = {
96
+ render: () => {
97
+ const [tick, setTick] = useState(0);
98
+ return (
99
+ <div className="p-8 bg-background">
100
+ <div className="flex items-baseline justify-between mb-6">
101
+ <h3 className="text-sm font-semibold text-muted-foreground">Easing curves</h3>
102
+ <button
103
+ type="button"
104
+ onClick={() => setTick((t) => t + 1)}
105
+ className="text-sm font-medium underline underline-offset-4 hover:text-primary"
106
+ >
107
+ Replay
108
+ </button>
109
+ </div>
110
+ <div className="space-y-6">
111
+ {EASINGS.map((e) => (
112
+ <div key={e.name} className="flex items-center gap-6">
113
+ <div className="w-40 shrink-0">
114
+ <code className="text-xs font-mono text-foreground">--{e.name}</code>
115
+ <p className="text-xs text-muted-foreground font-mono mt-0.5 truncate">
116
+ {e.value}
117
+ </p>
118
+ </div>
119
+ <div className="relative h-12 flex-1 max-w-[260px]">
120
+ <DemoBox duration="600ms" easing={e.value} trigger={tick} />
121
+ </div>
122
+ <p className="text-sm text-muted-foreground">{e.note}</p>
123
+ </div>
124
+ ))}
125
+ </div>
126
+ </div>
127
+ );
128
+ },
129
+ };
130
+
131
+ export const ReducedMotion: Story = {
132
+ parameters: {
133
+ docs: {
134
+ description: {
135
+ story:
136
+ "All motion in BADS collapses at the token layer when prefers-reduced-motion is set. Toggle reduced motion in your OS settings to verify — animations should snap to their end state instantly.",
137
+ },
138
+ },
139
+ },
140
+ render: () => {
141
+ const [tick, setTick] = useState(0);
142
+ return (
143
+ <div className="p-8 bg-background">
144
+ <h3 className="text-sm font-semibold text-muted-foreground mb-2">Reduced motion</h3>
145
+ <p className="text-sm text-muted-foreground mb-6 max-w-prose">
146
+ With <code className="text-xs">prefers-reduced-motion: reduce</code>, this should jump
147
+ instantly. Otherwise it animates at <code className="text-xs">--duration-base</code>.
148
+ </p>
149
+ <button
150
+ type="button"
151
+ onClick={() => setTick((t) => t + 1)}
152
+ className="text-sm font-medium underline underline-offset-4 hover:text-primary mb-4"
153
+ >
154
+ Replay
155
+ </button>
156
+ <style>{`
157
+ @media (prefers-reduced-motion: no-preference) {
158
+ .reduced-motion-demo { transition: transform 200ms cubic-bezier(0, 0, 0.2, 1); }
159
+ }
160
+ `}</style>
161
+ <div
162
+ key={tick}
163
+ className="reduced-motion-demo h-12 w-12 rounded-md bg-primary"
164
+ style={{ transform: tick % 2 === 0 ? "translateX(0)" : "translateX(220px)" }}
165
+ />
166
+ </div>
167
+ );
168
+ },
169
+ };
@@ -0,0 +1,36 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+
3
+ const meta: Meta = {
4
+ title: "Foundations/Radius",
5
+ parameters: { layout: "fullscreen" },
6
+ };
7
+ export default meta;
8
+ type Story = StoryObj<typeof meta>;
9
+
10
+ const RADII = [
11
+ { name: "radius-sm", v: "var(--radius-sm)", note: "Tight UI corners (chips, micro inputs)" },
12
+ { name: "radius-md", v: "var(--radius-md)", note: "Most controls (buttons, inputs)" },
13
+ { name: "radius-lg", v: "var(--radius-lg)", note: "Cards, dialogs (also raw --radius)" },
14
+ { name: "radius-xl", v: "var(--radius-xl)", note: "Hero surfaces, marketing panels" },
15
+ ];
16
+
17
+ export const Scale: Story = {
18
+ render: () => (
19
+ <div className="p-8 bg-background">
20
+ <h3 className="text-sm font-semibold text-muted-foreground mb-6">Radius scale</h3>
21
+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-6">
22
+ {RADII.map((r) => (
23
+ <div key={r.name} className="flex flex-col items-center gap-3">
24
+ <div
25
+ className="h-20 w-20 bg-primary"
26
+ style={{ borderRadius: r.v }}
27
+ aria-hidden="true"
28
+ />
29
+ <code className="font-mono text-xs">{r.name}</code>
30
+ <p className="text-xs text-muted-foreground text-center max-w-[14ch]">{r.note}</p>
31
+ </div>
32
+ ))}
33
+ </div>
34
+ </div>
35
+ ),
36
+ };
@@ -0,0 +1,30 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+
3
+ const meta: Meta = {
4
+ title: "Foundations/Shadows",
5
+ parameters: { layout: "fullscreen" },
6
+ };
7
+ export default meta;
8
+ type Story = StoryObj<typeof meta>;
9
+
10
+ const SHADOWS = ["2xs", "xs", "sm", "default", "md", "lg", "xl", "2xl"];
11
+
12
+ export const Scale: Story = {
13
+ render: () => (
14
+ <div className="p-8 bg-background">
15
+ <h3 className="text-sm font-semibold text-muted-foreground mb-6">Shadow scale</h3>
16
+ <div className="grid grid-cols-2 sm:grid-cols-4 gap-8 p-6">
17
+ {SHADOWS.map((s) => (
18
+ <div key={s} className="flex flex-col items-center gap-3">
19
+ <div
20
+ className="h-20 w-20 rounded-md bg-card border border-border"
21
+ style={{ boxShadow: s === "default" ? "var(--shadow)" : `var(--shadow-${s})` }}
22
+ aria-hidden="true"
23
+ />
24
+ <code className="font-mono text-xs">shadow{s === "default" ? "" : `-${s}`}</code>
25
+ </div>
26
+ ))}
27
+ </div>
28
+ </div>
29
+ ),
30
+ };
@@ -0,0 +1,35 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+
3
+ const meta: Meta = {
4
+ title: "Foundations/Spacing",
5
+ parameters: { layout: "fullscreen" },
6
+ };
7
+ export default meta;
8
+ type Story = StoryObj<typeof meta>;
9
+
10
+ const STEPS = [1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24];
11
+
12
+ export const Scale: Story = {
13
+ render: () => (
14
+ <div className="p-8 bg-background">
15
+ <h3 className="text-sm font-semibold text-muted-foreground mb-6">
16
+ Spacing scale (multiplier × <code className="font-mono">--spacing</code>)
17
+ </h3>
18
+ <div className="space-y-3">
19
+ {STEPS.map((step) => (
20
+ <div key={step} className="flex items-center gap-4">
21
+ <code className="font-mono text-xs text-muted-foreground w-12 shrink-0">{step}</code>
22
+ <div
23
+ className="h-4 bg-primary rounded-sm"
24
+ style={{ width: `calc(var(--spacing) * ${step})` }}
25
+ aria-hidden="true"
26
+ />
27
+ <span className="text-xs text-muted-foreground font-mono">
28
+ {(0.25 * step).toFixed(2)}rem default
29
+ </span>
30
+ </div>
31
+ ))}
32
+ </div>
33
+ </div>
34
+ ),
35
+ };
@@ -0,0 +1,68 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+
3
+ const meta: Meta = {
4
+ title: "Foundations/Typography",
5
+ parameters: { layout: "fullscreen" },
6
+ };
7
+ export default meta;
8
+ type Story = StoryObj<typeof meta>;
9
+
10
+ const SCALE = [
11
+ { name: "text-xs", className: "text-xs", note: "Captions, fine print (14px floor)" },
12
+ { name: "text-sm", className: "text-sm", note: "Helper text, labels (16px)" },
13
+ { name: "text-base", className: "text-base", note: "Body (18px)" },
14
+ { name: "text-lg", className: "text-lg", note: "Lead, emphasis (20px)" },
15
+ { name: "text-xl", className: "text-xl", note: "Card titles (24px)" },
16
+ { name: "text-2xl", className: "text-2xl", note: "Section headers (28px)" },
17
+ { name: "text-3xl", className: "text-3xl", note: "Page titles (32px)" },
18
+ ];
19
+
20
+ export const Scale: Story = {
21
+ render: () => (
22
+ <div className="p-8 space-y-6 bg-background text-foreground">
23
+ <h3 className="text-sm font-semibold text-muted-foreground">Type scale</h3>
24
+ <div className="space-y-5">
25
+ {SCALE.map((s) => (
26
+ <div key={s.name} className="flex items-baseline gap-6 border-b border-border pb-4">
27
+ <code className="font-mono text-xs text-muted-foreground w-24 shrink-0">{s.name}</code>
28
+ <div className="flex-1">
29
+ <p className={s.className}>The quick brown fox jumps over the lazy dog</p>
30
+ <p className="text-xs text-muted-foreground mt-1">{s.note}</p>
31
+ </div>
32
+ </div>
33
+ ))}
34
+ </div>
35
+ </div>
36
+ ),
37
+ };
38
+
39
+ export const Families: Story = {
40
+ render: () => (
41
+ <div className="p-8 space-y-8 bg-background text-foreground">
42
+ <h3 className="text-sm font-semibold text-muted-foreground">Font families</h3>
43
+ <div className="space-y-6">
44
+ <div>
45
+ <code className="font-mono text-xs text-muted-foreground">--font-sans</code>
46
+ <p className="text-3xl mt-2" style={{ fontFamily: "var(--font-sans)" }}>
47
+ The quick brown fox jumps over the lazy dog
48
+ </p>
49
+ <p className="text-base mt-2" style={{ fontFamily: "var(--font-sans)" }}>
50
+ Body weight. Aa Bb Cc 0123456789
51
+ </p>
52
+ </div>
53
+ <div>
54
+ <code className="font-mono text-xs text-muted-foreground">--font-serif</code>
55
+ <p className="text-3xl mt-2" style={{ fontFamily: "var(--font-serif)" }}>
56
+ The quick brown fox jumps over the lazy dog
57
+ </p>
58
+ </div>
59
+ <div>
60
+ <code className="font-mono text-xs text-muted-foreground">--font-mono</code>
61
+ <p className="text-3xl mt-2" style={{ fontFamily: "var(--font-mono)" }}>
62
+ The quick brown fox 0123456789
63
+ </p>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ ),
68
+ };
@@ -0,0 +1,120 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { ExternalLink, X, Sparkles } from "lucide-react";
5
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
6
+
7
+ type CheckResult =
8
+ | { ok: true; upstream?: true; skip?: string }
9
+ | { ok: true; upToDate: true; local: string; remote: string }
10
+ | {
11
+ ok: true;
12
+ upToDate: false;
13
+ local: string;
14
+ remote: string;
15
+ behind: number | null;
16
+ remoteMessage: string | null;
17
+ remoteDate: string | null;
18
+ compareUrl: string;
19
+ releasesUrl: string;
20
+ }
21
+ | { ok: true; error: string };
22
+
23
+ const DISMISS_KEY = "BADS.updateDismissedFor";
24
+
25
+ export function BadsUpdateBanner() {
26
+ const [data, setData] = useState<CheckResult | null>(null);
27
+ const [dismissedFor, setDismissedFor] = useState<string | null>(null);
28
+
29
+ useEffect(() => {
30
+ try {
31
+ setDismissedFor(window.localStorage.getItem(DISMISS_KEY));
32
+ } catch {}
33
+ fetch("/api/bads-update-check")
34
+ .then((r) => r.json())
35
+ .then((d) => setData(d))
36
+ .catch(() => setData({ ok: true, error: "fetch-failed" }));
37
+ }, []);
38
+
39
+ if (!data || !data.ok) return null;
40
+ if ("upstream" in data || "error" in data) return null;
41
+ if ("upToDate" in data && data.upToDate) return null;
42
+
43
+ // From here we know it's the "behind" shape.
44
+ const behindData = data as Extract<
45
+ CheckResult,
46
+ { ok: true; upToDate: false }
47
+ >;
48
+
49
+ // Don't re-show after the user dismissed for this exact remote sha. New
50
+ // upstream commit → banner returns.
51
+ if (dismissedFor === behindData.remote) return null;
52
+
53
+ const handleDismiss = () => {
54
+ try {
55
+ window.localStorage.setItem(DISMISS_KEY, behindData.remote);
56
+ } catch {}
57
+ setDismissedFor(behindData.remote);
58
+ };
59
+
60
+ const behindLabel =
61
+ typeof behindData.behind === "number"
62
+ ? `${behindData.behind} commit${behindData.behind === 1 ? "" : "s"} behind`
63
+ : "behind upstream";
64
+
65
+ const dateLabel = behindData.remoteDate
66
+ ? new Date(behindData.remoteDate).toLocaleDateString("en-US", {
67
+ month: "short",
68
+ day: "numeric",
69
+ year: "numeric",
70
+ })
71
+ : null;
72
+
73
+ return (
74
+ <div className="rounded-lg border border-primary/30 bg-primary/5 p-4 flex items-start gap-3">
75
+ <Sparkles className="h-4 w-4 text-primary shrink-0 mt-0.5" strokeWidth={1.5} />
76
+ <div className="flex-1 min-w-0 space-y-1">
77
+ <p className="text-sm font-medium text-foreground">
78
+ BADS update available — {behindLabel}
79
+ </p>
80
+ <p className="text-xs text-muted-foreground">
81
+ {behindData.remoteMessage
82
+ ? `Latest on upstream: "${behindData.remoteMessage}"`
83
+ : "Upstream BADS has new commits since this fork's last sync."}
84
+ {dateLabel && <> &middot; {dateLabel}</>}
85
+ </p>
86
+ <div className="flex items-center gap-2 pt-1">
87
+ <Button size="sm" variant="default" className="gap-1.5" asChild>
88
+ <a href={behindData.releasesUrl} target="_blank" rel="noopener noreferrer">
89
+ See releases
90
+ <ExternalLink className="h-3.5 w-3.5" strokeWidth={1.5} />
91
+ </a>
92
+ </Button>
93
+ <Button size="sm" variant="outline" className="gap-1.5" asChild>
94
+ <a href={behindData.compareUrl} target="_blank" rel="noopener noreferrer">
95
+ View diff
96
+ <ExternalLink className="h-3.5 w-3.5" strokeWidth={1.5} />
97
+ </a>
98
+ </Button>
99
+ <code className="ml-2 font-mono text-xs text-muted-foreground">
100
+ <span className="text-foreground">{behindData.local.slice(0, 7)}</span>
101
+ {" → "}
102
+ <span className="text-primary">{behindData.remote.slice(0, 7)}</span>
103
+ </code>
104
+ </div>
105
+ <p className="text-xs text-muted-foreground pt-1">
106
+ Run <code className="font-mono">pnpm bads:sync</code> in this fork to pull
107
+ updates selectively.
108
+ </p>
109
+ </div>
110
+ <button
111
+ type="button"
112
+ onClick={handleDismiss}
113
+ aria-label="Dismiss this update notice"
114
+ className="shrink-0 text-muted-foreground hover:text-foreground"
115
+ >
116
+ <X className="h-4 w-4" strokeWidth={1.5} />
117
+ </button>
118
+ </div>
119
+ );
120
+ }