@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.
- package/package.json +8 -3
- package/scripts/a11y-lint.cjs +93 -39
- package/scripts/a11y-ratchet.mjs +10 -23
- package/scripts/bads-components.mjs +118 -0
- package/scripts/build-tokens.cjs +175 -17
- package/scripts/check-stories.mjs +1 -1
- package/scripts/health-report.mjs +52 -10
- package/scripts/lib/scan-roots.cjs +143 -0
- package/scripts/lint-component-source.mjs +100 -0
- package/scripts/lint-microanimation.mjs +267 -0
- package/scripts/lint-slop.mjs +21 -28
- package/scripts/lint-token-intent.mjs +10 -16
- package/scripts/size-audit.cjs +94 -27
- package/scripts/source-of-truth.cjs +58 -0
- package/scripts/ux-smoke.mjs +438 -0
- package/scripts/wcag-audit.cjs +49 -1
- package/src/api/layers/file.ts +2 -0
- package/src/app/preview/components/page.tsx +972 -0
- package/src/app/preview/health/page.tsx +8 -5
- package/src/app/preview/history/page.tsx +11 -0
- package/src/app/shell.tsx +261 -87
- package/src/components/customize/brand-mark-section.tsx +4 -2
- package/src/components/customize/design-controls.tsx +1 -1
- package/src/components/customize/discipline-section.tsx +91 -0
- package/src/components/customize/font-pickers.tsx +1 -1
- package/src/components/customize/letter-spacing.tsx +1 -1
- package/src/components/customize/save-bar.tsx +2 -2
- package/src/components/customize/theme-io.tsx +7 -7
- package/src/components/customize/type-scale.tsx +1 -1
- package/src/components/customize-tab.tsx +9 -4
- package/src/components/home-tab.tsx +3 -0
- package/src/components/ui/accordion.tsx +7 -0
- package/src/components/ui/alert.tsx +1 -0
- package/src/components/ui/announcement-bar.tsx +256 -0
- package/src/components/ui/badge.tsx +1 -0
- package/src/components/ui/callout.tsx +218 -0
- package/src/components/ui/chart.tsx +2 -14
- package/src/components/ui/color-picker.tsx +1 -1
- package/src/components/ui/format-relative-time.tsx +139 -0
- package/src/components/ui/grid.tsx +255 -0
- package/src/components/ui/icon.tsx +108 -0
- package/src/components/ui/index.ts +8 -0
- package/src/components/ui/page-header.tsx +63 -0
- package/src/components/ui/portal.tsx +111 -0
- package/src/components/ui/presence.tsx +172 -0
- package/src/components/ui/progress-stack.tsx +258 -0
- package/src/components/ui/select.tsx +89 -4
- package/src/components/ui/separator.tsx +1 -0
- package/src/components/ui/slider.tsx +83 -3
- package/src/components/ui/sparkline.tsx +15 -15
- package/src/components/ui/textarea.tsx +28 -1
- package/src/data/docs-index.ts +5 -0
- package/src/data/history.json +269 -0
- package/src/hooks/use-reduced-motion.ts +6 -0
- package/src/stories/Accordion.stories.tsx +59 -0
- package/src/stories/Alert.stories.tsx +3 -1
- package/src/stories/AnnouncementBar.stories.tsx +261 -0
- package/src/stories/Badge.stories.tsx +3 -0
- package/src/stories/Calendar.stories.tsx +1 -1
- package/src/stories/Callout.stories.tsx +219 -0
- package/src/stories/Chart.stories.tsx +4 -0
- package/src/stories/ColorPicker.stories.tsx +23 -0
- package/src/stories/FormatRelativeTime.stories.tsx +116 -0
- package/src/stories/Grid.stories.tsx +197 -0
- package/src/stories/Icon.stories.tsx +175 -0
- package/src/stories/MultiSelect.stories.tsx +1 -1
- package/src/stories/PageHeader.stories.tsx +102 -0
- package/src/stories/Portal.stories.tsx +189 -0
- package/src/stories/Presence.stories.tsx +228 -0
- package/src/stories/ProgressStack.stories.tsx +287 -0
- package/src/stories/Select.stories.tsx +25 -0
- package/src/stories/Separator.stories.tsx +3 -0
- package/src/stories/Sheet.stories.tsx +9 -3
- package/src/stories/Slider.stories.tsx +54 -5
- package/src/stories/Sparkline.stories.tsx +39 -0
- package/src/stories/Textarea.stories.tsx +18 -0
- package/src/stories/story-groups.json +14 -5
- package/src/styles.css +133 -12
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { AnnouncementBar } from "@behavioral-agentic-design-system/core/components/ui/announcement-bar";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AnnouncementBar is a full-width persistent strip for page-level or
|
|
7
|
+
* site-level messages: maintenance windows, feature launches, free-tier
|
|
8
|
+
* limits, service disruptions, cookie/consent notices.
|
|
9
|
+
*
|
|
10
|
+
* How it differs from the rest of the feedback family:
|
|
11
|
+
* - Alert: inline, role="alert", nested inside content
|
|
12
|
+
* - Notification: persisted feed item, inside an inbox/drawer
|
|
13
|
+
* - Sonner: ephemeral auto-dismissing toast overlay
|
|
14
|
+
* - Callout: editorial annotation inside prose
|
|
15
|
+
* - AnnouncementBar: full-width strip intended to sit ABOVE the main shell.
|
|
16
|
+
* It persists until explicitly dismissed or until the triggering condition
|
|
17
|
+
* clears. It is NOT ephemeral, and it is not inline.
|
|
18
|
+
*
|
|
19
|
+
* Five variants — default / info / success / warning / destructive — share
|
|
20
|
+
* the same intent family as Alert and Notification but with a full-bleed
|
|
21
|
+
* `role="region"` and no action row or inline placement constraints.
|
|
22
|
+
*/
|
|
23
|
+
const meta: Meta<typeof AnnouncementBar> = {
|
|
24
|
+
title: "Components/Feedback/AnnouncementBar",
|
|
25
|
+
component: AnnouncementBar,
|
|
26
|
+
parameters: { layout: "fullscreen" },
|
|
27
|
+
tags: ["autodocs"],
|
|
28
|
+
argTypes: {
|
|
29
|
+
variant: {
|
|
30
|
+
control: "select",
|
|
31
|
+
options: ["default", "info", "success", "warning", "destructive"],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default meta;
|
|
37
|
+
type Story = StoryObj<typeof meta>;
|
|
38
|
+
|
|
39
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
40
|
+
|
|
41
|
+
function DismissWrapper({ children }: { children: (onDismiss: () => void, dismissed: boolean) => React.ReactNode }) {
|
|
42
|
+
const [dismissed, setDismissed] = React.useState(false);
|
|
43
|
+
return (
|
|
44
|
+
<div>
|
|
45
|
+
{children(() => setDismissed(true), dismissed)}
|
|
46
|
+
{dismissed && (
|
|
47
|
+
<div className="flex items-center justify-center py-8 text-sm text-muted-foreground">
|
|
48
|
+
Bar dismissed — refresh to restore
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ─── Stories ──────────────────────────────────────────────────────────────────
|
|
56
|
+
|
|
57
|
+
export const Default: Story = {
|
|
58
|
+
args: {
|
|
59
|
+
variant: "default",
|
|
60
|
+
"aria-label": "Announcement",
|
|
61
|
+
},
|
|
62
|
+
render: (args) => (
|
|
63
|
+
<AnnouncementBar {...args}>
|
|
64
|
+
BADS v2.4 is now available with 12 new components and a refreshed color
|
|
65
|
+
token surface.
|
|
66
|
+
</AnnouncementBar>
|
|
67
|
+
),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Variant_Default: Story = {
|
|
71
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
72
|
+
<AnnouncementBar variant="default">
|
|
73
|
+
BADS v2.4 is now available — the{" "}
|
|
74
|
+
<span className="font-semibold">ProgressStack</span>,{" "}
|
|
75
|
+
<span className="font-semibold">Callout</span>, and{" "}
|
|
76
|
+
<span className="font-semibold">AnnouncementBar</span> primitives ship in
|
|
77
|
+
this release.
|
|
78
|
+
</AnnouncementBar>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const Variant_Info: Story = {
|
|
83
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
84
|
+
<AnnouncementBar variant="info" aria-label="Maintenance notice">
|
|
85
|
+
Scheduled maintenance on Sunday 2026-09-21 from 02:00–04:00 CDT. The
|
|
86
|
+
design token API will be read-only during that window.
|
|
87
|
+
</AnnouncementBar>
|
|
88
|
+
),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const Variant_Success: Story = {
|
|
92
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
93
|
+
<AnnouncementBar variant="success" aria-label="Incident resolved">
|
|
94
|
+
Incident resolved — the BADS npm registry is fully operational. Build
|
|
95
|
+
times are back to baseline.
|
|
96
|
+
</AnnouncementBar>
|
|
97
|
+
),
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export const Variant_Warning: Story = {
|
|
101
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
102
|
+
<AnnouncementBar variant="warning" aria-label="Deprecation notice">
|
|
103
|
+
<span className="font-semibold">Deprecation:</span> The{" "}
|
|
104
|
+
<code className="rounded bg-black/10 px-1 py-px font-mono text-xs dark:bg-white/10">
|
|
105
|
+
impactLevel
|
|
106
|
+
</code>{" "}
|
|
107
|
+
prop on Notification is removed in v3. Migrate to{" "}
|
|
108
|
+
<code className="rounded bg-black/10 px-1 py-px font-mono text-xs dark:bg-white/10">
|
|
109
|
+
variant
|
|
110
|
+
</code>{" "}
|
|
111
|
+
before upgrading.
|
|
112
|
+
</AnnouncementBar>
|
|
113
|
+
),
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const Variant_Destructive: Story = {
|
|
117
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
118
|
+
<AnnouncementBar variant="destructive" aria-label="Active incident">
|
|
119
|
+
Partial outage affecting the Night Shift pipeline — automated component
|
|
120
|
+
builds are paused. Manual PRs are unaffected.
|
|
121
|
+
</AnnouncementBar>
|
|
122
|
+
),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export const AllVariants: Story = {
|
|
126
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
127
|
+
<div className="flex flex-col">
|
|
128
|
+
<AnnouncementBar variant="default">
|
|
129
|
+
BADS v2.4 — ProgressStack, Callout, and AnnouncementBar now available.
|
|
130
|
+
</AnnouncementBar>
|
|
131
|
+
<AnnouncementBar variant="info">
|
|
132
|
+
Scheduled maintenance Sunday 2026-09-21 02:00–04:00 CDT.
|
|
133
|
+
</AnnouncementBar>
|
|
134
|
+
<AnnouncementBar variant="success">
|
|
135
|
+
Incident resolved — build pipeline fully operational.
|
|
136
|
+
</AnnouncementBar>
|
|
137
|
+
<AnnouncementBar variant="warning">
|
|
138
|
+
Deprecation: <code className="font-mono text-xs">impactLevel</code> is
|
|
139
|
+
removed in v3. Migrate to{" "}
|
|
140
|
+
<code className="font-mono text-xs">variant</code>.
|
|
141
|
+
</AnnouncementBar>
|
|
142
|
+
<AnnouncementBar variant="destructive">
|
|
143
|
+
Partial outage — Night Shift component builds paused.
|
|
144
|
+
</AnnouncementBar>
|
|
145
|
+
</div>
|
|
146
|
+
),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const WithAction: Story = {
|
|
150
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
151
|
+
<AnnouncementBar
|
|
152
|
+
variant="default"
|
|
153
|
+
action={
|
|
154
|
+
<a
|
|
155
|
+
href="#changelog"
|
|
156
|
+
className="rounded-sm font-semibold underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-current focus-visible:ring-offset-1"
|
|
157
|
+
>
|
|
158
|
+
View changelog
|
|
159
|
+
</a>
|
|
160
|
+
}
|
|
161
|
+
>
|
|
162
|
+
BADS v2.4 ships 12 new components, including ProgressStack and Callout.
|
|
163
|
+
</AnnouncementBar>
|
|
164
|
+
),
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const Dismissible: Story = {
|
|
168
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
169
|
+
<DismissWrapper>
|
|
170
|
+
{(onDismiss, dismissed) =>
|
|
171
|
+
!dismissed ? (
|
|
172
|
+
<AnnouncementBar
|
|
173
|
+
variant="info"
|
|
174
|
+
aria-label="Free plan limit notice"
|
|
175
|
+
onDismiss={onDismiss}
|
|
176
|
+
>
|
|
177
|
+
You're on the free plan. Fork limit: 3 active engagements.
|
|
178
|
+
</AnnouncementBar>
|
|
179
|
+
) : null
|
|
180
|
+
}
|
|
181
|
+
</DismissWrapper>
|
|
182
|
+
),
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export const DismissibleWithAction: Story = {
|
|
186
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
187
|
+
<DismissWrapper>
|
|
188
|
+
{(onDismiss, dismissed) =>
|
|
189
|
+
!dismissed ? (
|
|
190
|
+
<AnnouncementBar
|
|
191
|
+
variant="warning"
|
|
192
|
+
aria-label="Deprecation warning"
|
|
193
|
+
onDismiss={onDismiss}
|
|
194
|
+
action={
|
|
195
|
+
<a
|
|
196
|
+
href="#migration"
|
|
197
|
+
className="rounded-sm font-semibold underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-current focus-visible:ring-offset-1"
|
|
198
|
+
>
|
|
199
|
+
Migration guide
|
|
200
|
+
</a>
|
|
201
|
+
}
|
|
202
|
+
>
|
|
203
|
+
<span className="font-semibold">Breaking change in v3:</span> The{" "}
|
|
204
|
+
<code className="rounded bg-black/10 px-1 py-px font-mono text-xs dark:bg-white/10">
|
|
205
|
+
size
|
|
206
|
+
</code>{" "}
|
|
207
|
+
prop on Button is renamed to{" "}
|
|
208
|
+
<code className="rounded bg-black/10 px-1 py-px font-mono text-xs dark:bg-white/10">
|
|
209
|
+
buttonSize
|
|
210
|
+
</code>
|
|
211
|
+
.
|
|
212
|
+
</AnnouncementBar>
|
|
213
|
+
) : null
|
|
214
|
+
}
|
|
215
|
+
</DismissWrapper>
|
|
216
|
+
),
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
export const NoIcon: Story = {
|
|
220
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
221
|
+
<AnnouncementBar variant="info" icon={null} aria-label="Feature notice">
|
|
222
|
+
Pass{" "}
|
|
223
|
+
<code className="rounded bg-black/10 px-1 py-px font-mono text-xs dark:bg-white/10">
|
|
224
|
+
icon={"{null}"}
|
|
225
|
+
</code>{" "}
|
|
226
|
+
to suppress the default icon and let the background tint carry the variant
|
|
227
|
+
signal.
|
|
228
|
+
</AnnouncementBar>
|
|
229
|
+
),
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export const RealisticUse: Story = {
|
|
233
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
234
|
+
<div className="min-h-[300px] bg-background">
|
|
235
|
+
{/* The bar sits above the shell */}
|
|
236
|
+
<AnnouncementBar
|
|
237
|
+
variant="default"
|
|
238
|
+
aria-label="Release announcement"
|
|
239
|
+
action={
|
|
240
|
+
<a
|
|
241
|
+
href="#changelog"
|
|
242
|
+
className="rounded-sm font-semibold underline underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-current focus-visible:ring-offset-1"
|
|
243
|
+
>
|
|
244
|
+
What's new →
|
|
245
|
+
</a>
|
|
246
|
+
}
|
|
247
|
+
>
|
|
248
|
+
BADS v2.4 — ProgressStack, Callout & AnnouncementBar are live.
|
|
249
|
+
</AnnouncementBar>
|
|
250
|
+
|
|
251
|
+
{/* Mock shell below the bar */}
|
|
252
|
+
<div className="border-b px-6 py-3 flex items-center gap-3">
|
|
253
|
+
<span className="font-semibold text-sm">BADS</span>
|
|
254
|
+
<span className="text-xs text-muted-foreground">Design System</span>
|
|
255
|
+
</div>
|
|
256
|
+
<div className="px-6 py-8 text-sm text-muted-foreground">
|
|
257
|
+
Main content area — the bar sits above, outside the layout shell.
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
),
|
|
261
|
+
};
|
|
@@ -14,6 +14,9 @@ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badg
|
|
|
14
14
|
* Size ladder (peer parity: Mantine size, MUI Chip size, Chakra size):
|
|
15
15
|
* sm = dense inline labels, default = unchanged, lg = prominent surfaces.
|
|
16
16
|
* BADS text-xs = 14px and text-sm = 16px — both meet the AAA 14px floor.
|
|
17
|
+
*
|
|
18
|
+
* Status variant borders are `!`-forced (see the recipe-note in badge.tsx)
|
|
19
|
+
* — an override needs the same importance, e.g. `border-transparent!`.
|
|
17
20
|
*/
|
|
18
21
|
const meta: Meta<typeof Badge> = {
|
|
19
22
|
title: "Components/Badges and avatars/Badge",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Note: calendar day cells use the shadcn default font-normal weight (see the
|
|
2
2
|
// `allow-font-normal-small` escape hatch in calendar.tsx). A font-medium bump to
|
|
3
|
-
// satisfy the
|
|
3
|
+
// satisfy the BADS-WEIGHT floor is a deferred design decision on this shared
|
|
4
4
|
// primitive, not a mechanical fix.
|
|
5
5
|
//
|
|
6
6
|
// react-day-picker v10: the grid element's classNames key is `month_grid`
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { SparklesIcon } from "lucide-react";
|
|
3
|
+
import { Callout } from "@behavioral-agentic-design-system/core/components/ui/callout";
|
|
4
|
+
import { Code } from "@behavioral-agentic-design-system/core/components/ui/code";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Callout is the documentation/editorial aside that highlights contextual
|
|
8
|
+
* information inside prose — not system feedback.
|
|
9
|
+
*
|
|
10
|
+
* Use it for the note-about-a-gotcha, the tip-about-a-shortcut, the
|
|
11
|
+
* warning-before-a-destructive-migration. Five variants (note / tip /
|
|
12
|
+
* warning / danger / info) share the same intent family as Alert and
|
|
13
|
+
* Notification but with an `<aside>` semantic and no dismiss or action row.
|
|
14
|
+
*
|
|
15
|
+
* Body content is a rich slot — headings, lists, inline code, and multiple
|
|
16
|
+
* paragraphs all render correctly inside the body.
|
|
17
|
+
*/
|
|
18
|
+
const meta: Meta<typeof Callout> = {
|
|
19
|
+
title: "Components/Feedback/Callout",
|
|
20
|
+
component: Callout,
|
|
21
|
+
parameters: { layout: "centered" },
|
|
22
|
+
tags: ["autodocs"],
|
|
23
|
+
argTypes: {
|
|
24
|
+
variant: {
|
|
25
|
+
control: "select",
|
|
26
|
+
options: ["note", "tip", "warning", "danger", "info"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default meta;
|
|
32
|
+
type Story = StoryObj<typeof meta>;
|
|
33
|
+
|
|
34
|
+
// ─── Stories ──────────────────────────────────────────────────────────────────
|
|
35
|
+
|
|
36
|
+
export const Default: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
variant: "note",
|
|
39
|
+
title: "Note",
|
|
40
|
+
},
|
|
41
|
+
render: (args) => (
|
|
42
|
+
<div className="w-[480px]">
|
|
43
|
+
<Callout {...args}>
|
|
44
|
+
The component registry is the single source of truth. Never hardcode
|
|
45
|
+
values that live in <Code>tokens.json</Code> — changes propagate via{" "}
|
|
46
|
+
<Code>pnpm build:tokens</Code>.
|
|
47
|
+
</Callout>
|
|
48
|
+
</div>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Variant_Note: Story = {
|
|
53
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
54
|
+
<div className="w-[480px]">
|
|
55
|
+
<Callout variant="note" title="Note">
|
|
56
|
+
Run <Code>pnpm wcag:audit</Code> before any PR that touches color
|
|
57
|
+
tokens to catch contrast regressions against the AAA floor.
|
|
58
|
+
</Callout>
|
|
59
|
+
</div>
|
|
60
|
+
),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const Variant_Tip: Story = {
|
|
64
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
65
|
+
<div className="w-[480px]">
|
|
66
|
+
<Callout variant="tip" title="Tip">
|
|
67
|
+
Set <Code>forceMount</Code> on inactive <Code>TabsContent</Code> panels
|
|
68
|
+
and wrap them in <Code>TabsPanels</Code> to avoid iframe cold-load on
|
|
69
|
+
every tab switch.
|
|
70
|
+
</Callout>
|
|
71
|
+
</div>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const Variant_Warning: Story = {
|
|
76
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
77
|
+
<div className="w-[480px]">
|
|
78
|
+
<Callout variant="warning" title="Warning">
|
|
79
|
+
The <Code>duration-fast</Code> and <Code>duration-base</Code> Tailwind
|
|
80
|
+
utilities compile to nothing in v4 — use inline{" "}
|
|
81
|
+
<Code>{`style={{ transitionDuration: "var(--duration-fast)" }}`}</Code>{" "}
|
|
82
|
+
instead.
|
|
83
|
+
</Callout>
|
|
84
|
+
</div>
|
|
85
|
+
),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export const Variant_Danger: Story = {
|
|
89
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
90
|
+
<div className="w-[480px]">
|
|
91
|
+
<Callout variant="danger" title="Breaking change in v3">
|
|
92
|
+
The <Code>size</Code> prop on Button was renamed to{" "}
|
|
93
|
+
<Code>buttonSize</Code>. Update every call site before upgrading.
|
|
94
|
+
</Callout>
|
|
95
|
+
</div>
|
|
96
|
+
),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const Variant_Info: Story = {
|
|
100
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
101
|
+
<div className="w-[480px]">
|
|
102
|
+
<Callout variant="info" title="WCAG 3.0 status">
|
|
103
|
+
The March 2026 Working Draft renamed "outcomes" to "requirements". No
|
|
104
|
+
conformance action is required until the Candidate Recommendation
|
|
105
|
+
(expected Q4 2027). BADS's current AAA floor maps cleanly to the
|
|
106
|
+
Gold tier.
|
|
107
|
+
</Callout>
|
|
108
|
+
</div>
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export const AllVariants: Story = {
|
|
113
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
114
|
+
<div className="flex w-[480px] flex-col gap-4">
|
|
115
|
+
<Callout variant="note" title="Note">
|
|
116
|
+
General information or contextual aside.
|
|
117
|
+
</Callout>
|
|
118
|
+
<Callout variant="tip" title="Tip">
|
|
119
|
+
A helpful shortcut or recommended practice.
|
|
120
|
+
</Callout>
|
|
121
|
+
<Callout variant="warning" title="Warning">
|
|
122
|
+
Caution: a risk or potential issue to be aware of.
|
|
123
|
+
</Callout>
|
|
124
|
+
<Callout variant="danger" title="Danger">
|
|
125
|
+
Stop: this path leads to data loss or a breaking change.
|
|
126
|
+
</Callout>
|
|
127
|
+
<Callout variant="info" title="Info">
|
|
128
|
+
Neutral reference that is neither an error nor a tip.
|
|
129
|
+
</Callout>
|
|
130
|
+
</div>
|
|
131
|
+
),
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const NoTitle: Story = {
|
|
135
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
136
|
+
<div className="flex w-[480px] flex-col gap-4">
|
|
137
|
+
<Callout variant="note">
|
|
138
|
+
Icon alone signals the variant when the title is omitted.
|
|
139
|
+
</Callout>
|
|
140
|
+
<Callout variant="warning">
|
|
141
|
+
Passing a custom icon? Set <Code>strokeWidth={"{1.5}"}</Code> to stay
|
|
142
|
+
on-system.
|
|
143
|
+
</Callout>
|
|
144
|
+
</div>
|
|
145
|
+
),
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
export const NoIcon: Story = {
|
|
149
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
150
|
+
<div className="w-[480px]">
|
|
151
|
+
<Callout variant="tip" icon={null} title="Styling tip">
|
|
152
|
+
Pass <Code>icon={"{null}"}</Code> to suppress the default icon and let
|
|
153
|
+
the title and background tint carry the variant signal.
|
|
154
|
+
</Callout>
|
|
155
|
+
</div>
|
|
156
|
+
),
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const CustomIcon: Story = {
|
|
160
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
161
|
+
<div className="w-[480px]">
|
|
162
|
+
<Callout
|
|
163
|
+
variant="tip"
|
|
164
|
+
icon={<SparklesIcon strokeWidth={1.5} aria-hidden />}
|
|
165
|
+
title="Night Shift"
|
|
166
|
+
>
|
|
167
|
+
Night Shift runs daily at 06:00 CDT, audits the full system, and opens
|
|
168
|
+
draft PRs for low-risk mechanical fixes. See{" "}
|
|
169
|
+
<Code>CIRCADIAN.md</Code> for the full spec.
|
|
170
|
+
</Callout>
|
|
171
|
+
</div>
|
|
172
|
+
),
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const RichContent: Story = {
|
|
176
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
177
|
+
<div className="w-[480px]">
|
|
178
|
+
<Callout variant="danger" title="Microanimation patterns to avoid">
|
|
179
|
+
<p>These patterns compile to nothing in Tailwind v4 and produce silent failures:</p>
|
|
180
|
+
<ul className="mt-2 list-disc pl-4 space-y-1 text-muted-foreground">
|
|
181
|
+
<li><Code>duration-fast</Code>, <Code>duration-base</Code>, <Code>duration-slow</Code></li>
|
|
182
|
+
<li><Code>duration-[var(--duration-fast)]</Code> (arbitrary-value form)</li>
|
|
183
|
+
<li>Inline <Code>transitionDuration: "200ms"</Code> (literal value bypasses tokens)</li>
|
|
184
|
+
</ul>
|
|
185
|
+
<p className="mt-2">
|
|
186
|
+
Use inline <Code>{`style={{ transitionDuration: "var(--duration-fast)" }}`}</Code>{" "}
|
|
187
|
+
instead.
|
|
188
|
+
</p>
|
|
189
|
+
</Callout>
|
|
190
|
+
</div>
|
|
191
|
+
),
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export const RealisticUse: Story = {
|
|
195
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
196
|
+
<div className="w-[560px] flex flex-col gap-5">
|
|
197
|
+
<h2 className="text-lg font-semibold">Rename a client fork</h2>
|
|
198
|
+
<p className="text-sm text-muted-foreground">
|
|
199
|
+
A fork is unrenamed if <Code>.client-identity.json</Code> does not
|
|
200
|
+
exist and <Code>brand.config.ts</Code> still reads{" "}
|
|
201
|
+
<Code>name: "BADS"</Code>.
|
|
202
|
+
</p>
|
|
203
|
+
<Callout variant="tip" title="Fast path">
|
|
204
|
+
Run <Code>pnpm rename "Clap Design" clap</Code> — the script
|
|
205
|
+
updates every reference in a single pass, then commit with{" "}
|
|
206
|
+
<Code>git add -A && git commit -m "chore: rename to Clap Design"</Code>.
|
|
207
|
+
</Callout>
|
|
208
|
+
<Callout variant="warning" title="After renaming">
|
|
209
|
+
Re-run <Code>pnpm install && pnpm build:tokens</Code> so the generated
|
|
210
|
+
CSS carries the new package namespace. Skipping this causes a silent
|
|
211
|
+
FOUC on first load.
|
|
212
|
+
</Callout>
|
|
213
|
+
<Callout variant="danger">
|
|
214
|
+
Never run <Code>pnpm rename</Code> on an already-renamed repo — it will
|
|
215
|
+
do nothing harmful but wastes time and produces a confusing diff.
|
|
216
|
+
</Callout>
|
|
217
|
+
</div>
|
|
218
|
+
),
|
|
219
|
+
};
|
|
@@ -145,6 +145,10 @@ export const Variant_WithReferenceDot: Story = {
|
|
|
145
145
|
),
|
|
146
146
|
};
|
|
147
147
|
|
|
148
|
+
// `animate={false}` freezes the chart at its final frame on demand. It is the
|
|
149
|
+
// same output reduced-motion users get automatically: ChartContainer reads the
|
|
150
|
+
// shared `useReducedMotion` hook (hooks/use-reduced-motion) and drops the
|
|
151
|
+
// entrance for them regardless of this prop.
|
|
148
152
|
export const Variant_NoAnimation: Story = {
|
|
149
153
|
render: () => (
|
|
150
154
|
<ChartContainer config={twoSeriesConfig} className="h-56 w-[520px]" animate={false}>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { userEvent, within, expect } from "storybook/test";
|
|
3
4
|
import { ColorPicker } from "@behavioral-agentic-design-system/core/components/ui/color-picker";
|
|
4
5
|
import { Card, CardContent, CardHeader, CardTitle } from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
5
6
|
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
|
|
@@ -77,6 +78,28 @@ export const AddViaWheel: Story = {
|
|
|
77
78
|
</div>
|
|
78
79
|
);
|
|
79
80
|
},
|
|
81
|
+
// "Add color" is the wheel popover's committing action and it is full-width,
|
|
82
|
+
// which is the shape BADS-2b flags: a w-full Button is the primary action of
|
|
83
|
+
// its container, and at the default size that is a 36px target under SC
|
|
84
|
+
// 2.5.5's 44px floor. The class fix is invisible until something renders it,
|
|
85
|
+
// so measure the rendered height rather than trusting the className.
|
|
86
|
+
// Two traps here, both worth keeping in the comment because both cost a
|
|
87
|
+
// round to find:
|
|
88
|
+
//
|
|
89
|
+
// 1. The wheel opens in a Radix portal at <body>, OUTSIDE canvasElement, so
|
|
90
|
+
// the query has to run against the document.
|
|
91
|
+
// 2. Assert the COMPUTED min-height, not getBoundingClientRect(). The popover
|
|
92
|
+
// enters with zoom-in-95, so the rect reads the animated box: 41.8px on
|
|
93
|
+
// one run and 43.4px on the next, against a design value of 44. That is
|
|
94
|
+
// corrections #023's "a reading taken mid-animation is not a design value"
|
|
95
|
+
// in miniature, and a gate that reports a different number each run
|
|
96
|
+
// teaches people to re-run it until it is green.
|
|
97
|
+
play: async ({ canvasElement }) => {
|
|
98
|
+
const canvas = within(canvasElement);
|
|
99
|
+
await userEvent.click(canvas.getByRole("button", { name: /add a custom color/i }));
|
|
100
|
+
const add = await within(document.body).findByRole("button", { name: /^add color$/i });
|
|
101
|
+
await expect(parseFloat(getComputedStyle(add).minHeight)).toBeGreaterThanOrEqual(44);
|
|
102
|
+
},
|
|
80
103
|
};
|
|
81
104
|
|
|
82
105
|
export const AddOnlyWheel: Story = {
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import { FormatRelativeTime } from "@behavioral-agentic-design-system/core/components/ui/format-relative-time"
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof FormatRelativeTime> = {
|
|
5
|
+
title: "Components/Content and data/FormatRelativeTime",
|
|
6
|
+
component: FormatRelativeTime,
|
|
7
|
+
parameters: {
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component:
|
|
11
|
+
"Locale-aware relative-time display primitive. Renders a `<time>` element with a machine-readable dateTime attribute. Optionally live-updates every 30 s.",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default meta
|
|
19
|
+
type Story = StoryObj<typeof FormatRelativeTime>
|
|
20
|
+
|
|
21
|
+
// Two minutes ago
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
args: {
|
|
24
|
+
date: new Date(Date.now() - 2 * 60_000),
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Future date
|
|
29
|
+
export const Future: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
date: new Date(Date.now() + 4 * 60 * 60_000),
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Yesterday
|
|
36
|
+
export const Yesterday: Story = {
|
|
37
|
+
args: {
|
|
38
|
+
date: new Date(Date.now() - 25 * 60 * 60_000),
|
|
39
|
+
numeric: "auto",
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Two weeks ago — days unit
|
|
44
|
+
export const TwoWeeksAgo: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
date: new Date(Date.now() - 14 * 24 * 60 * 60_000),
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Long time ago — years unit
|
|
51
|
+
export const ThreeYearsAgo: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
date: new Date(Date.now() - 3 * 365 * 24 * 60 * 60_000),
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Static (no live update) — for use in SSR/static contexts
|
|
58
|
+
export const Static: Story = {
|
|
59
|
+
args: {
|
|
60
|
+
date: new Date(Date.now() - 45_000),
|
|
61
|
+
live: false,
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Narrow style — compact label ("2 min. ago")
|
|
66
|
+
export const Narrow: Story = {
|
|
67
|
+
args: {
|
|
68
|
+
date: new Date(Date.now() - 7 * 60_000),
|
|
69
|
+
formatStyle: "narrow",
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Numeric forced — always uses numbers even for "yesterday"
|
|
74
|
+
export const AlwaysNumeric: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
date: new Date(Date.now() - 25 * 60 * 60_000),
|
|
77
|
+
numeric: "always",
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Realistic use: activity feed row
|
|
82
|
+
export const RealisticUse: Story = {
|
|
83
|
+
parameters: { controls: { disable: true } },
|
|
84
|
+
render: () => (
|
|
85
|
+
<ul className="flex flex-col gap-2 text-sm">
|
|
86
|
+
{[
|
|
87
|
+
{ user: "Jordan Reeves", action: "approved the PR", ago: 3 * 60_000 },
|
|
88
|
+
{
|
|
89
|
+
user: "Seo-yun Park",
|
|
90
|
+
action: "left a comment",
|
|
91
|
+
ago: 42 * 60_000,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
user: "Marcus Lindqvist",
|
|
95
|
+
action: "opened a pull request",
|
|
96
|
+
ago: 4 * 60 * 60_000,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
user: "Anika Patel",
|
|
100
|
+
action: "pushed 3 commits",
|
|
101
|
+
ago: 2 * 24 * 60 * 60_000,
|
|
102
|
+
},
|
|
103
|
+
].map(({ user, action, ago }) => (
|
|
104
|
+
<li key={user} className="flex items-center justify-between gap-4">
|
|
105
|
+
<span>
|
|
106
|
+
<span className="font-medium">{user}</span> {action}
|
|
107
|
+
</span>
|
|
108
|
+
<FormatRelativeTime
|
|
109
|
+
date={new Date(Date.now() - ago)}
|
|
110
|
+
className="text-muted-foreground tabular-nums shrink-0"
|
|
111
|
+
/>
|
|
112
|
+
</li>
|
|
113
|
+
))}
|
|
114
|
+
</ul>
|
|
115
|
+
),
|
|
116
|
+
}
|