@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,87 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
export interface WordRotateProps {
|
|
7
|
+
/** Words to cycle through. Needs at least 2 to animate. */
|
|
8
|
+
words: string[]
|
|
9
|
+
/**
|
|
10
|
+
* Milliseconds each word is shown before transitioning.
|
|
11
|
+
* Default: 2000 (2 s).
|
|
12
|
+
*/
|
|
13
|
+
interval?: number
|
|
14
|
+
/** Extra className on the outer inline wrapper. */
|
|
15
|
+
className?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* WordRotate — cycles an array of words in place with a slide-fade exit/entrance.
|
|
20
|
+
* Zero dependencies; uses CSS transitions with token-driven duration/easing.
|
|
21
|
+
*
|
|
22
|
+
* Motion: current word slides up + fades out, next word slides in from below +
|
|
23
|
+
* fades in. Transition duration is var(--duration-base); easing is var(--ease-out).
|
|
24
|
+
* Reduced-motion: the base layer collapses all transitions to 0.01 ms.
|
|
25
|
+
*
|
|
26
|
+
* Accessibility: outer span carries aria-live="polite" + aria-atomic="true" so
|
|
27
|
+
* the current word is announced on each swap. The animated span is aria-hidden;
|
|
28
|
+
* a sr-only span carries the live-region text.
|
|
29
|
+
*/
|
|
30
|
+
function WordRotate({
|
|
31
|
+
words,
|
|
32
|
+
interval = 2000,
|
|
33
|
+
className,
|
|
34
|
+
}: WordRotateProps) {
|
|
35
|
+
const [index, setIndex] = React.useState(0)
|
|
36
|
+
const [visible, setVisible] = React.useState(true)
|
|
37
|
+
|
|
38
|
+
React.useEffect(() => {
|
|
39
|
+
if (words.length <= 1) return
|
|
40
|
+
let swapId: ReturnType<typeof setTimeout>
|
|
41
|
+
const id = setInterval(() => {
|
|
42
|
+
// Phase 1: exit current word
|
|
43
|
+
setVisible(false)
|
|
44
|
+
// Phase 2: swap word + enter — timed to match transition-duration
|
|
45
|
+
swapId = setTimeout(() => {
|
|
46
|
+
setIndex((i) => (i + 1) % words.length)
|
|
47
|
+
setVisible(true)
|
|
48
|
+
}, 200)
|
|
49
|
+
}, interval)
|
|
50
|
+
return () => {
|
|
51
|
+
clearInterval(id)
|
|
52
|
+
clearTimeout(swapId)
|
|
53
|
+
}
|
|
54
|
+
}, [words.length, interval])
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<span
|
|
58
|
+
data-slot="word-rotate"
|
|
59
|
+
aria-live="polite"
|
|
60
|
+
aria-atomic="true"
|
|
61
|
+
// inline-block + overflow-hidden would drop the box's baseline to its
|
|
62
|
+
// bottom edge (a CSS quirk), floating the rotating word ABOVE the
|
|
63
|
+
// surrounding text. Keep overflow visible and pin vertical-align to the
|
|
64
|
+
// text baseline so the word sits on the same line as its neighbours. The
|
|
65
|
+
// slide is a small translateY + fade, so the brief overflow is invisible.
|
|
66
|
+
className={cn("inline-block align-baseline", className)}
|
|
67
|
+
>
|
|
68
|
+
{/* Visual word — aria-hidden because sr-only below carries the live region */}
|
|
69
|
+
<span
|
|
70
|
+
aria-hidden="true"
|
|
71
|
+
className="inline-block transition-[opacity,transform]"
|
|
72
|
+
style={{
|
|
73
|
+
opacity: visible ? 1 : 0,
|
|
74
|
+
transform: visible ? "translateY(0)" : "translateY(-30%)",
|
|
75
|
+
transitionDuration: "var(--duration-base)",
|
|
76
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{words[index]}
|
|
80
|
+
</span>
|
|
81
|
+
{/* Screen reader always gets the current word via the live region */}
|
|
82
|
+
<span className="sr-only">{words[index]}</span>
|
|
83
|
+
</span>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { WordRotate }
|
package/src/data/docs-index.ts
CHANGED
|
@@ -91,6 +91,7 @@ export const DOCS_INDEX: DocGroup[] = [
|
|
|
91
91
|
{ title: "Skill — promote-prototype", path: ".claude/skills/promote-prototype/SKILL.md" },
|
|
92
92
|
{ title: "Skill — visual-verify", path: ".claude/skills/visual-verify/SKILL.md" },
|
|
93
93
|
{ title: "Prompt — conceptual model", path: "prompts/conceptual-model.md", summary: "Before sketching a product surface, name its domain objects, states, relationships, and vocabulary — Jamie Mill's 'most neglected layer,' wired into Path B as design-exploration step 3.5. Feeds the real-content pool, state patterns, and primitive selection." },
|
|
94
|
+
{ title: "Prompt — parallel rollout", path: "prompts/parallel-rollout.md", summary: "For a Path B build that's N similar surfaces: build one reference screen, turn it into an explicit contract, sign off on the contract, then fan the rest out against it (via Workflow) and verify each to the contract. Stops multi-screen drift. Adapted from the design-spec-framework." },
|
|
94
95
|
{ title: "Prompt — design directions", path: "prompts/design-directions.md" },
|
|
95
96
|
{ title: "Prompt — design critique", path: "prompts/design-critique.md" },
|
|
96
97
|
{ title: "Prompt — independent critique", path: "prompts/independent-critique.md" },
|
|
@@ -129,7 +129,7 @@ export const RealisticUse: Story = {
|
|
|
129
129
|
const scrollRef = React.useRef<HTMLDivElement>(null);
|
|
130
130
|
return (
|
|
131
131
|
<div className="relative h-72 w-[420px] overflow-hidden rounded-lg border border-border bg-card [transform:translateZ(0)]">
|
|
132
|
-
<div ref={scrollRef} className="h-full overflow-y-auto p-4">
|
|
132
|
+
<div ref={scrollRef} className="h-full overflow-y-auto p-4" tabIndex={0}>
|
|
133
133
|
<h3 className="text-base font-semibold text-foreground">
|
|
134
134
|
Design system changelog
|
|
135
135
|
</h3>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { AiBadge } from "@behavioral-agentic-design-system/core/components/ui/ai-badge";
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof AiBadge> = {
|
|
5
|
+
title: "Components/AiBadge",
|
|
6
|
+
component: AiBadge,
|
|
7
|
+
parameters: { layout: "centered" },
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
render: () => (
|
|
16
|
+
<div className="flex items-center gap-2">
|
|
17
|
+
<AiBadge />
|
|
18
|
+
<AiBadge variant="solid" />
|
|
19
|
+
<AiBadge variant="outline" />
|
|
20
|
+
</div>
|
|
21
|
+
),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Variant_Subtle: Story = {
|
|
25
|
+
render: () => <AiBadge variant="subtle" />,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Variant_Solid: Story = {
|
|
29
|
+
render: () => <AiBadge variant="solid" />,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const Variant_Outline: Story = {
|
|
33
|
+
render: () => <AiBadge variant="outline" />,
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Size_Sm: Story = {
|
|
37
|
+
render: () => <AiBadge size="sm" />,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const Size_Default: Story = {
|
|
41
|
+
render: () => <AiBadge size="default" />,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const NoIcon: Story = {
|
|
45
|
+
render: () => <AiBadge showIcon={false} />,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export const CustomLabel: Story = {
|
|
49
|
+
render: () => <AiBadge>AI summary</AiBadge>,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const RealisticUse: Story = {
|
|
53
|
+
render: () => (
|
|
54
|
+
<div className="max-w-sm space-y-2 rounded-lg border border-border bg-card p-4">
|
|
55
|
+
<div className="flex items-center gap-2">
|
|
56
|
+
<span className="text-sm font-semibold text-foreground">
|
|
57
|
+
Weekly recap
|
|
58
|
+
</span>
|
|
59
|
+
<AiBadge size="sm" />
|
|
60
|
+
</div>
|
|
61
|
+
<p className="text-sm text-muted-foreground">
|
|
62
|
+
Deploys were up 18% this week, with the mail service accounting for most
|
|
63
|
+
of the increase. No incidents were reported.
|
|
64
|
+
</p>
|
|
65
|
+
</div>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
@@ -35,7 +35,7 @@ function DemoSection({
|
|
|
35
35
|
export const Default: Story = {
|
|
36
36
|
render: () => (
|
|
37
37
|
<div className="flex w-[640px] max-w-full gap-8">
|
|
38
|
-
<div className="h-72 min-w-0 flex-1 overflow-y-auto rounded-lg border border-border p-5">
|
|
38
|
+
<div className="h-72 min-w-0 flex-1 overflow-y-auto rounded-lg border border-border p-5" tabIndex={0}>
|
|
39
39
|
<DemoSection id="anc-default-overview" title="Overview">
|
|
40
40
|
BADS ships tokens, components, and accessibility contracts as one
|
|
41
41
|
portable system. Fork it, rename it, and every client engagement
|
|
@@ -73,7 +73,7 @@ export const Default: Story = {
|
|
|
73
73
|
export const WithGroups: Story = {
|
|
74
74
|
render: () => (
|
|
75
75
|
<div className="flex w-[640px] max-w-full gap-8">
|
|
76
|
-
<div className="h-72 min-w-0 flex-1 overflow-y-auto rounded-lg border border-border p-5">
|
|
76
|
+
<div className="h-72 min-w-0 flex-1 overflow-y-auto rounded-lg border border-border p-5" tabIndex={0}>
|
|
77
77
|
<DemoSection id="anc-groups-foundation" title="Foundation">
|
|
78
78
|
Voice, tone, language, and personas — the layer every piece of copy
|
|
79
79
|
checks against before it ships.
|
|
@@ -152,7 +152,7 @@ export const Sticky: Story = {
|
|
|
152
152
|
export const Customized: Story = {
|
|
153
153
|
render: () => (
|
|
154
154
|
<div className="flex w-[640px] max-w-full gap-8">
|
|
155
|
-
<div className="h-64 min-w-0 flex-1 overflow-y-auto rounded-lg border border-border p-5">
|
|
155
|
+
<div className="h-64 min-w-0 flex-1 overflow-y-auto rounded-lg border border-border p-5" tabIndex={0}>
|
|
156
156
|
<DemoSection id="anc-custom-savings" title="Client savings">
|
|
157
157
|
The ROI report prices what an in-house team would have charged to
|
|
158
158
|
build the system from scratch — $182,450 to date.
|
|
@@ -191,7 +191,7 @@ export const RealisticUse: Story = {
|
|
|
191
191
|
</p>
|
|
192
192
|
</div>
|
|
193
193
|
<div className="flex gap-8">
|
|
194
|
-
<div className="h-80 min-w-0 flex-1 overflow-y-auto pr-2">
|
|
194
|
+
<div className="h-80 min-w-0 flex-1 overflow-y-auto pr-2" tabIndex={0}>
|
|
195
195
|
<DemoSection id="anc-real-fork" title="Fork and rename">
|
|
196
196
|
Every engagement starts by forking BADS and running pnpm rename
|
|
197
197
|
with the client display name and slug. The npm package name stays
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Reply, SmilePlus } from "lucide-react";
|
|
4
|
+
import {
|
|
5
|
+
ChatBubble,
|
|
6
|
+
ChatBubbleAction,
|
|
7
|
+
ChatBubbleActions,
|
|
8
|
+
ChatBubbleAvatar,
|
|
9
|
+
ChatBubbleMessage,
|
|
10
|
+
ChatBubbleReadReceipt,
|
|
11
|
+
ChatBubbleTimestamp,
|
|
12
|
+
} from "@behavioral-agentic-design-system/core/components/ui/chat-bubble";
|
|
13
|
+
|
|
14
|
+
const meta: Meta<typeof ChatBubble> = {
|
|
15
|
+
title: "Components/ChatBubble",
|
|
16
|
+
component: ChatBubble,
|
|
17
|
+
parameters: { layout: "padded" },
|
|
18
|
+
tags: ["autodocs"],
|
|
19
|
+
argTypes: {
|
|
20
|
+
position: { control: "radio", options: ["sent", "received"] },
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default meta;
|
|
25
|
+
type Story = StoryObj<typeof ChatBubble>;
|
|
26
|
+
|
|
27
|
+
// Real content from content/personas/bads.json — primary persona names
|
|
28
|
+
// (Jordan Reeves, Seo-yun Park) and design-system chatter built from the
|
|
29
|
+
// jargon / body_copy / notifications / urls pools. No placeholder content.
|
|
30
|
+
const THREAD = [
|
|
31
|
+
{
|
|
32
|
+
id: 1,
|
|
33
|
+
from: "Seo-yun Park",
|
|
34
|
+
initials: "SP",
|
|
35
|
+
position: "received" as const,
|
|
36
|
+
text: "Just pushed the tokens v2 proposal — can you look before standup? design.bads.com/share/tokens-v2-proposal",
|
|
37
|
+
time: "10:38 AM",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 2,
|
|
41
|
+
from: "Jordan Reeves",
|
|
42
|
+
initials: "JR",
|
|
43
|
+
position: "sent" as const,
|
|
44
|
+
text: "On it. Did the semantic layer change touch --muted-foreground?",
|
|
45
|
+
time: "10:40 AM",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 3,
|
|
49
|
+
from: "Seo-yun Park",
|
|
50
|
+
initials: "SP",
|
|
51
|
+
position: "received" as const,
|
|
52
|
+
text: "Yes — nudged it for the 7:1 floor. All 36 components still pass AAA contrast, wcag:audit is green.",
|
|
53
|
+
time: "10:41 AM",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 4,
|
|
57
|
+
from: "Jordan Reeves",
|
|
58
|
+
initials: "JR",
|
|
59
|
+
position: "sent" as const,
|
|
60
|
+
text: "Token changes saved. Running pnpm build:tokens now — both CSS files regenerate.",
|
|
61
|
+
time: "10:42 AM",
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
export const Default: Story = {
|
|
66
|
+
render: () => (
|
|
67
|
+
<div className="w-full max-w-md">
|
|
68
|
+
<ChatBubble position="received">
|
|
69
|
+
<ChatBubbleMessage>
|
|
70
|
+
Just pushed the tokens v2 proposal — can you look before standup?
|
|
71
|
+
</ChatBubbleMessage>
|
|
72
|
+
</ChatBubble>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const Variant_Sent: Story = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<div className="w-full max-w-md">
|
|
80
|
+
<ChatBubble position="sent">
|
|
81
|
+
<ChatBubbleMessage>
|
|
82
|
+
On it. Did the semantic layer change touch --muted-foreground?
|
|
83
|
+
</ChatBubbleMessage>
|
|
84
|
+
</ChatBubble>
|
|
85
|
+
</div>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const Variant_Received: Story = {
|
|
90
|
+
render: () => (
|
|
91
|
+
<div className="w-full max-w-md">
|
|
92
|
+
<ChatBubble position="received">
|
|
93
|
+
<ChatBubbleMessage variant="received">
|
|
94
|
+
Yes — nudged it for the 7:1 floor. All 36 components still pass AAA
|
|
95
|
+
contrast.
|
|
96
|
+
</ChatBubbleMessage>
|
|
97
|
+
</ChatBubble>
|
|
98
|
+
</div>
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const Variant_Typing: Story = {
|
|
103
|
+
parameters: {
|
|
104
|
+
docs: {
|
|
105
|
+
description: {
|
|
106
|
+
story:
|
|
107
|
+
"Typing indicator — the bubble carries role=status + aria-live=polite + an accessible name (\"Typing…\") because it has no visible text. Only render it while a real participant is actually typing; a fake typing indicator is a dark pattern (see registry antiPatterns).",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
render: () => (
|
|
112
|
+
<div className="w-full max-w-md">
|
|
113
|
+
<ChatBubble position="received">
|
|
114
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
115
|
+
<ChatBubbleMessage variant="typing" />
|
|
116
|
+
</ChatBubble>
|
|
117
|
+
</div>
|
|
118
|
+
),
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const WithAvatar: Story = {
|
|
122
|
+
render: () => (
|
|
123
|
+
<div className="w-full max-w-md">
|
|
124
|
+
<ChatBubble position="received">
|
|
125
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
126
|
+
<ChatBubbleMessage>
|
|
127
|
+
Storybook coverage check passed — all components have matching
|
|
128
|
+
stories.
|
|
129
|
+
</ChatBubbleMessage>
|
|
130
|
+
</ChatBubble>
|
|
131
|
+
</div>
|
|
132
|
+
),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const WithReadReceipt: Story = {
|
|
136
|
+
render: () => (
|
|
137
|
+
<div className="w-full max-w-md space-y-3">
|
|
138
|
+
{(["sent", "delivered", "read"] as const).map((status) => (
|
|
139
|
+
<ChatBubble key={status} position="sent">
|
|
140
|
+
<div className="flex min-w-0 flex-col items-end gap-1">
|
|
141
|
+
<ChatBubbleMessage>
|
|
142
|
+
Token changes saved. Run pnpm build:tokens to regenerate CSS.
|
|
143
|
+
</ChatBubbleMessage>
|
|
144
|
+
<span className="flex items-center gap-1">
|
|
145
|
+
<ChatBubbleTimestamp timestamp="10:42 AM" />
|
|
146
|
+
<ChatBubbleReadReceipt status={status} />
|
|
147
|
+
</span>
|
|
148
|
+
</div>
|
|
149
|
+
</ChatBubble>
|
|
150
|
+
))}
|
|
151
|
+
</div>
|
|
152
|
+
),
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const WithActions: Story = {
|
|
156
|
+
parameters: {
|
|
157
|
+
docs: {
|
|
158
|
+
description: {
|
|
159
|
+
story:
|
|
160
|
+
"Action row is hidden until the row is hovered — or until any action button receives keyboard focus (focus-within), so keyboard users are never locked out of a hover-only affordance. Each action is a 44×44 ghost Button with a required aria-label.",
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
render: () => (
|
|
165
|
+
<div className="w-full max-w-md">
|
|
166
|
+
<ChatBubble position="received">
|
|
167
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
168
|
+
<ChatBubbleMessage>
|
|
169
|
+
The token pipeline paid for itself in a week. One tokens.json change,
|
|
170
|
+
both CSS files regenerate, every fork picks it up.
|
|
171
|
+
</ChatBubbleMessage>
|
|
172
|
+
<ChatBubbleActions>
|
|
173
|
+
<ChatBubbleAction
|
|
174
|
+
icon={<SmilePlus strokeWidth={1.5} className="size-5" />}
|
|
175
|
+
label="React to message"
|
|
176
|
+
/>
|
|
177
|
+
<ChatBubbleAction
|
|
178
|
+
icon={<Reply strokeWidth={1.5} className="size-5" />}
|
|
179
|
+
label="Reply to message"
|
|
180
|
+
/>
|
|
181
|
+
</ChatBubbleActions>
|
|
182
|
+
</ChatBubble>
|
|
183
|
+
</div>
|
|
184
|
+
),
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
export const RealisticUse: Story = {
|
|
188
|
+
render: () => (
|
|
189
|
+
<div
|
|
190
|
+
role="log"
|
|
191
|
+
aria-label="Conversation with Seo-yun Park"
|
|
192
|
+
className="flex w-full max-w-md flex-col gap-3 overflow-y-auto rounded-lg border bg-background p-4"
|
|
193
|
+
>
|
|
194
|
+
{THREAD.map((msg) => (
|
|
195
|
+
<ChatBubble key={msg.id} position={msg.position}>
|
|
196
|
+
{msg.position === "received" ? (
|
|
197
|
+
<ChatBubbleAvatar fallback={msg.initials} />
|
|
198
|
+
) : null}
|
|
199
|
+
<div
|
|
200
|
+
className={
|
|
201
|
+
msg.position === "sent"
|
|
202
|
+
? "flex min-w-0 flex-col items-end gap-1"
|
|
203
|
+
: "flex min-w-0 flex-col items-start gap-1"
|
|
204
|
+
}
|
|
205
|
+
>
|
|
206
|
+
<ChatBubbleMessage>{msg.text}</ChatBubbleMessage>
|
|
207
|
+
<span className="flex items-center gap-1">
|
|
208
|
+
<ChatBubbleTimestamp timestamp={msg.time} />
|
|
209
|
+
{msg.position === "sent" ? (
|
|
210
|
+
<ChatBubbleReadReceipt status={msg.id === 4 ? "delivered" : "read"} />
|
|
211
|
+
) : null}
|
|
212
|
+
</span>
|
|
213
|
+
</div>
|
|
214
|
+
</ChatBubble>
|
|
215
|
+
))}
|
|
216
|
+
<ChatBubble position="received">
|
|
217
|
+
<ChatBubbleAvatar fallback="SP" />
|
|
218
|
+
<ChatBubbleMessage variant="typing" />
|
|
219
|
+
</ChatBubble>
|
|
220
|
+
</div>
|
|
221
|
+
),
|
|
222
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Motion: input copied-tint + focus ring on transition-[color,box-shadow,border-color]
|
|
2
|
+
// with inline var(--duration-fast) + var(--ease-out); trigger swap is CopyButton's.
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
4
|
+
import * as React from "react"
|
|
5
|
+
import {
|
|
6
|
+
Clipboard,
|
|
7
|
+
ClipboardControl,
|
|
8
|
+
ClipboardInput,
|
|
9
|
+
ClipboardLabel,
|
|
10
|
+
ClipboardTrigger,
|
|
11
|
+
} from "@behavioral-agentic-design-system/core/components/ui/clipboard"
|
|
12
|
+
import {
|
|
13
|
+
Card,
|
|
14
|
+
CardContent,
|
|
15
|
+
CardDescription,
|
|
16
|
+
CardHeader,
|
|
17
|
+
CardTitle,
|
|
18
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
19
|
+
|
|
20
|
+
const meta: Meta<typeof Clipboard> = {
|
|
21
|
+
title: "Components/Clipboard",
|
|
22
|
+
component: Clipboard,
|
|
23
|
+
parameters: {
|
|
24
|
+
layout: "centered",
|
|
25
|
+
docs: {
|
|
26
|
+
description: {
|
|
27
|
+
component:
|
|
28
|
+
"Compound clipboard widget: renders the copyable value inline as a read-only, select-on-focus input alongside a copy trigger. The trigger composes CopyButton (clipboard write, Copy→Check success animation, aria-live 'Copied to clipboard'). The input truncates long values (min-w-0 + truncate) and preserves the full string in title; its border tints to the ring token during the copied window. Label associates via htmlFor; without a ClipboardLabel the input falls back to aria-label='Copyable value'. Trigger defaults to size='xl' (44px CTA floor). Distinct from CopyButton, which copies without displaying the value.",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
export default meta
|
|
34
|
+
type Story = StoryObj<typeof Clipboard>
|
|
35
|
+
|
|
36
|
+
export const Default: Story = {
|
|
37
|
+
render: () => (
|
|
38
|
+
<div className="w-96">
|
|
39
|
+
<Clipboard value="pk_live_5K8mN2qR7tLwYjAb4cDeFgHi">
|
|
40
|
+
<ClipboardControl>
|
|
41
|
+
<ClipboardInput />
|
|
42
|
+
<ClipboardTrigger />
|
|
43
|
+
</ClipboardControl>
|
|
44
|
+
</Clipboard>
|
|
45
|
+
</div>
|
|
46
|
+
),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const WithLabel: Story = {
|
|
50
|
+
render: () => (
|
|
51
|
+
<div className="w-96">
|
|
52
|
+
<Clipboard value="https://design.bads.com/share/tokens-v2-proposal">
|
|
53
|
+
<ClipboardLabel>Share link</ClipboardLabel>
|
|
54
|
+
<ClipboardControl>
|
|
55
|
+
<ClipboardInput />
|
|
56
|
+
<ClipboardTrigger>Copy link</ClipboardTrigger>
|
|
57
|
+
</ClipboardControl>
|
|
58
|
+
</Clipboard>
|
|
59
|
+
</div>
|
|
60
|
+
),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const LongValue: Story = {
|
|
64
|
+
render: () => (
|
|
65
|
+
<div className="w-80">
|
|
66
|
+
<Clipboard value="https://design.bads.com/docs/getting-started?utm_source=onboarding&utm_campaign=client-fork-2026&session=jordan.reeves">
|
|
67
|
+
<ClipboardLabel>Onboarding link</ClipboardLabel>
|
|
68
|
+
<ClipboardControl>
|
|
69
|
+
<ClipboardInput />
|
|
70
|
+
<ClipboardTrigger />
|
|
71
|
+
</ClipboardControl>
|
|
72
|
+
</Clipboard>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const IconTrigger: Story = {
|
|
78
|
+
render: () => (
|
|
79
|
+
<div className="w-96">
|
|
80
|
+
<Clipboard value="npm install @behavioral-agentic-design-system/core">
|
|
81
|
+
<ClipboardLabel>Install command</ClipboardLabel>
|
|
82
|
+
<ClipboardControl>
|
|
83
|
+
<ClipboardInput />
|
|
84
|
+
<ClipboardTrigger size="icon-xl" aria-label="Copy install command" />
|
|
85
|
+
</ClipboardControl>
|
|
86
|
+
</Clipboard>
|
|
87
|
+
</div>
|
|
88
|
+
),
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const Disabled: Story = {
|
|
92
|
+
render: () => (
|
|
93
|
+
<div className="w-96">
|
|
94
|
+
<Clipboard value="pk_live_5K8mN2qR7tLwYjAb4cDeFgHi" disabled>
|
|
95
|
+
<ClipboardLabel>API key</ClipboardLabel>
|
|
96
|
+
<ClipboardControl>
|
|
97
|
+
<ClipboardInput />
|
|
98
|
+
<ClipboardTrigger />
|
|
99
|
+
</ClipboardControl>
|
|
100
|
+
</Clipboard>
|
|
101
|
+
</div>
|
|
102
|
+
),
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const RealisticUse: Story = {
|
|
106
|
+
render: () => {
|
|
107
|
+
const secretKey = "sk-proj-Xk9mNpQ2vR7tLwYjAb4cDeFgHiJkLmNo" // gitleaks:allow
|
|
108
|
+
return (
|
|
109
|
+
<Card className="w-[26rem]">
|
|
110
|
+
<CardHeader>
|
|
111
|
+
<CardTitle>API keys</CardTitle>
|
|
112
|
+
<CardDescription>
|
|
113
|
+
Authenticate requests from jordan@reeves.design's workspace. Keep
|
|
114
|
+
the secret key server-side.
|
|
115
|
+
</CardDescription>
|
|
116
|
+
</CardHeader>
|
|
117
|
+
<CardContent className="flex flex-col gap-6">
|
|
118
|
+
<Clipboard value="pk_live_5K8mN2qR7tLwYjAb4cDeFgHi">
|
|
119
|
+
<ClipboardLabel>Publishable key</ClipboardLabel>
|
|
120
|
+
<ClipboardControl>
|
|
121
|
+
<ClipboardInput />
|
|
122
|
+
<ClipboardTrigger />
|
|
123
|
+
</ClipboardControl>
|
|
124
|
+
</Clipboard>
|
|
125
|
+
<Clipboard value={secretKey}>
|
|
126
|
+
<ClipboardLabel>Secret key</ClipboardLabel>
|
|
127
|
+
<ClipboardControl>
|
|
128
|
+
<ClipboardInput />
|
|
129
|
+
<ClipboardTrigger />
|
|
130
|
+
</ClipboardControl>
|
|
131
|
+
</Clipboard>
|
|
132
|
+
</CardContent>
|
|
133
|
+
</Card>
|
|
134
|
+
)
|
|
135
|
+
},
|
|
136
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
// Motion: the copy↔copied swap narrowed transition-all → transition-[opacity,transform] (explicit-properties rule).
|
|
2
|
+
// Types: onCopy is (value: string) => void — the DOM ClipboardEventHandler is Omit-ed
|
|
3
|
+
// from the button props so the callback parameter is a clean string (2026-08-06).
|
|
2
4
|
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
5
|
import * as React from "react"
|
|
4
6
|
import { CopyButton } from "@behavioral-agentic-design-system/core/components/ui/copy-button"
|