@behavioral-agentic-design-system/core 0.26.0 → 0.27.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 +1 -1
- package/scripts/build-tokens.cjs +8 -0
- package/src/app/preview/components/page.tsx +236 -1
- package/src/components/ui/floating-action-button.tsx +179 -0
- package/src/components/ui/index.ts +1 -0
- package/src/components/ui/meter.tsx +4 -4
- 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 +82 -0
- package/src/data/docs-index.ts +1 -0
- package/src/stories/Affix.stories.tsx +1 -1
- package/src/stories/Anchor.stories.tsx +4 -4
- package/src/stories/FloatingActionButton.stories.tsx +215 -0
- package/src/stories/Meter.stories.tsx +7 -0
- package/src/stories/TransferList.stories.tsx +21 -0
- package/src/stories/TypingIndicator.stories.tsx +139 -0
- package/src/stories/WordRotate.stories.tsx +101 -0
- package/src/styles.css +8 -0
- package/src/tokens.json +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { cn } from "../../lib/utils"
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* TypingIndicator — three-dot animated is-typing signal for chat and AI
|
|
8
|
+
* response surfaces. Matches the pattern used by Signal, Slack, iMessage,
|
|
9
|
+
* and Ant Design X (Bubble.Typing).
|
|
10
|
+
*
|
|
11
|
+
* Motion: pattern (b) keyframe `typing-dot` defined in build-tokens.cjs,
|
|
12
|
+
* applied per-dot with a staggered `animationDelay` via inline style (pattern
|
|
13
|
+
* c). The three-dot sequence runs at 1.2 s per cycle, 200 ms apart.
|
|
14
|
+
* Reduced-motion: the base-layer `@media (prefers-reduced-motion: reduce)`
|
|
15
|
+
* forces `animation-duration: 0.01ms` — dots snap to their rest state
|
|
16
|
+
* instantly and the indicator reads as a static three-dot ellipsis.
|
|
17
|
+
*
|
|
18
|
+
* Accessibility: the outer span carries `role="status"` + `aria-label` so
|
|
19
|
+
* the typing state is announced politely to screen readers on mount. The dot
|
|
20
|
+
* spans are `aria-hidden` — the dots themselves carry no information; the
|
|
21
|
+
* label does. Pair with an aria-live region or Sonner toast for the actual
|
|
22
|
+
* response text.
|
|
23
|
+
*
|
|
24
|
+
* Ethics contract: no data collected, darkPatternRisk none. The indicator
|
|
25
|
+
* must reflect real async work — never fake a typing animation to add
|
|
26
|
+
* perceived thoughtfulness to an already-computed response (that's deceptive
|
|
27
|
+
* theater, not a loading state).
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
export interface TypingIndicatorProps
|
|
31
|
+
extends React.ComponentProps<"span"> {
|
|
32
|
+
/** Accessible label for screen readers. Default "Typing". */
|
|
33
|
+
label?: string
|
|
34
|
+
/** Visual size of the dot cluster. Default "default". */
|
|
35
|
+
size?: "sm" | "default" | "lg"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const DOT_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
|
|
39
|
+
sm: "size-1",
|
|
40
|
+
default: "size-1.5",
|
|
41
|
+
lg: "size-2",
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const GAP_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
|
|
45
|
+
sm: "gap-0.5",
|
|
46
|
+
default: "gap-1",
|
|
47
|
+
lg: "gap-1.5",
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const PADDING_SIZES: Record<NonNullable<TypingIndicatorProps["size"]>, string> = {
|
|
51
|
+
sm: "px-2 py-1",
|
|
52
|
+
default: "px-2.5 py-1.5",
|
|
53
|
+
lg: "px-3 py-2",
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function TypingIndicator({
|
|
57
|
+
label = "Typing",
|
|
58
|
+
size = "default",
|
|
59
|
+
className,
|
|
60
|
+
...props
|
|
61
|
+
}: TypingIndicatorProps) {
|
|
62
|
+
return (
|
|
63
|
+
<span
|
|
64
|
+
role="status"
|
|
65
|
+
aria-label={label}
|
|
66
|
+
data-slot="typing-indicator"
|
|
67
|
+
data-size={size}
|
|
68
|
+
className={cn(
|
|
69
|
+
"inline-flex items-center rounded-full bg-muted",
|
|
70
|
+
PADDING_SIZES[size],
|
|
71
|
+
className
|
|
72
|
+
)}
|
|
73
|
+
{...props}
|
|
74
|
+
>
|
|
75
|
+
{/* Dot cluster — aria-hidden; the role=status label carries meaning */}
|
|
76
|
+
<span
|
|
77
|
+
aria-hidden="true"
|
|
78
|
+
className={cn("flex items-center", GAP_SIZES[size])}
|
|
79
|
+
>
|
|
80
|
+
{[0, 1, 2].map((i) => (
|
|
81
|
+
<span
|
|
82
|
+
key={i}
|
|
83
|
+
data-slot="typing-indicator-dot"
|
|
84
|
+
className={cn("rounded-full bg-muted-foreground", DOT_SIZES[size])}
|
|
85
|
+
style={{
|
|
86
|
+
animation: "typing-dot 1.2s ease-in-out infinite",
|
|
87
|
+
animationDelay: `${i * 200}ms`,
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
))}
|
|
91
|
+
</span>
|
|
92
|
+
</span>
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export { TypingIndicator }
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
className={cn("inline-block overflow-hidden", className)}
|
|
62
|
+
>
|
|
63
|
+
{/* Visual word — aria-hidden because sr-only below carries the live region */}
|
|
64
|
+
<span
|
|
65
|
+
aria-hidden="true"
|
|
66
|
+
className="inline-block transition-[opacity,transform]"
|
|
67
|
+
style={{
|
|
68
|
+
opacity: visible ? 1 : 0,
|
|
69
|
+
transform: visible ? "translateY(0)" : "translateY(-30%)",
|
|
70
|
+
transitionDuration: "var(--duration-base)",
|
|
71
|
+
transitionTimingFunction: "var(--ease-out)",
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
{words[index]}
|
|
75
|
+
</span>
|
|
76
|
+
{/* Screen reader always gets the current word via the live region */}
|
|
77
|
+
<span className="sr-only">{words[index]}</span>
|
|
78
|
+
</span>
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
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>
|
|
@@ -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,215 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { MessageCircle, Pencil, Plus } from "lucide-react";
|
|
4
|
+
import { FloatingActionButton } from "@behavioral-agentic-design-system/core/components/ui/floating-action-button";
|
|
5
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof FloatingActionButton> = {
|
|
8
|
+
title: "Components/FloatingActionButton",
|
|
9
|
+
component: FloatingActionButton,
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: "centered",
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component:
|
|
15
|
+
"Fixed-position circular button that triggers a single primary action — the single-action counterpart to SpeedDial (which opens a 2–5 item submenu). Wraps Button, so focus ring, loading, and disabled ship from the primitive. md (56px) is the recommended thumb-target size; sm (40px) sits below the 44px floor and is for dense secondary chrome only. Icon-only FABs REQUIRE aria-label. Stories render inside a [transform:translateZ(0)] frame so position:fixed pins to the demo frame instead of the Storybook viewport.",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
tags: ["autodocs"],
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Demo frame: `transform: translateZ(0)` makes this box the containing block
|
|
27
|
+
* for `position: fixed` descendants, so the FAB pins to the frame instead of
|
|
28
|
+
* the Storybook viewport (same trick as the Affix stories). In a real app the
|
|
29
|
+
* FAB pins to the true viewport.
|
|
30
|
+
*/
|
|
31
|
+
function DemoFrame({ children }: { children: React.ReactNode }) {
|
|
32
|
+
return (
|
|
33
|
+
<div className="relative h-64 w-96 overflow-hidden rounded-lg border border-border bg-card [transform:translateZ(0)]">
|
|
34
|
+
<div className="p-4">
|
|
35
|
+
<p className="text-sm font-medium text-foreground">design.bads.com</p>
|
|
36
|
+
<p className="text-sm text-muted-foreground">
|
|
37
|
+
The frame stands in for the viewport — the FAB stays pinned to its
|
|
38
|
+
corner while everything else scrolls.
|
|
39
|
+
</p>
|
|
40
|
+
</div>
|
|
41
|
+
{children}
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const Default: Story = {
|
|
47
|
+
render: () => (
|
|
48
|
+
<DemoFrame>
|
|
49
|
+
<FloatingActionButton
|
|
50
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
51
|
+
aria-label="Create new"
|
|
52
|
+
/>
|
|
53
|
+
</DemoFrame>
|
|
54
|
+
),
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const Variant_Secondary: Story = {
|
|
58
|
+
render: () => (
|
|
59
|
+
<DemoFrame>
|
|
60
|
+
<FloatingActionButton
|
|
61
|
+
variant="secondary"
|
|
62
|
+
icon={<MessageCircle strokeWidth={1.5} aria-hidden="true" />}
|
|
63
|
+
aria-label="Open chat with Jordan Reeves"
|
|
64
|
+
/>
|
|
65
|
+
</DemoFrame>
|
|
66
|
+
),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const WithLabel: Story = {
|
|
70
|
+
render: () => (
|
|
71
|
+
<DemoFrame>
|
|
72
|
+
{/* Extended (pill) form — the visible label IS the accessible name. */}
|
|
73
|
+
<FloatingActionButton
|
|
74
|
+
icon={<Pencil strokeWidth={1.5} aria-hidden="true" />}
|
|
75
|
+
label="New proposal"
|
|
76
|
+
/>
|
|
77
|
+
</DemoFrame>
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Size_Sm: Story = {
|
|
82
|
+
render: () => (
|
|
83
|
+
<DemoFrame>
|
|
84
|
+
{/* 40px — below the 44px SC 2.5.5 floor. Dense/desktop-secondary
|
|
85
|
+
chrome only; never the primary CTA (see registry antiPatterns). */}
|
|
86
|
+
<FloatingActionButton
|
|
87
|
+
size="sm"
|
|
88
|
+
variant="secondary"
|
|
89
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
90
|
+
aria-label="Add token"
|
|
91
|
+
/>
|
|
92
|
+
</DemoFrame>
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export const Size_Md: Story = {
|
|
97
|
+
render: () => (
|
|
98
|
+
<DemoFrame>
|
|
99
|
+
<FloatingActionButton
|
|
100
|
+
size="md"
|
|
101
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
102
|
+
aria-label="Create new"
|
|
103
|
+
/>
|
|
104
|
+
</DemoFrame>
|
|
105
|
+
),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const Size_Lg: Story = {
|
|
109
|
+
render: () => (
|
|
110
|
+
<DemoFrame>
|
|
111
|
+
<FloatingActionButton
|
|
112
|
+
size="lg"
|
|
113
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
114
|
+
aria-label="Create new"
|
|
115
|
+
/>
|
|
116
|
+
</DemoFrame>
|
|
117
|
+
),
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const Corner_BottomLeft: Story = {
|
|
121
|
+
render: () => (
|
|
122
|
+
<DemoFrame>
|
|
123
|
+
<FloatingActionButton
|
|
124
|
+
corner="bottom-left"
|
|
125
|
+
icon={<MessageCircle strokeWidth={1.5} aria-hidden="true" />}
|
|
126
|
+
aria-label="Open support chat"
|
|
127
|
+
/>
|
|
128
|
+
</DemoFrame>
|
|
129
|
+
),
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const Loading: Story = {
|
|
133
|
+
render: () => (
|
|
134
|
+
<DemoFrame>
|
|
135
|
+
{/* Spinner replaces the icon; aria-busy + disabled via Button. The
|
|
136
|
+
min-h/min-w frame keeps dimensions stable while loading. */}
|
|
137
|
+
<FloatingActionButton
|
|
138
|
+
loading
|
|
139
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
140
|
+
aria-label="Creating proposal"
|
|
141
|
+
/>
|
|
142
|
+
</DemoFrame>
|
|
143
|
+
),
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export const Disabled: Story = {
|
|
147
|
+
render: () => (
|
|
148
|
+
<DemoFrame>
|
|
149
|
+
<FloatingActionButton
|
|
150
|
+
disabled
|
|
151
|
+
icon={<Plus strokeWidth={1.5} aria-hidden="true" />}
|
|
152
|
+
aria-label="Create new (unavailable)"
|
|
153
|
+
/>
|
|
154
|
+
</DemoFrame>
|
|
155
|
+
),
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Real content from content/personas/bads.json (primary persona pool).
|
|
159
|
+
const reviewQueue = [
|
|
160
|
+
{
|
|
161
|
+
author: "Jordan Reeves",
|
|
162
|
+
date: "2026-05-26",
|
|
163
|
+
entry:
|
|
164
|
+
"Shared 36 components for review at design.bads.com/share/tokens-v2-proposal.",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
author: "Seo-yun Park",
|
|
168
|
+
date: "2026-01-15",
|
|
169
|
+
entry: "Raised the contrast floor to 7:1 across every shipped token pair.",
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
author: "Marcus Lindqvist",
|
|
173
|
+
date: "2025-11-20",
|
|
174
|
+
entry: "Moved the touch-target audit to the 44×44px target across all CTAs.",
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
author: "Anika Patel",
|
|
178
|
+
date: "2027-03-01",
|
|
179
|
+
entry:
|
|
180
|
+
"Scheduled the semantic-layer migration — token drift lint goes strict.",
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
|
|
184
|
+
export const RealisticUse: Story = {
|
|
185
|
+
render: () => (
|
|
186
|
+
<div className="relative h-80 w-[420px] overflow-hidden rounded-lg border border-border bg-card [transform:translateZ(0)]">
|
|
187
|
+
<div className="h-full overflow-y-auto p-4" tabIndex={0}>
|
|
188
|
+
<div className="flex items-center justify-between gap-3">
|
|
189
|
+
<h3 className="min-w-0 truncate text-base font-semibold text-foreground">
|
|
190
|
+
Tokens v2 proposal — review queue
|
|
191
|
+
</h3>
|
|
192
|
+
<Badge variant="secondary">4 open</Badge>
|
|
193
|
+
</div>
|
|
194
|
+
<ul className="mt-3 space-y-4">
|
|
195
|
+
{reviewQueue.map((item, i) => (
|
|
196
|
+
<li key={i} className="space-y-1">
|
|
197
|
+
<p className="text-sm font-medium text-foreground">
|
|
198
|
+
{item.author}{" "}
|
|
199
|
+
<span className="font-normal text-muted-foreground">
|
|
200
|
+
· {item.date}
|
|
201
|
+
</span>
|
|
202
|
+
</p>
|
|
203
|
+
<p className="text-sm text-muted-foreground">{item.entry}</p>
|
|
204
|
+
</li>
|
|
205
|
+
))}
|
|
206
|
+
</ul>
|
|
207
|
+
</div>
|
|
208
|
+
{/* The single primary action on this surface: start a new review. */}
|
|
209
|
+
<FloatingActionButton
|
|
210
|
+
icon={<Pencil strokeWidth={1.5} aria-hidden="true" />}
|
|
211
|
+
label="New review"
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
),
|
|
215
|
+
};
|
|
@@ -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
|
}
|
|
@@ -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,139 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
3
|
+
import { TypingIndicator } from "@behavioral-agentic-design-system/core/components/ui/typing-indicator";
|
|
4
|
+
import { Avatar, AvatarFallback, AvatarImage } from "@behavioral-agentic-design-system/core/components/ui/avatar";
|
|
5
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
6
|
+
import {
|
|
7
|
+
Card,
|
|
8
|
+
CardContent,
|
|
9
|
+
CardHeader,
|
|
10
|
+
CardTitle,
|
|
11
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof TypingIndicator> = {
|
|
14
|
+
title: "Components/TypingIndicator",
|
|
15
|
+
component: TypingIndicator,
|
|
16
|
+
parameters: {
|
|
17
|
+
layout: "centered",
|
|
18
|
+
docs: {
|
|
19
|
+
description: {
|
|
20
|
+
component:
|
|
21
|
+
"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.",
|
|
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
|
+
<div className="flex flex-col items-start gap-2">
|
|
34
|
+
<TypingIndicator />
|
|
35
|
+
<p className="text-sm text-muted-foreground">
|
|
36
|
+
Default size — 3 dots bob with 200 ms stagger on a 1.2 s cycle.
|
|
37
|
+
</p>
|
|
38
|
+
</div>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const Size_sm: Story = {
|
|
43
|
+
render: () => (
|
|
44
|
+
<div className="flex flex-col items-start gap-2">
|
|
45
|
+
<TypingIndicator size="sm" />
|
|
46
|
+
<p className="text-sm text-muted-foreground">
|
|
47
|
+
sm — compact, for dense conversation threads.
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
),
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const Size_lg: Story = {
|
|
54
|
+
render: () => (
|
|
55
|
+
<div className="flex flex-col items-start gap-2">
|
|
56
|
+
<TypingIndicator size="lg" />
|
|
57
|
+
<p className="text-sm text-muted-foreground">
|
|
58
|
+
lg — prominent, for full-page AI response surfaces.
|
|
59
|
+
</p>
|
|
60
|
+
</div>
|
|
61
|
+
),
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const CustomLabel: Story = {
|
|
65
|
+
render: () => (
|
|
66
|
+
<div className="flex flex-col items-start gap-2">
|
|
67
|
+
<TypingIndicator label="BADS assistant is thinking…" />
|
|
68
|
+
<p className="text-sm text-muted-foreground">
|
|
69
|
+
Custom label — announced once by screen readers on mount.
|
|
70
|
+
</p>
|
|
71
|
+
</div>
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const RealisticUse: Story = {
|
|
76
|
+
render: function RealisticUseStory() {
|
|
77
|
+
const [phase, setPhase] = React.useState<"idle" | "typing" | "done">("idle");
|
|
78
|
+
const [response, setResponse] = React.useState("");
|
|
79
|
+
|
|
80
|
+
const handleSend = () => {
|
|
81
|
+
setPhase("typing");
|
|
82
|
+
setResponse("");
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
setPhase("done");
|
|
85
|
+
setResponse(
|
|
86
|
+
"I found 3 components related to your query: RollingNumber, Timer, and FormatNumber. RollingNumber animates value changes; Timer ticks toward a deadline; FormatNumber formats statically."
|
|
87
|
+
);
|
|
88
|
+
}, 2600);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Card className="w-[380px]">
|
|
93
|
+
<CardHeader>
|
|
94
|
+
<CardTitle className="text-sm font-medium">BADS Assistant</CardTitle>
|
|
95
|
+
</CardHeader>
|
|
96
|
+
<CardContent className="flex flex-col gap-3">
|
|
97
|
+
{/* User message */}
|
|
98
|
+
<div className="flex justify-end">
|
|
99
|
+
<div className="max-w-[70%] rounded-2xl rounded-tr-sm bg-primary px-3 py-2 text-sm text-primary-foreground">
|
|
100
|
+
Which component should I use for animated numbers?
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
{/* Assistant response area */}
|
|
105
|
+
<div className="flex items-end gap-2">
|
|
106
|
+
<Avatar size="sm" className="shrink-0">
|
|
107
|
+
<AvatarImage src="" alt="" />
|
|
108
|
+
<AvatarFallback>B</AvatarFallback>
|
|
109
|
+
</Avatar>
|
|
110
|
+
<div className="min-h-[36px]">
|
|
111
|
+
{phase === "idle" && (
|
|
112
|
+
<p className="text-sm text-muted-foreground">
|
|
113
|
+
Send a message to see the typing indicator.
|
|
114
|
+
</p>
|
|
115
|
+
)}
|
|
116
|
+
{phase === "typing" && (
|
|
117
|
+
<TypingIndicator label="BADS assistant is typing" />
|
|
118
|
+
)}
|
|
119
|
+
{phase === "done" && (
|
|
120
|
+
<div className="max-w-[70%] rounded-2xl rounded-tl-sm bg-muted px-3 py-2 text-sm">
|
|
121
|
+
{response}
|
|
122
|
+
</div>
|
|
123
|
+
)}
|
|
124
|
+
</div>
|
|
125
|
+
</div>
|
|
126
|
+
|
|
127
|
+
<Button
|
|
128
|
+
size="xl"
|
|
129
|
+
onClick={handleSend}
|
|
130
|
+
disabled={phase === "typing"}
|
|
131
|
+
className="w-full"
|
|
132
|
+
>
|
|
133
|
+
{phase === "typing" ? "Waiting…" : "Ask BADS"}
|
|
134
|
+
</Button>
|
|
135
|
+
</CardContent>
|
|
136
|
+
</Card>
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
};
|