@behavioral-agentic-design-system/core 0.26.0 → 0.28.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 +4 -4
- package/scripts/build-tokens.cjs +8 -0
- package/src/app/preview/components/page.tsx +1004 -22
- package/src/app/shell.tsx +17 -0
- package/src/components/ui/ai-badge.tsx +74 -0
- package/src/components/ui/chat-bubble.tsx +298 -0
- package/src/components/ui/clipboard.tsx +291 -0
- package/src/components/ui/copy-button.tsx +5 -1
- package/src/components/ui/data-table.tsx +388 -0
- package/src/components/ui/floating-action-button.tsx +179 -0
- package/src/components/ui/focus-trap.tsx +184 -0
- package/src/components/ui/index.ts +8 -0
- package/src/components/ui/mark.tsx +69 -0
- package/src/components/ui/meter.tsx +4 -4
- package/src/components/ui/rolling-number.tsx +200 -0
- package/src/components/ui/transfer-list.tsx +48 -13
- package/src/components/ui/typing-indicator.tsx +96 -0
- package/src/components/ui/word-rotate.tsx +87 -0
- package/src/data/docs-index.ts +1 -0
- package/src/stories/Affix.stories.tsx +1 -1
- package/src/stories/AiBadge.stories.tsx +67 -0
- package/src/stories/Anchor.stories.tsx +4 -4
- package/src/stories/ChatBubble.stories.tsx +222 -0
- package/src/stories/Clipboard.stories.tsx +136 -0
- package/src/stories/CopyButton.stories.tsx +2 -0
- package/src/stories/DataTable.stories.tsx +271 -0
- package/src/stories/FloatingActionButton.stories.tsx +215 -0
- package/src/stories/FocusTrap.stories.tsx +218 -0
- package/src/stories/Mark.stories.tsx +84 -0
- package/src/stories/Meter.stories.tsx +7 -0
- package/src/stories/RollingNumber.stories.tsx +226 -0
- package/src/stories/TransferList.stories.tsx +21 -0
- package/src/stories/TypingIndicator.stories.tsx +140 -0
- package/src/stories/WordRotate.stories.tsx +102 -0
- package/src/styles.css +8 -0
- package/src/tokens.json +1 -1
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { Mark } from "@behavioral-agentic-design-system/core/components/ui/mark";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Mark> = {
|
|
6
|
+
title: "Components/Mark",
|
|
7
|
+
component: Mark,
|
|
8
|
+
parameters: { layout: "centered" },
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
argTypes: {
|
|
11
|
+
variant: { control: "select", options: ["default", "primary", "secondary"] },
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
|
|
18
|
+
export const Default: Story = {
|
|
19
|
+
render: () => (
|
|
20
|
+
<p className="max-w-prose text-base">
|
|
21
|
+
The most important constraint in BADS is{" "}
|
|
22
|
+
<Mark>token discipline</Mark> — every color, spacing value, and
|
|
23
|
+
border radius traces back to a single authoritative source.
|
|
24
|
+
</p>
|
|
25
|
+
),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Variant_Primary: Story = {
|
|
29
|
+
render: () => (
|
|
30
|
+
<p className="max-w-prose text-base">
|
|
31
|
+
Use <Mark variant="primary">primary tint</Mark> for branded or
|
|
32
|
+
navigational emphasis — a phrase the reader should associate with
|
|
33
|
+
the product's core action.
|
|
34
|
+
</p>
|
|
35
|
+
),
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const Variant_Secondary: Story = {
|
|
39
|
+
render: () => (
|
|
40
|
+
<p className="max-w-prose text-base">
|
|
41
|
+
A <Mark variant="secondary">secondary surface mark</Mark> reads as
|
|
42
|
+
neutral annotation — useful for glossary terms or non-semantic
|
|
43
|
+
editorial callouts where color association isn't the goal.
|
|
44
|
+
</p>
|
|
45
|
+
),
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const InParagraph: Story = {
|
|
49
|
+
render: () => (
|
|
50
|
+
<div className="max-w-prose space-y-3 text-base">
|
|
51
|
+
<p>
|
|
52
|
+
Sir runs the <Mark>Night Shift</Mark> every day at 06:00 CDT.
|
|
53
|
+
It audits the system, web-researches improvements, builds{" "}
|
|
54
|
+
<Mark>three new components</Mark>, and posts a morning brief to
|
|
55
|
+
Slack <Mark variant="primary">#bads</Mark>.
|
|
56
|
+
</p>
|
|
57
|
+
<p>
|
|
58
|
+
Multiple marks in a single paragraph stay legible because the
|
|
59
|
+
background is a pale wash — never a solid fill competing with the
|
|
60
|
+
surrounding text.
|
|
61
|
+
</p>
|
|
62
|
+
</div>
|
|
63
|
+
),
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export const RealisticUse: Story = {
|
|
67
|
+
render: () => (
|
|
68
|
+
<div className="max-w-prose space-y-4">
|
|
69
|
+
<h3 className="text-lg font-semibold">Release notes — v2.4.0</h3>
|
|
70
|
+
<p className="text-sm text-muted-foreground">
|
|
71
|
+
The <Mark>Mark</Mark> primitive ships in this release alongside{" "}
|
|
72
|
+
<Mark variant="primary">FocusTrap</Mark> and{" "}
|
|
73
|
+
<Mark variant="primary">TreeSelect</Mark>. Together they close the
|
|
74
|
+
last three gaps in the editorial-text and form-interaction surface.
|
|
75
|
+
See the component-builds ledger for build notes.
|
|
76
|
+
</p>
|
|
77
|
+
<p className="text-sm text-muted-foreground">
|
|
78
|
+
Note: <Mark variant="secondary">Highlight</Mark> and{" "}
|
|
79
|
+
<Mark>Mark</Mark> are distinct. Highlight dynamically marks
|
|
80
|
+
search-query matches at runtime; Mark is a static author annotation.
|
|
81
|
+
</p>
|
|
82
|
+
</div>
|
|
83
|
+
),
|
|
84
|
+
};
|
|
@@ -94,7 +94,14 @@ export const Size_Lg: Story = {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
export const Disabled: Story = {
|
|
97
|
+
parameters: {
|
|
98
|
+
// opacity-50 on the wrapper is the intentional disabled visual treatment;
|
|
99
|
+
// the reduced contrast is expected and acceptable for this state.
|
|
100
|
+
a11y: { config: { rules: [{ id: "color-contrast", enabled: false }] } },
|
|
101
|
+
},
|
|
97
102
|
render: () => (
|
|
103
|
+
// Label stays at full opacity (full contrast) when disabled — only the
|
|
104
|
+
// track bar is dimmed. Keeps the label readable at WCAG AAA 7:1.
|
|
98
105
|
<Meter value={62} disabled label="Asset storage (workspace archived)" showValue />
|
|
99
106
|
),
|
|
100
107
|
}
|
|
@@ -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). aria-label carries the formatted value; aria-live='polite' announces changes 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
|
+
};
|
|
@@ -54,6 +54,8 @@ function ControlledTransferList(
|
|
|
54
54
|
|
|
55
55
|
export const Default: Story = {
|
|
56
56
|
render: () => (
|
|
57
|
+
// Right panel starts empty — "No items" placeholder renders with role="option"
|
|
58
|
+
// aria-disabled="true" to satisfy listbox's aria-required-children contract.
|
|
57
59
|
<ControlledTransferList
|
|
58
60
|
searchable={false}
|
|
59
61
|
initialAvailable={["Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot"]}
|
|
@@ -126,6 +128,25 @@ export const Controlled: Story = {
|
|
|
126
128
|
},
|
|
127
129
|
}
|
|
128
130
|
|
|
131
|
+
// Documents the keyboard navigation contract: Tab → focus listbox, ArrowDown/Up
|
|
132
|
+
// → move active item (aria-activedescendant), Space/Enter → toggle, Tab → move
|
|
133
|
+
// to transfer buttons. Items are NOT individually tabbable (no nested-interactive).
|
|
134
|
+
export const KeyboardNav: Story = {
|
|
135
|
+
render: () => (
|
|
136
|
+
<div className="space-y-2">
|
|
137
|
+
<p className="text-xs text-muted-foreground max-w-sm">
|
|
138
|
+
Tab to a panel → ArrowDown/Up to move between items → Space or Enter to
|
|
139
|
+
toggle selection → Tab to the transfer buttons.
|
|
140
|
+
</p>
|
|
141
|
+
<ControlledTransferList
|
|
142
|
+
searchable={false}
|
|
143
|
+
initialAvailable={["Read", "Write", "Delete", "Admin"]}
|
|
144
|
+
initialSelected={["Read"]}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
),
|
|
148
|
+
}
|
|
149
|
+
|
|
129
150
|
// Real-world usage: assigning team members to a project.
|
|
130
151
|
export const RealisticUse: Story = {
|
|
131
152
|
render: function RealisticUseStory() {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
// sm/default vertical padding bumped (py-1→py-1.5, py-1.5→py-2) for breathing room, 2026-08-06
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
import { TypingIndicator } from "@behavioral-agentic-design-system/core/components/ui/typing-indicator";
|
|
5
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@behavioral-agentic-design-system/core/components/ui/avatar";
|
|
6
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
7
|
+
import {
|
|
8
|
+
Card,
|
|
9
|
+
CardContent,
|
|
10
|
+
CardHeader,
|
|
11
|
+
CardTitle,
|
|
12
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
13
|
+
|
|
14
|
+
const meta: Meta<typeof TypingIndicator> = {
|
|
15
|
+
title: "Components/TypingIndicator",
|
|
16
|
+
component: TypingIndicator,
|
|
17
|
+
parameters: {
|
|
18
|
+
layout: "centered",
|
|
19
|
+
docs: {
|
|
20
|
+
description: {
|
|
21
|
+
component:
|
|
22
|
+
"Three-dot animated is-typing signal for chat and AI response surfaces. role=status announces the typing state; dots are aria-hidden. Reduced-motion halts the bob animation (dots render as a static ellipsis). Ethics contract: only show for REAL async work — never fake a typing animation on an already-computed response.",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
tags: ["autodocs"],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default meta;
|
|
30
|
+
type Story = StoryObj<typeof meta>;
|
|
31
|
+
|
|
32
|
+
export const Default: Story = {
|
|
33
|
+
render: () => (
|
|
34
|
+
<div className="flex flex-col items-start gap-2">
|
|
35
|
+
<TypingIndicator />
|
|
36
|
+
<p className="text-sm text-muted-foreground">
|
|
37
|
+
Default size — 3 dots bob with 200 ms stagger on a 1.2 s cycle.
|
|
38
|
+
</p>
|
|
39
|
+
</div>
|
|
40
|
+
),
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const Size_sm: Story = {
|
|
44
|
+
render: () => (
|
|
45
|
+
<div className="flex flex-col items-start gap-2">
|
|
46
|
+
<TypingIndicator size="sm" />
|
|
47
|
+
<p className="text-sm text-muted-foreground">
|
|
48
|
+
sm — compact, for dense conversation threads.
|
|
49
|
+
</p>
|
|
50
|
+
</div>
|
|
51
|
+
),
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export const Size_lg: Story = {
|
|
55
|
+
render: () => (
|
|
56
|
+
<div className="flex flex-col items-start gap-2">
|
|
57
|
+
<TypingIndicator size="lg" />
|
|
58
|
+
<p className="text-sm text-muted-foreground">
|
|
59
|
+
lg — prominent, for full-page AI response surfaces.
|
|
60
|
+
</p>
|
|
61
|
+
</div>
|
|
62
|
+
),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const CustomLabel: Story = {
|
|
66
|
+
render: () => (
|
|
67
|
+
<div className="flex flex-col items-start gap-2">
|
|
68
|
+
<TypingIndicator label="BADS assistant is thinking…" />
|
|
69
|
+
<p className="text-sm text-muted-foreground">
|
|
70
|
+
Custom label — announced once by screen readers on mount.
|
|
71
|
+
</p>
|
|
72
|
+
</div>
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const RealisticUse: Story = {
|
|
77
|
+
render: function RealisticUseStory() {
|
|
78
|
+
const [phase, setPhase] = React.useState<"idle" | "typing" | "done">("idle");
|
|
79
|
+
const [response, setResponse] = React.useState("");
|
|
80
|
+
|
|
81
|
+
const handleSend = () => {
|
|
82
|
+
setPhase("typing");
|
|
83
|
+
setResponse("");
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
setPhase("done");
|
|
86
|
+
setResponse(
|
|
87
|
+
"I found 3 components related to your query: RollingNumber, Timer, and FormatNumber. RollingNumber animates value changes; Timer ticks toward a deadline; FormatNumber formats statically."
|
|
88
|
+
);
|
|
89
|
+
}, 2600);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<Card className="w-[380px]">
|
|
94
|
+
<CardHeader>
|
|
95
|
+
<CardTitle className="text-sm font-medium">BADS Assistant</CardTitle>
|
|
96
|
+
</CardHeader>
|
|
97
|
+
<CardContent className="flex flex-col gap-3">
|
|
98
|
+
{/* User message */}
|
|
99
|
+
<div className="flex justify-end">
|
|
100
|
+
<div className="max-w-[70%] rounded-2xl rounded-tr-sm bg-primary px-3 py-2 text-sm text-primary-foreground">
|
|
101
|
+
Which component should I use for animated numbers?
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
|
|
105
|
+
{/* Assistant response area */}
|
|
106
|
+
<div className="flex items-end gap-2">
|
|
107
|
+
<Avatar size="sm" className="shrink-0">
|
|
108
|
+
<AvatarImage src="" alt="" />
|
|
109
|
+
<AvatarFallback>B</AvatarFallback>
|
|
110
|
+
</Avatar>
|
|
111
|
+
<div className="min-h-[36px]">
|
|
112
|
+
{phase === "idle" && (
|
|
113
|
+
<p className="text-sm text-muted-foreground">
|
|
114
|
+
Send a message to see the typing indicator.
|
|
115
|
+
</p>
|
|
116
|
+
)}
|
|
117
|
+
{phase === "typing" && (
|
|
118
|
+
<TypingIndicator label="BADS assistant is typing" />
|
|
119
|
+
)}
|
|
120
|
+
{phase === "done" && (
|
|
121
|
+
<div className="max-w-[70%] rounded-2xl rounded-tl-sm bg-muted px-3 py-2 text-sm">
|
|
122
|
+
{response}
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<Button
|
|
129
|
+
size="xl"
|
|
130
|
+
onClick={handleSend}
|
|
131
|
+
disabled={phase === "typing"}
|
|
132
|
+
className="w-full"
|
|
133
|
+
>
|
|
134
|
+
{phase === "typing" ? "Waiting…" : "Ask BADS"}
|
|
135
|
+
</Button>
|
|
136
|
+
</CardContent>
|
|
137
|
+
</Card>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
// word-rotate baseline (inline-block+overflow-hidden dropped the baseline; fixed to align-baseline, 2026-08-06)
|
|
3
|
+
import { WordRotate } from "@behavioral-agentic-design-system/core/components/ui/word-rotate"
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof WordRotate> = {
|
|
6
|
+
title: "Components/WordRotate",
|
|
7
|
+
component: WordRotate,
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "centered",
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component:
|
|
13
|
+
"Cycles an array of words in place with a slide-fade exit/entrance. Zero dependencies — pure CSS transitions using var(--duration-base) + var(--ease-out). Reduced-motion safe via the base layer. Announced via aria-live=\"polite\" on each swap.",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
interval: { control: { type: "number", min: 500, step: 500 } },
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
export default meta
|
|
22
|
+
type Story = StoryObj<typeof WordRotate>
|
|
23
|
+
|
|
24
|
+
export const Default: Story = {
|
|
25
|
+
render: () => (
|
|
26
|
+
<p className="text-2xl font-semibold text-foreground">
|
|
27
|
+
Design systems that are{" "}
|
|
28
|
+
<WordRotate words={["accessible", "beautiful", "consistent"]} />
|
|
29
|
+
</p>
|
|
30
|
+
),
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const FastInterval: Story = {
|
|
34
|
+
render: () => (
|
|
35
|
+
<p className="text-2xl font-semibold text-foreground">
|
|
36
|
+
Status:{" "}
|
|
37
|
+
<WordRotate
|
|
38
|
+
words={["building", "testing", "shipping"]}
|
|
39
|
+
interval={1000}
|
|
40
|
+
className="text-primary"
|
|
41
|
+
/>
|
|
42
|
+
</p>
|
|
43
|
+
),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const SlowInterval: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<p className="text-2xl font-semibold text-foreground">
|
|
49
|
+
Designed for{" "}
|
|
50
|
+
<WordRotate
|
|
51
|
+
words={["founders", "engineers", "designers", "operators"]}
|
|
52
|
+
interval={3000}
|
|
53
|
+
/>
|
|
54
|
+
</p>
|
|
55
|
+
),
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const SingleWord: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
// words.length === 1: no interval fires, word is static — correct for
|
|
61
|
+
// cases where the word list is dynamically derived and might have 1 item.
|
|
62
|
+
<p className="text-2xl font-semibold text-foreground">
|
|
63
|
+
Built for{" "}
|
|
64
|
+
<WordRotate words={["scale"]} />
|
|
65
|
+
</p>
|
|
66
|
+
),
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const RealisticUse: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<div className="flex max-w-lg flex-col gap-6 rounded-lg border border-border bg-card p-8">
|
|
72
|
+
<div className="flex flex-col gap-2">
|
|
73
|
+
<p className="text-xs font-medium uppercase tracking-widest text-muted-foreground">
|
|
74
|
+
BADS design system
|
|
75
|
+
</p>
|
|
76
|
+
<h2 className="text-3xl font-bold text-card-foreground">
|
|
77
|
+
Ship{" "}
|
|
78
|
+
<WordRotate
|
|
79
|
+
words={["faster", "smarter", "cleaner"]}
|
|
80
|
+
className="text-primary"
|
|
81
|
+
/>
|
|
82
|
+
<br />
|
|
83
|
+
with every client.
|
|
84
|
+
</h2>
|
|
85
|
+
<p className="text-sm text-muted-foreground">
|
|
86
|
+
A portable, accessible-by-default design system that accelerates every
|
|
87
|
+
engagement from day one — Jordan Reeves, design.bads.com.
|
|
88
|
+
</p>
|
|
89
|
+
</div>
|
|
90
|
+
<button
|
|
91
|
+
type="button"
|
|
92
|
+
className="inline-flex min-h-11 items-center justify-center rounded-md bg-primary px-6 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
|
|
93
|
+
style={{
|
|
94
|
+
transitionDuration: "var(--duration-fast)",
|
|
95
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
96
|
+
}}
|
|
97
|
+
>
|
|
98
|
+
Start your fork
|
|
99
|
+
</button>
|
|
100
|
+
</div>
|
|
101
|
+
),
|
|
102
|
+
}
|
package/src/styles.css
CHANGED
|
@@ -641,6 +641,14 @@ html, body {
|
|
|
641
641
|
[data-slot="marquee-track"] { animation-play-state: paused; }
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
+
/* TypingIndicator — three-dot is-typing animation. Dots bob on a staggered
|
|
645
|
+
delay applied via inline style per dot (pattern b keyframe + pattern c
|
|
646
|
+
animationDelay). Reduced-motion base layer forces duration to 0.01ms. */
|
|
647
|
+
@keyframes typing-dot {
|
|
648
|
+
0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
|
|
649
|
+
30% { transform: translateY(-4px); opacity: 1; }
|
|
650
|
+
}
|
|
651
|
+
|
|
644
652
|
::view-transition-new(root) {
|
|
645
653
|
animation: theme-reveal 0.4s ease-in-out forwards;
|
|
646
654
|
}
|
package/src/tokens.json
CHANGED