@behavioral-agentic-design-system/core 0.39.1 → 0.42.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/README.md +2 -0
- package/package.json +26 -5
- package/scripts/a11y-lint.cjs +88 -8
- package/scripts/bads-components.mjs +118 -0
- package/scripts/build-tokens.cjs +133 -12
- package/scripts/check-stories.mjs +1 -1
- package/scripts/health-report.mjs +16 -2
- package/scripts/lint-component-source.mjs +100 -0
- package/scripts/lint-microanimation.mjs +267 -0
- package/scripts/lint-slop.mjs +25 -1
- package/scripts/size-audit.cjs +79 -0
- package/scripts/source-of-truth.cjs +58 -0
- package/scripts/ux-smoke.mjs +438 -0
- package/scripts/wcag-audit.cjs +121 -6
- package/src/api/layers/file.ts +1 -0
- package/src/app/opengraph-image.tsx +5 -0
- package/src/app/preview/components/page.tsx +2237 -2
- package/src/app/shell.tsx +17 -16
- package/src/components/Foundations/Motion.stories.tsx +1 -0
- package/src/components/customize/brand-mark-section.tsx +4 -2
- package/src/components/customize/design-controls.tsx +17 -2
- package/src/components/customize/discipline-section.tsx +3 -6
- 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 +7 -4
- package/src/components/home-tab.tsx +3 -0
- package/src/components/studio/studio.tsx +153 -0
- package/src/components/ui/accordion.tsx +7 -0
- package/src/components/ui/alert.tsx +1 -0
- package/src/components/ui/anchor.tsx +37 -3
- package/src/components/ui/announcement-bar.tsx +256 -0
- package/src/components/ui/attachment.tsx +211 -0
- package/src/components/ui/badge.tsx +1 -0
- package/src/components/ui/callout.tsx +218 -0
- package/src/components/ui/chart.tsx +5 -14
- package/src/components/ui/code.tsx +1 -1
- package/src/components/ui/color-picker.tsx +2 -2
- package/src/components/ui/format-relative-time.tsx +139 -0
- package/src/components/ui/gauge-chart.tsx +238 -0
- package/src/components/ui/grid.tsx +255 -0
- package/src/components/ui/heatmap.tsx +256 -0
- package/src/components/ui/icon.tsx +108 -0
- package/src/components/ui/index.ts +17 -0
- package/src/components/ui/infinite-scroll.tsx +103 -0
- package/src/components/ui/json-input.tsx +351 -0
- package/src/components/ui/navigation-progress.tsx +281 -0
- package/src/components/ui/number-input.tsx +1 -4
- package/src/components/ui/page-header.tsx +63 -0
- package/src/components/ui/password-input.tsx +2 -1
- package/src/components/ui/password-strength-input.tsx +288 -0
- package/src/components/ui/pill.tsx +140 -0
- package/src/components/ui/popover.tsx +27 -4
- 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/scroll-progress.tsx +100 -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/snackbar.tsx +393 -0
- package/src/components/ui/sortable-list.tsx +342 -0
- package/src/components/ui/sparkline.tsx +2 -14
- package/src/components/ui/squircle.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/textarea.tsx +28 -1
- package/src/components/ui/tour.tsx +1 -3
- package/src/data/docs-index.ts +25 -0
- package/src/hooks/use-reduced-motion.ts +6 -0
- package/src/lib/clamp.ts +2 -0
- package/src/stories/Accordion.stories.tsx +59 -0
- package/src/stories/Alert.stories.tsx +3 -1
- package/src/stories/Anchor.stories.tsx +54 -0
- package/src/stories/AnnouncementBar.stories.tsx +261 -0
- package/src/stories/Attachment.stories.tsx +189 -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 +8 -0
- package/src/stories/Code.stories.tsx +1 -0
- package/src/stories/ColorPicker.stories.tsx +24 -0
- package/src/stories/FormatRelativeTime.stories.tsx +116 -0
- package/src/stories/GaugeChart.stories.tsx +163 -0
- package/src/stories/Grid.stories.tsx +197 -0
- package/src/stories/Heatmap.stories.tsx +172 -0
- package/src/stories/Icon.stories.tsx +175 -0
- package/src/stories/InfiniteScroll.stories.tsx +225 -0
- package/src/stories/JsonInput.stories.tsx +212 -0
- package/src/stories/MultiSelect.stories.tsx +1 -1
- package/src/stories/NavigationProgress.stories.tsx +159 -0
- package/src/stories/NumberInput.stories.tsx +1 -0
- package/src/stories/PageHeader.stories.tsx +102 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
- package/src/stories/Pill.stories.tsx +201 -0
- package/src/stories/Popover.stories.tsx +29 -1
- package/src/stories/Portal.stories.tsx +191 -0
- package/src/stories/Presence.stories.tsx +228 -0
- package/src/stories/ProgressStack.stories.tsx +287 -0
- package/src/stories/ScrollProgress.stories.tsx +117 -0
- package/src/stories/Select.stories.tsx +25 -0
- package/src/stories/Separator.stories.tsx +3 -0
- package/src/stories/Slider.stories.tsx +54 -5
- package/src/stories/Snackbar.stories.tsx +315 -0
- package/src/stories/SortableList.stories.tsx +263 -0
- package/src/stories/Sparkline.stories.tsx +3 -0
- package/src/stories/Squircle.stories.tsx +1 -0
- package/src/stories/Table.stories.tsx +1 -0
- package/src/stories/Textarea.stories.tsx +18 -0
- package/src/stories/Tour.stories.tsx +1 -0
- package/src/stories/story-groups.json +26 -6
- package/src/styles.css +133 -12
- package/LICENSE +0 -21
|
@@ -179,6 +179,60 @@ export const Customized: Story = {
|
|
|
179
179
|
),
|
|
180
180
|
};
|
|
181
181
|
|
|
182
|
+
export const Controlled: Story = {
|
|
183
|
+
render: function ControlledStory() {
|
|
184
|
+
const [activeId, setActiveId] = React.useState<string | null>(
|
|
185
|
+
"anc-ctrl-tokens"
|
|
186
|
+
);
|
|
187
|
+
const items = [
|
|
188
|
+
{ id: "anc-ctrl-tokens", label: "Token audit" },
|
|
189
|
+
{ id: "anc-ctrl-stories", label: "Story coverage" },
|
|
190
|
+
{ id: "anc-ctrl-size", label: "CTA size contract" },
|
|
191
|
+
{ id: "anc-ctrl-slop", label: "Slop lint" },
|
|
192
|
+
];
|
|
193
|
+
const activeLabel =
|
|
194
|
+
items.find((item) => item.id === activeId)?.label ?? "none";
|
|
195
|
+
return (
|
|
196
|
+
<div className="w-[640px] max-w-full space-y-4">
|
|
197
|
+
<p className="text-sm text-muted-foreground">
|
|
198
|
+
Controlled: the highlight is whatever the consumer passes as{" "}
|
|
199
|
+
<code className="font-mono">activeId</code>. The scroll-spy keeps
|
|
200
|
+
reporting through <code className="font-mono">onActiveChange</code>,
|
|
201
|
+
and here it is mirrored straight back — the same wiring a docs site
|
|
202
|
+
uses to keep the URL hash and the nav in step. Currently reading:{" "}
|
|
203
|
+
<span className="font-medium text-foreground">{activeLabel}</span>.
|
|
204
|
+
</p>
|
|
205
|
+
<div className="flex gap-8">
|
|
206
|
+
<div className="h-72 min-w-0 flex-1 overflow-y-auto rounded-lg border border-border p-5" tabIndex={0}>
|
|
207
|
+
<DemoSection id="anc-ctrl-tokens" title="Token audit">
|
|
208
|
+
pnpm wcag:audit walks every shipped token pair and fails CI on
|
|
209
|
+
any text pair under 7:1 or non-text pair under 3:1.
|
|
210
|
+
</DemoSection>
|
|
211
|
+
<DemoSection id="anc-ctrl-stories" title="Story coverage">
|
|
212
|
+
A component file edited without its story in the same commit is
|
|
213
|
+
blocked at pre-commit; pnpm fix:stories seeds the baseline.
|
|
214
|
+
</DemoSection>
|
|
215
|
+
<DemoSection id="anc-ctrl-size" title="CTA size contract">
|
|
216
|
+
Every flow-changing control reads at text-sm, font-medium,
|
|
217
|
+
min-h-11. pnpm size-audit flags anything smaller.
|
|
218
|
+
</DemoSection>
|
|
219
|
+
<DemoSection id="anc-ctrl-slop" title="Slop lint">
|
|
220
|
+
Six code-detectable AI tics — gradient text, indigo gradients,
|
|
221
|
+
hover scale pops, 40px glows, decorative emoji, invented stats.
|
|
222
|
+
</DemoSection>
|
|
223
|
+
</div>
|
|
224
|
+
<Anchor
|
|
225
|
+
className="w-44 shrink-0 self-start"
|
|
226
|
+
activeId={activeId}
|
|
227
|
+
onActiveChange={setActiveId}
|
|
228
|
+
items={items}
|
|
229
|
+
/>
|
|
230
|
+
</div>
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
},
|
|
234
|
+
};
|
|
235
|
+
|
|
182
236
|
export const RealisticUse: Story = {
|
|
183
237
|
render: () => (
|
|
184
238
|
<div className="w-[720px] max-w-full rounded-lg border border-border bg-card p-6">
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// Motion: the remove control is a CloseButton, so hover/focus/press inherit
|
|
2
|
+
// Button's token-driven transition-colors; the chip itself has no entrance
|
|
3
|
+
// or exit animation (removal is an undo — it should be instant).
|
|
4
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
5
|
+
import * as React from "react"
|
|
6
|
+
import { Paperclip, SendHorizontal } from "lucide-react"
|
|
7
|
+
|
|
8
|
+
import { Attachment } from "@behavioral-agentic-design-system/core/components/ui/attachment"
|
|
9
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
10
|
+
import { Card } from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
11
|
+
import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea"
|
|
12
|
+
|
|
13
|
+
// File names and byte counts from content/personas/bads.json → files[].
|
|
14
|
+
const FILES = {
|
|
15
|
+
roiReport: { name: "roi-report-2026-06.pdf", bytes: 1_536_000, type: "application/pdf" },
|
|
16
|
+
favicon: { name: "favicon.svg", bytes: 500, type: "image/svg+xml" },
|
|
17
|
+
styles: { name: "styles.css", bytes: 42_700, type: "text/css" },
|
|
18
|
+
brandFonts: { name: "brand-fonts.woff2", bytes: 84_512, type: "font/woff2" },
|
|
19
|
+
figProposal: { name: "tokens-v2-proposal.fig", bytes: 24_618_034, type: "" },
|
|
20
|
+
snapshots: {
|
|
21
|
+
name: "chromatic-snapshots-2026-06.zip",
|
|
22
|
+
bytes: 1_073_741_824,
|
|
23
|
+
type: "application/zip",
|
|
24
|
+
},
|
|
25
|
+
} as const
|
|
26
|
+
|
|
27
|
+
const meta: Meta<typeof Attachment> = {
|
|
28
|
+
title: "Components/Badges and avatars/Attachment",
|
|
29
|
+
component: Attachment,
|
|
30
|
+
tags: ["autodocs"],
|
|
31
|
+
parameters: {
|
|
32
|
+
layout: "centered",
|
|
33
|
+
docs: {
|
|
34
|
+
description: {
|
|
35
|
+
component:
|
|
36
|
+
"Pre-send file chip for a chat composer: file-type icon (picked from the MIME type, falling back to the extension), truncated name with the full value on title, formatted size via FormatByte, and a 44px CloseButton remove control labeled 'Remove <name>'. The root is role='group' with aria-label 'Attached file: <name>'. Omit onRemove for a read-only chip. Not a drop zone (FileUpload) and not a post-send card (FileCard).",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
args: {
|
|
41
|
+
onRemove: () => {},
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default meta
|
|
46
|
+
type Story = StoryObj<typeof Attachment>
|
|
47
|
+
|
|
48
|
+
export const Default: Story = {
|
|
49
|
+
args: {
|
|
50
|
+
fileName: FILES.roiReport.name,
|
|
51
|
+
fileSize: FILES.roiReport.bytes,
|
|
52
|
+
fileType: FILES.roiReport.type,
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const ImageAttachment: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
fileName: FILES.favicon.name,
|
|
59
|
+
fileSize: FILES.favicon.bytes,
|
|
60
|
+
fileType: FILES.favicon.type,
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const CodeAttachment: Story = {
|
|
65
|
+
args: {
|
|
66
|
+
fileName: FILES.styles.name,
|
|
67
|
+
fileSize: FILES.styles.bytes,
|
|
68
|
+
fileType: FILES.styles.type,
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** A long archive name truncates; the full name stays on title and in the group label. */
|
|
73
|
+
export const LargeFile: Story = {
|
|
74
|
+
args: {
|
|
75
|
+
fileName: FILES.snapshots.name,
|
|
76
|
+
fileSize: FILES.snapshots.bytes,
|
|
77
|
+
fileType: FILES.snapshots.type,
|
|
78
|
+
},
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Unknown MIME type (the browser reports "" for .fig) — the extension fallback picks the generic icon. */
|
|
82
|
+
export const UnknownType: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
fileName: FILES.figProposal.name,
|
|
85
|
+
fileSize: FILES.figProposal.bytes,
|
|
86
|
+
fileType: FILES.figProposal.type,
|
|
87
|
+
},
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** No onRemove → the remove button is not rendered; the chip is read-only. */
|
|
91
|
+
export const ReadOnly: Story = {
|
|
92
|
+
args: {
|
|
93
|
+
fileName: FILES.brandFonts.name,
|
|
94
|
+
fileSize: FILES.brandFonts.bytes,
|
|
95
|
+
fileType: FILES.brandFonts.type,
|
|
96
|
+
onRemove: undefined,
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Dimmed, remove control disabled — the state while the message is sending. */
|
|
101
|
+
export const Disabled: Story = {
|
|
102
|
+
args: {
|
|
103
|
+
fileName: FILES.roiReport.name,
|
|
104
|
+
fileSize: FILES.roiReport.bytes,
|
|
105
|
+
fileType: FILES.roiReport.type,
|
|
106
|
+
disabled: true,
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function ComposerDemo() {
|
|
111
|
+
const [attached, setAttached] = React.useState<
|
|
112
|
+
Array<{ name: string; bytes: number; type: string }>
|
|
113
|
+
>([FILES.roiReport, FILES.styles, FILES.snapshots])
|
|
114
|
+
const [sending, setSending] = React.useState(false)
|
|
115
|
+
// Removing a chip unmounts the focused button; send focus back to the
|
|
116
|
+
// composer so a keyboard user is not dropped on <body>. The component
|
|
117
|
+
// leaves this to the consumer on purpose — only the composer knows where
|
|
118
|
+
// "back" is.
|
|
119
|
+
const composerRef = React.useRef<HTMLTextAreaElement>(null)
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<Card className="w-[28rem] max-w-full gap-0 p-3">
|
|
123
|
+
<Textarea
|
|
124
|
+
ref={composerRef}
|
|
125
|
+
aria-label="Message to Jordan Reeves"
|
|
126
|
+
placeholder="Message Jordan Reeves"
|
|
127
|
+
defaultValue="Here's the June ROI export, the generated stylesheet, and last quarter's Chromatic baseline."
|
|
128
|
+
className="min-h-20 resize-none border-0 bg-transparent px-1 shadow-none focus-visible:ring-0"
|
|
129
|
+
/>
|
|
130
|
+
{attached.length > 0 && (
|
|
131
|
+
<div className="mt-2 flex flex-wrap gap-2 px-1" aria-label="Attachments">
|
|
132
|
+
{attached.map((f) => (
|
|
133
|
+
<Attachment
|
|
134
|
+
key={f.name}
|
|
135
|
+
fileName={f.name}
|
|
136
|
+
fileSize={f.bytes}
|
|
137
|
+
fileType={f.type}
|
|
138
|
+
disabled={sending}
|
|
139
|
+
onRemove={() => {
|
|
140
|
+
setAttached((prev) => prev.filter((p) => p.name !== f.name))
|
|
141
|
+
composerRef.current?.focus()
|
|
142
|
+
}}
|
|
143
|
+
/>
|
|
144
|
+
))}
|
|
145
|
+
</div>
|
|
146
|
+
)}
|
|
147
|
+
<div className="mt-3 flex items-center justify-between gap-2">
|
|
148
|
+
<Button
|
|
149
|
+
type="button"
|
|
150
|
+
variant="ghost"
|
|
151
|
+
size="icon-xl"
|
|
152
|
+
aria-label="Attach a file"
|
|
153
|
+
disabled={sending}
|
|
154
|
+
onClick={() =>
|
|
155
|
+
setAttached((prev) =>
|
|
156
|
+
prev.some((p) => p.name === FILES.favicon.name)
|
|
157
|
+
? prev
|
|
158
|
+
: [...prev, FILES.favicon]
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
>
|
|
162
|
+
<Paperclip strokeWidth={1.5} aria-hidden="true" />
|
|
163
|
+
</Button>
|
|
164
|
+
<Button
|
|
165
|
+
type="button"
|
|
166
|
+
size="xl"
|
|
167
|
+
disabled={sending}
|
|
168
|
+
loading={sending}
|
|
169
|
+
onClick={() => {
|
|
170
|
+
setSending(true)
|
|
171
|
+
window.setTimeout(() => {
|
|
172
|
+
setSending(false)
|
|
173
|
+
setAttached([])
|
|
174
|
+
}, 1200)
|
|
175
|
+
}}
|
|
176
|
+
>
|
|
177
|
+
<SendHorizontal strokeWidth={1.5} aria-hidden="true" />
|
|
178
|
+
Send
|
|
179
|
+
</Button>
|
|
180
|
+
</div>
|
|
181
|
+
</Card>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Three chips inside a composer. Remove one, re-attach via the paperclip, send to watch the disabled state. */
|
|
186
|
+
export const RealisticUse: Story = {
|
|
187
|
+
render: () => <ComposerDemo />,
|
|
188
|
+
parameters: { controls: { disable: true } },
|
|
189
|
+
}
|
|
@@ -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`
|