@behavioral-agentic-design-system/core 0.24.0 → 0.26.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.
Files changed (131) hide show
  1. package/package.json +5 -2
  2. package/scripts/build-tokens.cjs +79 -5
  3. package/src/app/preview/components/page.tsx +4474 -208
  4. package/src/app/shell.tsx +18 -6
  5. package/src/components/customize/brand-mark-section.tsx +1 -1
  6. package/src/components/customize-tab.tsx +2 -2
  7. package/src/components/home-tab.tsx +2 -2
  8. package/src/components/ui/action-bar.tsx +142 -0
  9. package/src/components/ui/affix.tsx +109 -0
  10. package/src/components/ui/alert.tsx +37 -3
  11. package/src/components/ui/anchor.tsx +136 -0
  12. package/src/components/ui/angle-slider.tsx +265 -0
  13. package/src/components/ui/autocomplete.tsx +223 -0
  14. package/src/components/ui/avatar.tsx +8 -2
  15. package/src/components/ui/blockquote.tsx +112 -0
  16. package/src/components/ui/bottom-navigation.tsx +144 -0
  17. package/src/components/ui/burger.tsx +117 -0
  18. package/src/components/ui/button.tsx +101 -3
  19. package/src/components/ui/calendar.tsx +1 -1
  20. package/src/components/ui/card.tsx +43 -5
  21. package/src/components/ui/carousel.tsx +10 -5
  22. package/src/components/ui/cascader.tsx +253 -0
  23. package/src/components/ui/checkbox-card.tsx +176 -0
  24. package/src/components/ui/checkbox-group.tsx +231 -0
  25. package/src/components/ui/checkbox.tsx +14 -3
  26. package/src/components/ui/chip.tsx +143 -0
  27. package/src/components/ui/circular-progress.tsx +2 -2
  28. package/src/components/ui/color-swatch.tsx +73 -0
  29. package/src/components/ui/copy-button.tsx +21 -4
  30. package/src/components/ui/date-picker.tsx +6 -3
  31. package/src/components/ui/date-range-picker.tsx +6 -3
  32. package/src/components/ui/float-label.tsx +114 -0
  33. package/src/components/ui/floating-panel.tsx +129 -0
  34. package/src/components/ui/format-number.tsx +122 -0
  35. package/src/components/ui/highlight.tsx +85 -0
  36. package/src/components/ui/image.tsx +195 -0
  37. package/src/components/ui/index.ts +50 -0
  38. package/src/components/ui/indicator.tsx +2 -2
  39. package/src/components/ui/input.tsx +48 -4
  40. package/src/components/ui/kbd.tsx +1 -1
  41. package/src/components/ui/link.tsx +158 -0
  42. package/src/components/ui/listbox.tsx +426 -0
  43. package/src/components/ui/loading-overlay.tsx +80 -0
  44. package/src/components/ui/marquee.tsx +193 -0
  45. package/src/components/ui/masonry.tsx +164 -0
  46. package/src/components/ui/meter.tsx +186 -0
  47. package/src/components/ui/motion-toggle.tsx +170 -0
  48. package/src/components/ui/notification.tsx +175 -0
  49. package/src/components/ui/overlay.tsx +63 -0
  50. package/src/components/ui/progress.tsx +95 -4
  51. package/src/components/ui/rating-group.tsx +1 -0
  52. package/src/components/ui/separator.tsx +57 -1
  53. package/src/components/ui/sidebar.tsx +1 -1
  54. package/src/components/ui/signature-pad.tsx +381 -0
  55. package/src/components/ui/skeleton.tsx +59 -2
  56. package/src/components/ui/skip-link.tsx +117 -0
  57. package/src/components/ui/slider.tsx +86 -1
  58. package/src/components/ui/spoiler.tsx +131 -0
  59. package/src/components/ui/tabs.tsx +1 -1
  60. package/src/components/ui/text.tsx +135 -0
  61. package/src/components/ui/textarea.tsx +66 -2
  62. package/src/components/ui/timeline.tsx +71 -14
  63. package/src/components/ui/timer.tsx +183 -0
  64. package/src/components/ui/tour.tsx +332 -0
  65. package/src/components/ui/transfer-list.tsx +308 -0
  66. package/src/components/ui/visually-hidden.tsx +42 -0
  67. package/src/components/ui/watermark.tsx +0 -0
  68. package/src/data/docs-index.ts +9 -2
  69. package/src/stories/ActionBar.stories.tsx +201 -0
  70. package/src/stories/Affix.stories.tsx +165 -0
  71. package/src/stories/Alert.stories.tsx +58 -0
  72. package/src/stories/Anchor.stories.tsx +236 -0
  73. package/src/stories/AngleSlider.stories.tsx +128 -0
  74. package/src/stories/Autocomplete.stories.tsx +216 -0
  75. package/src/stories/Avatar.stories.tsx +73 -1
  76. package/src/stories/Blockquote.stories.tsx +148 -0
  77. package/src/stories/BottomNavigation.stories.tsx +195 -0
  78. package/src/stories/Burger.stories.tsx +79 -0
  79. package/src/stories/Button.stories.tsx +103 -2
  80. package/src/stories/Calendar.stories.tsx +4 -0
  81. package/src/stories/Card.stories.tsx +30 -0
  82. package/src/stories/Carousel.stories.tsx +2 -1
  83. package/src/stories/Cascader.stories.tsx +285 -0
  84. package/src/stories/Checkbox.stories.tsx +13 -0
  85. package/src/stories/CheckboxCard.stories.tsx +210 -0
  86. package/src/stories/CheckboxGroup.stories.tsx +186 -0
  87. package/src/stories/Chip.stories.tsx +173 -0
  88. package/src/stories/CircularProgress.stories.tsx +3 -0
  89. package/src/stories/ColorSwatch.stories.tsx +81 -0
  90. package/src/stories/CopyButton.stories.tsx +3 -3
  91. package/src/stories/DatePicker.stories.tsx +3 -0
  92. package/src/stories/DateRangePicker.stories.tsx +3 -0
  93. package/src/stories/Editable.stories.tsx +14 -0
  94. package/src/stories/FloatLabel.stories.tsx +148 -0
  95. package/src/stories/FloatingPanel.stories.tsx +176 -0
  96. package/src/stories/FormatNumber.stories.tsx +308 -0
  97. package/src/stories/Highlight.stories.tsx +140 -0
  98. package/src/stories/Image.stories.tsx +141 -0
  99. package/src/stories/Indicator.stories.tsx +3 -0
  100. package/src/stories/Input.stories.tsx +33 -0
  101. package/src/stories/Kbd.stories.tsx +3 -0
  102. package/src/stories/Link.stories.tsx +198 -0
  103. package/src/stories/Listbox.stories.tsx +240 -0
  104. package/src/stories/LoadingOverlay.stories.tsx +148 -0
  105. package/src/stories/Marquee.stories.tsx +170 -0
  106. package/src/stories/Masonry.stories.tsx +227 -0
  107. package/src/stories/Meter.stories.tsx +143 -0
  108. package/src/stories/MotionToggle.stories.tsx +85 -0
  109. package/src/stories/Notification.stories.tsx +264 -0
  110. package/src/stories/Overlay.stories.tsx +169 -0
  111. package/src/stories/PasswordInput.stories.tsx +4 -0
  112. package/src/stories/Progress.stories.tsx +70 -27
  113. package/src/stories/RatingGroup.stories.tsx +5 -0
  114. package/src/stories/Separator.stories.tsx +41 -5
  115. package/src/stories/Sidebar.stories.tsx +2 -1
  116. package/src/stories/SignaturePad.stories.tsx +112 -0
  117. package/src/stories/Skeleton.stories.tsx +23 -4
  118. package/src/stories/SkipLink.stories.tsx +137 -0
  119. package/src/stories/Slider.stories.tsx +28 -0
  120. package/src/stories/Spoiler.stories.tsx +122 -0
  121. package/src/stories/Tabs.stories.tsx +2 -1
  122. package/src/stories/Text.stories.tsx +191 -0
  123. package/src/stories/Textarea.stories.tsx +58 -6
  124. package/src/stories/Timeline.stories.tsx +82 -0
  125. package/src/stories/Timer.stories.tsx +160 -0
  126. package/src/stories/Tour.stories.tsx +191 -0
  127. package/src/stories/TransferList.stories.tsx +169 -0
  128. package/src/stories/VisuallyHidden.stories.tsx +105 -0
  129. package/src/stories/Watermark.stories.tsx +212 -0
  130. package/src/styles.css +80 -6
  131. package/src/tokens.json +2 -2
@@ -0,0 +1,227 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import * as React from "react";
3
+ import { Masonry } from "@behavioral-agentic-design-system/core/components/ui/masonry";
4
+ import {
5
+ Card,
6
+ CardContent,
7
+ CardDescription,
8
+ CardHeader,
9
+ CardTitle,
10
+ } from "@behavioral-agentic-design-system/core/components/ui/card";
11
+ import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
12
+ import {
13
+ Avatar,
14
+ AvatarFallback,
15
+ } from "@behavioral-agentic-design-system/core/components/ui/avatar";
16
+
17
+ const meta: Meta<typeof Masonry> = {
18
+ title: "Components/Masonry",
19
+ component: Masonry,
20
+ parameters: { layout: "padded" },
21
+ tags: ["autodocs"],
22
+ argTypes: {
23
+ gap: {
24
+ control: "select",
25
+ options: ["0", "1", "2", "3", "4", "5", "6", "8"],
26
+ },
27
+ },
28
+ };
29
+
30
+ export default meta;
31
+ type Story = StoryObj<typeof Masonry>;
32
+
33
+ // Real content from content/personas/bads.json — the primary persona's
34
+ // jargon pool as doc-note tiles of deliberately uneven length, so the
35
+ // columns actually stagger the way variable-height content does.
36
+ const DOC_NOTES = [
37
+ {
38
+ topic: "design tokens",
39
+ body: "tokens.json is the source of truth. Run pnpm build:tokens and both CSS files regenerate.",
40
+ },
41
+ {
42
+ topic: "a11y contract",
43
+ body: "Every registry entry declares role, keyboard, focus, and target size. 7:1 contrast, 14px minimum, 44×44px target.",
44
+ },
45
+ {
46
+ topic: "token drift",
47
+ body: "The orphan lint scans every shipped theme token and flags zeros.",
48
+ },
49
+ {
50
+ topic: "visual regression",
51
+ body: "Chromatic runs on every push to main. First run establishes the baseline; every PR after that gets visual diffs against it, so a stray token change can't reflow a surface unnoticed.",
52
+ },
53
+ {
54
+ topic: "focus trap",
55
+ body: "Dialog and Sheet trap focus while open and return it to the trigger on close.",
56
+ },
57
+ {
58
+ topic: "semantic layer",
59
+ body: "Primitives resolve through semantic tokens — bg-card, text-muted-foreground — never raw hex. Rebrand by editing the semantic layer once.",
60
+ },
61
+ ];
62
+
63
+ function DocNoteCard({ topic, body }: { topic: string; body: string }) {
64
+ return (
65
+ <Card>
66
+ <CardHeader>
67
+ <CardTitle className="text-lg">{topic}</CardTitle>
68
+ </CardHeader>
69
+ <CardContent>
70
+ <p className="text-sm text-muted-foreground">{body}</p>
71
+ </CardContent>
72
+ </Card>
73
+ );
74
+ }
75
+
76
+ export const Default: Story = {
77
+ render: () => (
78
+ <Masonry>
79
+ {DOC_NOTES.map((note) => (
80
+ <DocNoteCard key={note.topic} {...note} />
81
+ ))}
82
+ </Masonry>
83
+ ),
84
+ };
85
+
86
+ export const TwoColumns: Story = {
87
+ render: () => (
88
+ <Masonry columns={2}>
89
+ {DOC_NOTES.map((note) => (
90
+ <DocNoteCard key={note.topic} {...note} />
91
+ ))}
92
+ </Masonry>
93
+ ),
94
+ };
95
+
96
+ export const FourColumns: Story = {
97
+ render: () => (
98
+ <Masonry columns={4} gap="3">
99
+ {DOC_NOTES.map((note) => (
100
+ <DocNoteCard key={note.topic} {...note} />
101
+ ))}
102
+ </Masonry>
103
+ ),
104
+ };
105
+
106
+ export const Responsive: Story = {
107
+ name: "Responsive ({ sm: 1, md: 2, lg: 3 })",
108
+ render: () => (
109
+ <Masonry columns={{ sm: 1, md: 2, lg: 3 }}>
110
+ {DOC_NOTES.map((note) => (
111
+ <DocNoteCard key={note.topic} {...note} />
112
+ ))}
113
+ </Masonry>
114
+ ),
115
+ };
116
+
117
+ // Real content from content/personas/bads.json — testimonials pool plus the
118
+ // metrics pool as interleaved stat tiles: the canonical masonry use case of
119
+ // mixed-height cards on a community wall.
120
+ const TESTIMONIALS = [
121
+ {
122
+ name: "Jordan Reeves",
123
+ role: "Design Systems Lead",
124
+ quote:
125
+ "First system I've adopted without reading a single apology in the docs. The a11y contracts are actually enforced.",
126
+ },
127
+ {
128
+ name: "Seo-yun Park",
129
+ role: "Senior Design Engineer",
130
+ quote:
131
+ "The token pipeline paid for itself in a week. One tokens.json change, both CSS files regenerate, every fork picks it up.",
132
+ },
133
+ {
134
+ name: "Marcus Lindqvist",
135
+ role: "Staff Engineer",
136
+ quote:
137
+ "Storybook coverage wired into pre-commit means nobody ships a variant without a story. That alone ended our drift problem.",
138
+ },
139
+ {
140
+ name: "Anika Patel",
141
+ role: "Design Engineer",
142
+ quote:
143
+ "7:1 contrast out of the box. I stopped auditing every PR for hardcoded hex values because the lint does it for me.",
144
+ },
145
+ ];
146
+
147
+ const STATS = [
148
+ { label: "Client savings to date", value: "$182,450" },
149
+ { label: "Build hours avoided", value: "1,432 hrs" },
150
+ { label: "Story coverage", value: "98.4%" },
151
+ ];
152
+
153
+ function initials(name: string) {
154
+ return name
155
+ .split(" ")
156
+ .map((part) => part[0])
157
+ .join("");
158
+ }
159
+
160
+ export const RealisticUse: Story = {
161
+ render: () => (
162
+ <Masonry columns={{ sm: 1, md: 2, lg: 3 }} gap="4">
163
+ {TESTIMONIALS.slice(0, 2).map((t) => (
164
+ <Card key={t.name}>
165
+ <CardContent className="pt-6">
166
+ <blockquote className="text-sm text-foreground">
167
+ &ldquo;{t.quote}&rdquo;
168
+ </blockquote>
169
+ <div className="mt-4 flex items-center gap-3">
170
+ <Avatar>
171
+ <AvatarFallback>{initials(t.name)}</AvatarFallback>
172
+ </Avatar>
173
+ <div className="min-w-0">
174
+ <p className="truncate text-sm font-medium">{t.name}</p>
175
+ <p className="truncate text-xs text-muted-foreground">
176
+ {t.role}
177
+ </p>
178
+ </div>
179
+ </div>
180
+ </CardContent>
181
+ </Card>
182
+ ))}
183
+ {STATS.map((stat) => (
184
+ <Card key={stat.label}>
185
+ <CardHeader>
186
+ <CardDescription>{stat.label}</CardDescription>
187
+ <CardTitle className="text-3xl tabular-nums">
188
+ {stat.value}
189
+ </CardTitle>
190
+ </CardHeader>
191
+ </Card>
192
+ ))}
193
+ {TESTIMONIALS.slice(2).map((t) => (
194
+ <Card key={t.name}>
195
+ <CardContent className="pt-6">
196
+ <blockquote className="text-sm text-foreground">
197
+ &ldquo;{t.quote}&rdquo;
198
+ </blockquote>
199
+ <div className="mt-4 flex items-center gap-3">
200
+ <Avatar>
201
+ <AvatarFallback>{initials(t.name)}</AvatarFallback>
202
+ </Avatar>
203
+ <div className="min-w-0">
204
+ <p className="truncate text-sm font-medium">{t.name}</p>
205
+ <p className="truncate text-xs text-muted-foreground">
206
+ {t.role}
207
+ </p>
208
+ </div>
209
+ </div>
210
+ </CardContent>
211
+ </Card>
212
+ ))}
213
+ <Card>
214
+ <CardHeader>
215
+ <div className="flex items-center gap-2">
216
+ <CardTitle className="text-lg">BADS 1.0</CardTitle>
217
+ <Badge variant="secondary">shipped 2026-05-26</Badge>
218
+ </div>
219
+ <CardDescription>
220
+ 88 registry components, 7:1 contrast floor, 44×44px targets — every
221
+ fork starts here.
222
+ </CardDescription>
223
+ </CardHeader>
224
+ </Card>
225
+ </Masonry>
226
+ ),
227
+ };
@@ -0,0 +1,143 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import { Meter } from "@behavioral-agentic-design-system/core/components/ui/meter"
4
+
5
+ const meta: Meta<typeof Meter> = {
6
+ title: "Components/Meter",
7
+ component: Meter,
8
+ parameters: {
9
+ layout: "centered",
10
+ docs: {
11
+ description: {
12
+ component:
13
+ "Linear gauge for where a measurement falls within a known range — battery, disk usage, vote share. role=\"meter\" (ARIA 1.1) with aria-valuenow/min/max/valuetext; the semantic sibling of Progress (which tracks work toward a goal as role=\"progressbar\"). Fill width and threshold color ease via var(--duration-base) + var(--ease-out). Display-only — not focusable, target size n/a.",
14
+ },
15
+ },
16
+ },
17
+ decorators: [
18
+ (Story) => (
19
+ <div className="w-80">
20
+ <Story />
21
+ </div>
22
+ ),
23
+ ],
24
+ }
25
+ export default meta
26
+ type Story = StoryObj<typeof Meter>
27
+
28
+ export const Default: Story = {
29
+ render: () => <Meter value={62} aria-label="Storage used" />,
30
+ }
31
+
32
+ export const WithLabel: Story = {
33
+ render: () => (
34
+ <Meter value={12.4} min={0} max={20} label="Asset storage" showValue getValueLabel={(v, _min, max) => `${v} GB of ${max} GB`} />
35
+ ),
36
+ }
37
+
38
+ export const Variant_Success: Story = {
39
+ render: () => (
40
+ <Meter value={98.4} variant="success" label="Story coverage" showValue getValueLabel={(v) => `${v}%`} />
41
+ ),
42
+ }
43
+
44
+ export const Variant_Warning: Story = {
45
+ render: () => (
46
+ <Meter value={78} variant="warning" label="Token budget used" showValue />
47
+ ),
48
+ }
49
+
50
+ export const Variant_Destructive: Story = {
51
+ render: () => (
52
+ <Meter value={94} variant="destructive" label="Contrast failures quota" showValue />
53
+ ),
54
+ }
55
+
56
+ export const WithVariants: Story = {
57
+ name: "WithVariants (threshold walk)",
58
+ render: () => {
59
+ // The variant is explicit — the consumer maps value → threshold. This is
60
+ // the canonical mapping for a "remaining capacity" reading.
61
+ const readings = [
62
+ { label: "Battery — healthy", value: 82, variant: "success" as const },
63
+ { label: "Battery — getting low", value: 34, variant: "warning" as const },
64
+ { label: "Battery — critical", value: 9, variant: "destructive" as const },
65
+ ]
66
+ return (
67
+ <div className="flex flex-col gap-5">
68
+ {readings.map((r) => (
69
+ <Meter
70
+ key={r.label}
71
+ value={r.value}
72
+ variant={r.variant}
73
+ label={r.label}
74
+ showValue
75
+ />
76
+ ))}
77
+ </div>
78
+ )
79
+ },
80
+ }
81
+
82
+ export const Size_Sm: Story = {
83
+ render: () => <Meter value={62} size="sm" aria-label="Storage used (small)" />,
84
+ }
85
+
86
+ export const Size_Default: Story = {
87
+ render: () => (
88
+ <Meter value={62} size="default" aria-label="Storage used (default)" />
89
+ ),
90
+ }
91
+
92
+ export const Size_Lg: Story = {
93
+ render: () => <Meter value={62} size="lg" aria-label="Storage used (large)" />,
94
+ }
95
+
96
+ export const Disabled: Story = {
97
+ render: () => (
98
+ <Meter value={62} disabled label="Asset storage (workspace archived)" showValue />
99
+ ),
100
+ }
101
+
102
+ export const RealisticUse: Story = {
103
+ render: () => {
104
+ // Persona content pool (content/personas/bads.json): Jordan Reeves,
105
+ // design.bads.com, registry/story-coverage metrics.
106
+ const [used, setUsed] = React.useState(12.4)
107
+ const max = 20
108
+ const pct = (used / max) * 100
109
+ const variant = pct >= 90 ? "destructive" : pct >= 75 ? "warning" : "default"
110
+ return (
111
+ <div className="flex w-80 flex-col gap-4 rounded-lg border border-border bg-card p-5">
112
+ <div>
113
+ <p className="text-base font-semibold text-card-foreground">
114
+ design.bads.com storage
115
+ </p>
116
+ <p className="text-sm text-muted-foreground">
117
+ Jordan Reeves&rsquo; workspace &middot; 88 registry components
118
+ </p>
119
+ </div>
120
+ <Meter
121
+ value={used}
122
+ min={0}
123
+ max={max}
124
+ variant={variant}
125
+ label="Asset storage"
126
+ showValue
127
+ getValueLabel={(v, _min, m) => `${v.toFixed(1)} GB of ${m} GB`}
128
+ />
129
+ <button
130
+ type="button"
131
+ className="min-h-11 rounded-md border border-border px-4 text-sm font-medium text-foreground transition-colors hover:bg-muted"
132
+ style={{
133
+ transitionDuration: "var(--duration-fast)",
134
+ transitionTimingFunction: "var(--ease-out)",
135
+ }}
136
+ onClick={() => setUsed((u) => (u >= max - 2 ? 12.4 : Math.round((u + 2.4) * 10) / 10))}
137
+ >
138
+ Upload exemplar batch (+2.4 GB)
139
+ </button>
140
+ </div>
141
+ )
142
+ },
143
+ }
@@ -0,0 +1,85 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import * as React from "react";
3
+ import { userEvent, within, expect, waitFor } from "storybook/test";
4
+ import { MotionToggle } from "@behavioral-agentic-design-system/core/components/ui/motion-toggle";
5
+
6
+ const meta: Meta<typeof MotionToggle> = {
7
+ title: "Components/MotionToggle",
8
+ component: MotionToggle,
9
+ parameters: { layout: "centered" },
10
+ tags: ["autodocs"],
11
+ argTypes: {
12
+ size: { control: "select", options: ["sm", "default", "lg"] },
13
+ showHint: { control: "boolean" },
14
+ },
15
+ };
16
+
17
+ export default meta;
18
+ type Story = StoryObj<typeof MotionToggle>;
19
+
20
+ export const Default: Story = {
21
+ args: { storageSuffix: "motion-sb-default" },
22
+ };
23
+
24
+ export const WithHint: Story = {
25
+ args: { showHint: true, storageSuffix: "motion-sb-hint" },
26
+ };
27
+
28
+ export const Size_Sm: Story = {
29
+ args: { size: "sm", storageSuffix: "motion-sb-sm" },
30
+ };
31
+
32
+ export const Size_Default: Story = {
33
+ args: { size: "default", storageSuffix: "motion-sb-default2" },
34
+ };
35
+
36
+ export const Size_Lg: Story = {
37
+ args: { size: "lg", storageSuffix: "motion-sb-lg" },
38
+ };
39
+
40
+ // Realistic use: an Appearance settings row pairing the label + control + hint,
41
+ // the shape a fork drops into its own settings surface.
42
+ export const RealisticUse: Story = {
43
+ render: () => (
44
+ <div className="flex w-96 flex-col gap-4 rounded-lg border bg-card p-6">
45
+ <div className="flex flex-col gap-1">
46
+ <h3 className="text-sm font-medium text-foreground">Motion</h3>
47
+ <p className="text-xs text-muted-foreground">
48
+ Control animations across the app. Reduced turns them off here even if
49
+ your device allows motion.
50
+ </p>
51
+ </div>
52
+ <MotionToggle showHint storageSuffix="motion-sb-settings" />
53
+ </div>
54
+ ),
55
+ };
56
+
57
+ // Verifies the data-motion contract end to end: selecting Reduced sets
58
+ // html[data-motion="reduce"], selecting Full sets "full", and returning to
59
+ // System REMOVES the attribute so the OS media query is the sole authority.
60
+ export const Interaction_SetsDataMotion: Story = {
61
+ tags: ["test"],
62
+ args: { storageSuffix: "motion-sb-interaction" },
63
+ play: async ({ canvasElement }) => {
64
+ const canvas = within(canvasElement);
65
+ const root = document.documentElement;
66
+ // Clean slate — other stories may have left an attribute behind.
67
+ root.removeAttribute("data-motion");
68
+
69
+ const reduced = canvas.getByRole("radio", { name: /reduced/i });
70
+ const full = canvas.getByRole("radio", { name: /full/i });
71
+ const system = canvas.getByRole("radio", { name: /system/i });
72
+
73
+ await userEvent.click(reduced);
74
+ await waitFor(() => expect(root).toHaveAttribute("data-motion", "reduce"));
75
+ expect(reduced).toHaveAttribute("aria-checked", "true");
76
+
77
+ await userEvent.click(full);
78
+ await waitFor(() => expect(root).toHaveAttribute("data-motion", "full"));
79
+
80
+ await userEvent.click(system);
81
+ // System clears the attribute entirely (not data-motion="system").
82
+ await waitFor(() => expect(root).not.toHaveAttribute("data-motion"));
83
+ expect(system).toHaveAttribute("aria-checked", "true");
84
+ },
85
+ };