@behavioral-agentic-design-system/core 0.27.0 → 0.29.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 +5 -5
- package/scripts/a11y-lint.cjs +78 -9
- package/scripts/build-tokens.cjs +273 -15
- package/scripts/wcag-audit.cjs +37 -7
- package/src/api/layers/file.ts +1 -0
- package/src/app/font-ready.tsx +6 -5
- package/src/app/layout.tsx +54 -3
- package/src/app/preview/components/page.tsx +5735 -2500
- package/src/app/preview/layout.tsx +4 -1
- package/src/app/preview/showcase-filter.tsx +66 -0
- package/src/app/preview/tab-replay.tsx +63 -0
- package/src/app/shell.tsx +91 -18
- package/src/components/customize/save-bar.tsx +19 -6
- package/src/components/docs-tab.tsx +36 -24
- package/src/components/layers-tab.tsx +37 -5
- package/src/components/ui/ai-badge.tsx +74 -0
- package/src/components/ui/alert.tsx +12 -0
- package/src/components/ui/badge.tsx +19 -0
- package/src/components/ui/chat-bubble.tsx +298 -0
- package/src/components/ui/chat-marker.tsx +120 -0
- package/src/components/ui/checkbox.tsx +9 -1
- package/src/components/ui/clipboard.tsx +291 -0
- package/src/components/ui/close-button.tsx +71 -0
- package/src/components/ui/combobox.tsx +62 -3
- package/src/components/ui/container.tsx +65 -0
- package/src/components/ui/copy-button.tsx +5 -1
- package/src/components/ui/data-table.tsx +388 -0
- package/src/components/ui/date-field.tsx +368 -0
- package/src/components/ui/drawer.tsx +334 -0
- package/src/components/ui/file-button.tsx +145 -0
- package/src/components/ui/floating-indicator.tsx +217 -0
- package/src/components/ui/focus-trap.tsx +184 -0
- package/src/components/ui/format-byte.tsx +113 -0
- package/src/components/ui/index.ts +28 -0
- package/src/components/ui/input.tsx +38 -3
- package/src/components/ui/keyboard-shortcut.tsx +146 -0
- package/src/components/ui/loading-dots.tsx +99 -0
- package/src/components/ui/mark.tsx +69 -0
- package/src/components/ui/month-picker.tsx +296 -0
- package/src/components/ui/multi-select.tsx +15 -13
- package/src/components/ui/nav-link.tsx +200 -0
- package/src/components/ui/navigation-rail.tsx +256 -0
- package/src/components/ui/notification.tsx +20 -0
- package/src/components/ui/password-input.tsx +34 -1
- package/src/components/ui/progress.tsx +15 -1
- package/src/components/ui/prose.tsx +62 -0
- package/src/components/ui/result.tsx +151 -0
- package/src/components/ui/rolling-number.tsx +201 -0
- package/src/components/ui/simple-grid.tsx +110 -0
- package/src/components/ui/skeleton.tsx +52 -3
- package/src/components/ui/squircle.tsx +274 -0
- package/src/components/ui/stack.tsx +105 -0
- package/src/components/ui/status-badge.tsx +93 -0
- package/src/components/ui/tabs.tsx +34 -7
- package/src/components/ui/tag.tsx +46 -5
- package/src/components/ui/theme-icon.tsx +138 -0
- package/src/components/ui/timeline.tsx +27 -10
- package/src/components/ui/tooltip.tsx +12 -1
- package/src/components/ui/tree-select.tsx +386 -0
- package/src/components/ui/typing-indicator.tsx +2 -2
- package/src/components/ui/word-rotate.tsx +6 -1
- package/src/components/ui/year-picker.tsx +307 -0
- package/src/data/docs-index.ts +10 -0
- package/src/hooks/use-global-primary-color.ts +57 -6
- package/src/stories/AiBadge.stories.tsx +67 -0
- package/src/stories/Alert.stories.tsx +31 -1
- package/src/stories/Badge.stories.tsx +63 -6
- package/src/stories/ChatBubble.stories.tsx +222 -0
- package/src/stories/ChatMarker.stories.tsx +59 -0
- package/src/stories/Checkbox.stories.tsx +5 -0
- package/src/stories/Clipboard.stories.tsx +136 -0
- package/src/stories/CloseButton.stories.tsx +65 -0
- package/src/stories/Combobox.stories.tsx +74 -3
- package/src/stories/Container.stories.tsx +134 -0
- package/src/stories/CopyButton.stories.tsx +2 -0
- package/src/stories/DataTable.stories.tsx +271 -0
- package/src/stories/DateField.stories.tsx +114 -0
- package/src/stories/Drawer.stories.tsx +211 -0
- package/src/stories/FileButton.stories.tsx +117 -0
- package/src/stories/FloatingIndicator.stories.tsx +343 -0
- package/src/stories/FocusTrap.stories.tsx +218 -0
- package/src/stories/FormatByte.stories.tsx +142 -0
- package/src/stories/Input.stories.tsx +91 -0
- package/src/stories/KeyboardShortcut.stories.tsx +87 -0
- package/src/stories/LoadingDots.stories.tsx +73 -0
- package/src/stories/Mark.stories.tsx +84 -0
- package/src/stories/MonthPicker.stories.tsx +99 -0
- package/src/stories/MultiSelect.stories.tsx +3 -1
- package/src/stories/NavLink.stories.tsx +213 -0
- package/src/stories/NavigationRail.stories.tsx +413 -0
- package/src/stories/Notification.stories.tsx +53 -0
- package/src/stories/PasswordInput.stories.tsx +21 -0
- package/src/stories/Progress.stories.tsx +38 -0
- package/src/stories/Prose.stories.tsx +232 -0
- package/src/stories/Result.stories.tsx +145 -0
- package/src/stories/RollingNumber.stories.tsx +226 -0
- package/src/stories/SimpleGrid.stories.tsx +130 -0
- package/src/stories/Skeleton.stories.tsx +62 -1
- package/src/stories/Squircle.stories.tsx +127 -0
- package/src/stories/Stack.stories.tsx +139 -0
- package/src/stories/StatusBadge.stories.tsx +125 -0
- package/src/stories/Tabs.stories.tsx +56 -1
- package/src/stories/Tag.stories.tsx +31 -0
- package/src/stories/ThemeIcon.stories.tsx +97 -0
- package/src/stories/Timeline.stories.tsx +69 -0
- package/src/stories/Tooltip.stories.tsx +18 -0
- package/src/stories/TreeSelect.stories.tsx +222 -0
- package/src/stories/TypingIndicator.stories.tsx +1 -0
- package/src/stories/WordRotate.stories.tsx +1 -0
- package/src/stories/YearPicker.stories.tsx +100 -0
- package/src/styles.css +289 -15
- package/src/tokens.json +96 -1
- package/LICENSE +0 -21
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { Prose } from "@behavioral-agentic-design-system/core/components/ui/prose"
|
|
4
|
+
import {
|
|
5
|
+
Card,
|
|
6
|
+
CardContent,
|
|
7
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof Prose> = {
|
|
10
|
+
title: "Components/Prose",
|
|
11
|
+
component: Prose,
|
|
12
|
+
parameters: { layout: "centered" },
|
|
13
|
+
tags: ["autodocs"],
|
|
14
|
+
argTypes: {
|
|
15
|
+
asChild: { control: "boolean" },
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export default meta
|
|
20
|
+
type Story = StoryObj<typeof meta>
|
|
21
|
+
|
|
22
|
+
// Content pulled from content/personas/bads.json (real-content rule) —
|
|
23
|
+
// names, metrics, and jargon come from the persona pool; the article copy
|
|
24
|
+
// is the BADS stack described in its own voice. Never Lorem, never Acme.
|
|
25
|
+
|
|
26
|
+
export const Default: Story = {
|
|
27
|
+
render: () => (
|
|
28
|
+
<Prose className="max-w-prose">
|
|
29
|
+
<h2>Why design tokens</h2>
|
|
30
|
+
<p>
|
|
31
|
+
A token is a named value — color, spacing, font size — that can change
|
|
32
|
+
without editing component code. When a brand color moves, one edit to{" "}
|
|
33
|
+
<code>tokens.json</code> propagates to every surface that references{" "}
|
|
34
|
+
<code>--primary</code>.
|
|
35
|
+
</p>
|
|
36
|
+
<p>
|
|
37
|
+
The alternative is token drift: forty-one hardcoded hex values across
|
|
38
|
+
three repos, each one a slightly different navy. Jordan Reeves reads
|
|
39
|
+
component source before adopting anything, and will absolutely bounce
|
|
40
|
+
a PR for a hardcoded hex value.
|
|
41
|
+
</p>
|
|
42
|
+
</Prose>
|
|
43
|
+
),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const WithHeadings: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<Prose className="max-w-prose">
|
|
49
|
+
<h1>Getting started with BADS</h1>
|
|
50
|
+
<p>
|
|
51
|
+
Fork it, rename it, customize the brand colors, and start building.
|
|
52
|
+
The stack is ten layers, all shipped.
|
|
53
|
+
</p>
|
|
54
|
+
<h2>The semantic layer</h2>
|
|
55
|
+
<p>
|
|
56
|
+
Semantic tokens are named for purpose — <code>--destructive</code>,
|
|
57
|
+
not a hex value — so intent survives a rebrand.
|
|
58
|
+
</p>
|
|
59
|
+
<h3>Primitives underneath</h3>
|
|
60
|
+
<p>
|
|
61
|
+
Every semantic token aliases a primitive scale entry, and the build
|
|
62
|
+
script resolves the chain at generation time.
|
|
63
|
+
</p>
|
|
64
|
+
<h4>What that buys you</h4>
|
|
65
|
+
<p>
|
|
66
|
+
Designers update one place; every component, story, and fork follows.
|
|
67
|
+
</p>
|
|
68
|
+
</Prose>
|
|
69
|
+
),
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const WithCode: Story = {
|
|
73
|
+
render: () => (
|
|
74
|
+
<Prose className="max-w-prose">
|
|
75
|
+
<p>
|
|
76
|
+
Regenerate both CSS files after any token edit — the generated files
|
|
77
|
+
carry a banner header and are never edited by hand:
|
|
78
|
+
</p>
|
|
79
|
+
<pre>
|
|
80
|
+
<code>{`pnpm build:tokens
|
|
81
|
+
# ✓ wrote packages/core/src/styles.css
|
|
82
|
+
# ✓ wrote styles/globals.css`}</code>
|
|
83
|
+
</pre>
|
|
84
|
+
<p>
|
|
85
|
+
Components reference motion through the token surface, e.g.{" "}
|
|
86
|
+
<code>var(--duration-fast)</code> with <code>var(--ease-out)</code> —
|
|
87
|
+
a <code>180ms transition</code> is a token decision, not a component
|
|
88
|
+
one.
|
|
89
|
+
</p>
|
|
90
|
+
</Prose>
|
|
91
|
+
),
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const WithLists: Story = {
|
|
95
|
+
render: () => (
|
|
96
|
+
<Prose className="max-w-prose">
|
|
97
|
+
<p>Every registry entry ships with an a11y contract covering:</p>
|
|
98
|
+
<ul>
|
|
99
|
+
<li>Contrast — 7:1 normal text, the AAA floor</li>
|
|
100
|
+
<li>Type — 14px minimum, no exceptions</li>
|
|
101
|
+
<li>Touch targets — 44×44px on every flow-changing control</li>
|
|
102
|
+
<li>
|
|
103
|
+
Focus — visible ring, 2px offset, never removed
|
|
104
|
+
<ul>
|
|
105
|
+
<li>Nested detail: the ring token is luminance-tuned per surface</li>
|
|
106
|
+
</ul>
|
|
107
|
+
</li>
|
|
108
|
+
</ul>
|
|
109
|
+
<p>Adopting a fork takes three steps:</p>
|
|
110
|
+
<ol>
|
|
111
|
+
<li>Run the rename script with your display name and slug</li>
|
|
112
|
+
<li>Point the brand config at your palette</li>
|
|
113
|
+
<li>Regenerate tokens and commit</li>
|
|
114
|
+
</ol>
|
|
115
|
+
</Prose>
|
|
116
|
+
),
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export const WithBlockquote: Story = {
|
|
120
|
+
render: () => (
|
|
121
|
+
<Prose className="max-w-prose">
|
|
122
|
+
<p>
|
|
123
|
+
Seo-yun Park wrote the team’s first token pipeline, and her
|
|
124
|
+
review note became the working rule for every new primitive:
|
|
125
|
+
</p>
|
|
126
|
+
<blockquote>
|
|
127
|
+
<p>
|
|
128
|
+
If a primitive needs a paragraph of explanation, the API is wrong.
|
|
129
|
+
</p>
|
|
130
|
+
</blockquote>
|
|
131
|
+
<p>
|
|
132
|
+
The registry enforces the spirit of that rule: at most four
|
|
133
|
+
non-passthrough props before a component must split.
|
|
134
|
+
</p>
|
|
135
|
+
</Prose>
|
|
136
|
+
),
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export const WithTable: Story = {
|
|
140
|
+
render: () => (
|
|
141
|
+
<Prose className="max-w-prose">
|
|
142
|
+
<p>The ROI report reads these costs straight from the registry:</p>
|
|
143
|
+
<table>
|
|
144
|
+
<thead>
|
|
145
|
+
<tr>
|
|
146
|
+
<th>Complexity</th>
|
|
147
|
+
<th>Build hours</th>
|
|
148
|
+
<th>Maintenance / yr</th>
|
|
149
|
+
</tr>
|
|
150
|
+
</thead>
|
|
151
|
+
<tbody>
|
|
152
|
+
<tr>
|
|
153
|
+
<td>Primitive</td>
|
|
154
|
+
<td>8</td>
|
|
155
|
+
<td>3</td>
|
|
156
|
+
</tr>
|
|
157
|
+
<tr>
|
|
158
|
+
<td>Composite</td>
|
|
159
|
+
<td>32</td>
|
|
160
|
+
<td>10</td>
|
|
161
|
+
</tr>
|
|
162
|
+
<tr>
|
|
163
|
+
<td>Pattern</td>
|
|
164
|
+
<td>80</td>
|
|
165
|
+
<td>16</td>
|
|
166
|
+
</tr>
|
|
167
|
+
</tbody>
|
|
168
|
+
</table>
|
|
169
|
+
<p>
|
|
170
|
+
Client savings to date: $182,450 across active forks, with 1,432
|
|
171
|
+
build hours avoided.
|
|
172
|
+
</p>
|
|
173
|
+
</Prose>
|
|
174
|
+
),
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// asChild swaps the wrapper <div> for the child element, so the landmark
|
|
178
|
+
// is the consumer's choice — here a semantic <article>.
|
|
179
|
+
export const AsChild_Usage: Story = {
|
|
180
|
+
render: () => (
|
|
181
|
+
<Prose asChild className="max-w-prose">
|
|
182
|
+
<article aria-label="Release notes">
|
|
183
|
+
<h2>Release notes — 2026-05-26</h2>
|
|
184
|
+
<p>
|
|
185
|
+
This release adds three primitives to the registry and tightens the
|
|
186
|
+
focus-ring offset to 2px across every interactive component.
|
|
187
|
+
</p>
|
|
188
|
+
</article>
|
|
189
|
+
</Prose>
|
|
190
|
+
),
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export const RealisticUse: Story = {
|
|
194
|
+
render: () => (
|
|
195
|
+
<Card className="w-[560px]">
|
|
196
|
+
<CardContent className="pt-6">
|
|
197
|
+
<Prose>
|
|
198
|
+
<h2>Adoption review, 2026-05-26</h2>
|
|
199
|
+
<p>
|
|
200
|
+
36 components, all passing AAA contrast. Last token change was 3
|
|
201
|
+
days ago. Story coverage is at 98.4%. Read the full audit at{" "}
|
|
202
|
+
<a href="https://design.bads.com/share/tokens-v2-proposal">
|
|
203
|
+
design.bads.com/share/tokens-v2-proposal
|
|
204
|
+
</a>
|
|
205
|
+
.
|
|
206
|
+
</p>
|
|
207
|
+
<h3>What changed</h3>
|
|
208
|
+
<ul>
|
|
209
|
+
<li>
|
|
210
|
+
Visual regression now runs on every push — Chromatic baselines
|
|
211
|
+
refreshed
|
|
212
|
+
</li>
|
|
213
|
+
<li>
|
|
214
|
+
The orphan-token sweep scanned 12,417 references and flagged
|
|
215
|
+
zero unused entries
|
|
216
|
+
</li>
|
|
217
|
+
</ul>
|
|
218
|
+
<blockquote>
|
|
219
|
+
<p>
|
|
220
|
+
Jordan reads component source before adopting anything, and
|
|
221
|
+
will absolutely bounce a PR for a hardcoded hex value.
|
|
222
|
+
</p>
|
|
223
|
+
</blockquote>
|
|
224
|
+
<p>
|
|
225
|
+
Next check-in lands after the <code>tokens-v2</code> proposal
|
|
226
|
+
review with the Austin design systems team.
|
|
227
|
+
</p>
|
|
228
|
+
</Prose>
|
|
229
|
+
</CardContent>
|
|
230
|
+
</Card>
|
|
231
|
+
),
|
|
232
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import { PartyPopper } from "lucide-react"
|
|
3
|
+
|
|
4
|
+
import { Result } from "@behavioral-agentic-design-system/core/components/ui/result"
|
|
5
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Result> = {
|
|
8
|
+
title: "Components/Result",
|
|
9
|
+
component: Result,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: "centered",
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component:
|
|
15
|
+
"Feedback primitive for the outcome of a concluded operation — status icon, title, optional subtitle, optional extra content. Four semantic statuses (success / error / warning / info) drive the default Lucide icon (48px, strokeWidth 1.5) and its token color. Distinct from EmptyState (no data yet) and Sonner (transient toasts). Icon entrance animates via animate-in fade-in zoom-in-50 on var(--duration-base) + var(--ease-spring); reduced-motion safe via the base layer.",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
argTypes: {
|
|
20
|
+
status: {
|
|
21
|
+
control: "select",
|
|
22
|
+
options: ["success", "error", "warning", "info"],
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
control: "select",
|
|
26
|
+
options: ["default", "sm"],
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
}
|
|
30
|
+
export default meta
|
|
31
|
+
type Story = StoryObj<typeof Result>
|
|
32
|
+
|
|
33
|
+
export const Default: Story = {
|
|
34
|
+
args: {
|
|
35
|
+
status: "success",
|
|
36
|
+
title: "Tokens published",
|
|
37
|
+
subtitle:
|
|
38
|
+
"tokens-v2-proposal is live at design.bads.com — every fork picks it up on the next @core bump.",
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const Variant_Success: Story = {
|
|
43
|
+
args: {
|
|
44
|
+
status: "success",
|
|
45
|
+
title: "Payment received",
|
|
46
|
+
subtitle: "We charged $249.00 to the card ending 4187. A receipt is on its way to jordan@reeves.design.",
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const Variant_Error: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
status: "error",
|
|
53
|
+
title: "Token sync failed",
|
|
54
|
+
subtitle:
|
|
55
|
+
"The build could not reach design.bads.com. Your local tokens.json is unchanged — nothing was overwritten.",
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const Variant_Warning: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
status: "warning",
|
|
62
|
+
title: "Contrast below AAA",
|
|
63
|
+
subtitle:
|
|
64
|
+
"3 of 78 token pairs landed under the 7:1 contrast floor. The system published anyway — review before shipping to clients.",
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const Variant_Info: Story = {
|
|
69
|
+
args: {
|
|
70
|
+
status: "info",
|
|
71
|
+
title: "Review pending",
|
|
72
|
+
subtitle:
|
|
73
|
+
"Seo-yun Park was asked to approve the tokens-v2 proposal. You'll be notified when the review lands.",
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const Size_SM: Story = {
|
|
78
|
+
args: {
|
|
79
|
+
status: "success",
|
|
80
|
+
size: "sm",
|
|
81
|
+
title: "Story coverage complete",
|
|
82
|
+
subtitle: "36 components audited — 98.4% story coverage.",
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export const WithSubtitle: Story = {
|
|
87
|
+
args: {
|
|
88
|
+
status: "info",
|
|
89
|
+
title: "Export queued",
|
|
90
|
+
subtitle:
|
|
91
|
+
"The ROI report for Q3 is being generated. Large registries can take up to a minute — we'll email marcus@lindqvist.dev when it's ready.",
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export const WithExtra: Story = {
|
|
96
|
+
render: () => (
|
|
97
|
+
<Result
|
|
98
|
+
status="success"
|
|
99
|
+
title="Fork renamed"
|
|
100
|
+
subtitle="This design system is now Clap Design System. Tokens rebuilt and both CSS files regenerated."
|
|
101
|
+
extra={
|
|
102
|
+
<>
|
|
103
|
+
<Button size="xl">Open the showcase</Button>
|
|
104
|
+
<Button size="xl" variant="outline">
|
|
105
|
+
View commit
|
|
106
|
+
</Button>
|
|
107
|
+
</>
|
|
108
|
+
}
|
|
109
|
+
/>
|
|
110
|
+
),
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const WithCustomIcon: Story = {
|
|
114
|
+
render: () => (
|
|
115
|
+
<Result
|
|
116
|
+
status="success"
|
|
117
|
+
icon={<PartyPopper strokeWidth={1.5} aria-hidden />}
|
|
118
|
+
title="Onboarding complete"
|
|
119
|
+
subtitle="Anika Patel finished all 9 setup steps. The brand layer, tokens, and voice calibration are ready for the first prototype."
|
|
120
|
+
extra={<Button size="xl">Start the first screen</Button>}
|
|
121
|
+
/>
|
|
122
|
+
),
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const RealisticUse: Story = {
|
|
126
|
+
render: () => (
|
|
127
|
+
// Post-checkout confirmation surface — the shape this primitive ships in
|
|
128
|
+
// most often: full-card outcome after an async operation concludes.
|
|
129
|
+
<div className="w-[28rem] max-w-full rounded-lg border border-border bg-card">
|
|
130
|
+
<Result
|
|
131
|
+
status="success"
|
|
132
|
+
title="You're on the Studio plan"
|
|
133
|
+
subtitle="We charged $249.00 to the card ending 4187. Your invoice and a getting-started guide were sent to seoyun.park@figma.com."
|
|
134
|
+
extra={
|
|
135
|
+
<>
|
|
136
|
+
<Button size="xl">Go to dashboard</Button>
|
|
137
|
+
<Button size="xl" variant="ghost">
|
|
138
|
+
Download invoice
|
|
139
|
+
</Button>
|
|
140
|
+
</>
|
|
141
|
+
}
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
),
|
|
145
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { RollingNumber } from "@behavioral-agentic-design-system/core/components/ui/rolling-number";
|
|
4
|
+
import {
|
|
5
|
+
Card,
|
|
6
|
+
CardContent,
|
|
7
|
+
CardHeader,
|
|
8
|
+
CardTitle,
|
|
9
|
+
CardDescription,
|
|
10
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
11
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof RollingNumber> = {
|
|
14
|
+
title: "Components/RollingNumber",
|
|
15
|
+
component: RollingNumber,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered",
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
"Animated digit counter — each digit independently scrolls (odometer/slot-machine style) when the value prop changes. Distinct from FormatNumber (static), Stat (layout), and Timer (live interval). Use for KPI milestones, revenue counters, real-time stats. Token-driven motion: var(--duration-base) + var(--ease-spring). role='status' + aria-label carries the formatted value; role=status implies aria-live='polite' so changes are announced to screen readers. Reduced-motion users see an instant value swap.",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
tags: ["autodocs"],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof meta>;
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
render: () => {
|
|
33
|
+
const [value, setValue] = React.useState(1247);
|
|
34
|
+
return (
|
|
35
|
+
<div className="flex flex-col items-center gap-4">
|
|
36
|
+
<RollingNumber value={value} className="text-4xl font-bold" />
|
|
37
|
+
<div className="flex gap-2">
|
|
38
|
+
<Button
|
|
39
|
+
size="xl"
|
|
40
|
+
variant="outline"
|
|
41
|
+
onClick={() => setValue((v) => Math.max(0, v - 137))}
|
|
42
|
+
>
|
|
43
|
+
−137
|
|
44
|
+
</Button>
|
|
45
|
+
<Button size="xl" onClick={() => setValue((v) => v + 137)}>
|
|
46
|
+
+137
|
|
47
|
+
</Button>
|
|
48
|
+
</div>
|
|
49
|
+
<p className="text-sm text-muted-foreground">
|
|
50
|
+
Each digit column animates independently on value change.
|
|
51
|
+
</p>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const WithPrefix: Story = {
|
|
58
|
+
render: () => {
|
|
59
|
+
const [value, setValue] = React.useState(24819);
|
|
60
|
+
return (
|
|
61
|
+
<div className="flex flex-col items-center gap-4">
|
|
62
|
+
<RollingNumber
|
|
63
|
+
value={value}
|
|
64
|
+
prefix="$"
|
|
65
|
+
thousandSeparator=","
|
|
66
|
+
className="text-3xl font-semibold tabular-nums"
|
|
67
|
+
/>
|
|
68
|
+
<div className="flex gap-2">
|
|
69
|
+
<Button
|
|
70
|
+
size="xl"
|
|
71
|
+
variant="outline"
|
|
72
|
+
onClick={() => setValue((v) => Math.max(0, v - 1000))}
|
|
73
|
+
>
|
|
74
|
+
−$1,000
|
|
75
|
+
</Button>
|
|
76
|
+
<Button size="xl" onClick={() => setValue((v) => v + 1000)}>
|
|
77
|
+
+$1,000
|
|
78
|
+
</Button>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const WithSuffix: Story = {
|
|
86
|
+
render: () => {
|
|
87
|
+
const [value, setValue] = React.useState(87);
|
|
88
|
+
return (
|
|
89
|
+
<div className="flex flex-col items-center gap-4">
|
|
90
|
+
<RollingNumber
|
|
91
|
+
value={value}
|
|
92
|
+
suffix="%"
|
|
93
|
+
decimalScale={1}
|
|
94
|
+
fixedDecimalScale
|
|
95
|
+
className="text-4xl font-bold"
|
|
96
|
+
/>
|
|
97
|
+
<div className="flex gap-2">
|
|
98
|
+
<Button
|
|
99
|
+
size="xl"
|
|
100
|
+
variant="outline"
|
|
101
|
+
onClick={() => setValue((v) => Math.max(0, parseFloat((v - 2.3).toFixed(1))))}
|
|
102
|
+
>
|
|
103
|
+
−2.3
|
|
104
|
+
</Button>
|
|
105
|
+
<Button
|
|
106
|
+
size="xl"
|
|
107
|
+
onClick={() => setValue((v) => Math.min(100, parseFloat((v + 2.3).toFixed(1))))}
|
|
108
|
+
>
|
|
109
|
+
+2.3
|
|
110
|
+
</Button>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const WithDecimals: Story = {
|
|
118
|
+
render: () => {
|
|
119
|
+
const [value, setValue] = React.useState(3.14159);
|
|
120
|
+
return (
|
|
121
|
+
<div className="flex flex-col items-center gap-4">
|
|
122
|
+
<RollingNumber
|
|
123
|
+
value={value}
|
|
124
|
+
decimalScale={2}
|
|
125
|
+
fixedDecimalScale
|
|
126
|
+
prefix="π ≈ "
|
|
127
|
+
className="text-3xl font-mono"
|
|
128
|
+
/>
|
|
129
|
+
<div className="flex gap-2">
|
|
130
|
+
<Button
|
|
131
|
+
size="xl"
|
|
132
|
+
variant="outline"
|
|
133
|
+
onClick={() => setValue((v) => parseFloat((v - 0.37).toFixed(2)))}
|
|
134
|
+
>
|
|
135
|
+
−0.37
|
|
136
|
+
</Button>
|
|
137
|
+
<Button
|
|
138
|
+
size="xl"
|
|
139
|
+
onClick={() => setValue((v) => parseFloat((v + 0.37).toFixed(2)))}
|
|
140
|
+
>
|
|
141
|
+
+0.37
|
|
142
|
+
</Button>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const RealisticUse: Story = {
|
|
150
|
+
render: () => {
|
|
151
|
+
const [revenue, setRevenue] = React.useState(142830);
|
|
152
|
+
const [users, setUsers] = React.useState(8471);
|
|
153
|
+
const [rate, setRate] = React.useState(94);
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<div className="w-full max-w-2xl space-y-4">
|
|
157
|
+
<div className="grid grid-cols-3 gap-4">
|
|
158
|
+
<Card>
|
|
159
|
+
<CardHeader className="pb-2">
|
|
160
|
+
<CardDescription>Monthly Revenue</CardDescription>
|
|
161
|
+
</CardHeader>
|
|
162
|
+
<CardContent>
|
|
163
|
+
<RollingNumber
|
|
164
|
+
value={revenue}
|
|
165
|
+
prefix="$"
|
|
166
|
+
thousandSeparator=","
|
|
167
|
+
className="text-2xl font-bold"
|
|
168
|
+
/>
|
|
169
|
+
</CardContent>
|
|
170
|
+
</Card>
|
|
171
|
+
<Card>
|
|
172
|
+
<CardHeader className="pb-2">
|
|
173
|
+
<CardDescription>Active Users</CardDescription>
|
|
174
|
+
</CardHeader>
|
|
175
|
+
<CardContent>
|
|
176
|
+
<RollingNumber
|
|
177
|
+
value={users}
|
|
178
|
+
thousandSeparator=","
|
|
179
|
+
className="text-2xl font-bold"
|
|
180
|
+
/>
|
|
181
|
+
</CardContent>
|
|
182
|
+
</Card>
|
|
183
|
+
<Card>
|
|
184
|
+
<CardHeader className="pb-2">
|
|
185
|
+
<CardDescription>Uptime</CardDescription>
|
|
186
|
+
</CardHeader>
|
|
187
|
+
<CardContent>
|
|
188
|
+
<RollingNumber
|
|
189
|
+
value={rate}
|
|
190
|
+
suffix="%"
|
|
191
|
+
decimalScale={1}
|
|
192
|
+
fixedDecimalScale
|
|
193
|
+
className="text-2xl font-bold"
|
|
194
|
+
/>
|
|
195
|
+
</CardContent>
|
|
196
|
+
</Card>
|
|
197
|
+
</div>
|
|
198
|
+
<div className="flex gap-2">
|
|
199
|
+
<Button
|
|
200
|
+
size="xl"
|
|
201
|
+
variant="outline"
|
|
202
|
+
className="flex-1"
|
|
203
|
+
onClick={() => {
|
|
204
|
+
setRevenue((v) => v + Math.floor(Math.random() * 5000) + 500);
|
|
205
|
+
setUsers((v) => v + Math.floor(Math.random() * 50) + 10);
|
|
206
|
+
setRate((v) => Math.min(99.9, parseFloat((v + 0.1).toFixed(1))));
|
|
207
|
+
}}
|
|
208
|
+
>
|
|
209
|
+
Simulate update
|
|
210
|
+
</Button>
|
|
211
|
+
<Button
|
|
212
|
+
size="xl"
|
|
213
|
+
variant="ghost"
|
|
214
|
+
onClick={() => {
|
|
215
|
+
setRevenue(142830);
|
|
216
|
+
setUsers(8471);
|
|
217
|
+
setRate(94);
|
|
218
|
+
}}
|
|
219
|
+
>
|
|
220
|
+
Reset
|
|
221
|
+
</Button>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
);
|
|
225
|
+
},
|
|
226
|
+
};
|