@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,211 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import {
|
|
3
|
+
Drawer,
|
|
4
|
+
DrawerClose,
|
|
5
|
+
DrawerContent,
|
|
6
|
+
DrawerDescription,
|
|
7
|
+
DrawerFooter,
|
|
8
|
+
DrawerHeader,
|
|
9
|
+
DrawerTitle,
|
|
10
|
+
DrawerTrigger,
|
|
11
|
+
} from "@behavioral-agentic-design-system/core/components/ui/drawer";
|
|
12
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
13
|
+
import { Textarea } from "@behavioral-agentic-design-system/core/components/ui/textarea";
|
|
14
|
+
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
|
|
15
|
+
|
|
16
|
+
const meta: Meta<typeof Drawer> = {
|
|
17
|
+
title: "Components/Drawer",
|
|
18
|
+
component: Drawer,
|
|
19
|
+
parameters: { layout: "centered" },
|
|
20
|
+
tags: ["autodocs"],
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default meta;
|
|
24
|
+
type Story = StoryObj<typeof meta>;
|
|
25
|
+
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
// Default — bottom drawer with drag-to-dismiss, uses BADS persona content
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
export const Default: Story = {
|
|
30
|
+
render: () => (
|
|
31
|
+
<Drawer>
|
|
32
|
+
<DrawerTrigger asChild>
|
|
33
|
+
<Button variant="outline">Open drawer</Button>
|
|
34
|
+
</DrawerTrigger>
|
|
35
|
+
<DrawerContent>
|
|
36
|
+
<DrawerHeader>
|
|
37
|
+
<DrawerTitle>Display settings</DrawerTitle>
|
|
38
|
+
<DrawerDescription>
|
|
39
|
+
Choose how content is laid out across your workspace.
|
|
40
|
+
</DrawerDescription>
|
|
41
|
+
</DrawerHeader>
|
|
42
|
+
<div className="flex flex-col gap-3 px-4 pb-4">
|
|
43
|
+
<p className="text-sm text-muted-foreground">
|
|
44
|
+
Drag the handle above or swipe down to dismiss.
|
|
45
|
+
</p>
|
|
46
|
+
<p className="text-sm">
|
|
47
|
+
Jordan Reeves — Design Systems Lead — jordan@reeves.design
|
|
48
|
+
</p>
|
|
49
|
+
</div>
|
|
50
|
+
</DrawerContent>
|
|
51
|
+
</Drawer>
|
|
52
|
+
),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// Side_Right — right-edge drawer
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
export const Side_Right: Story = {
|
|
59
|
+
render: () => (
|
|
60
|
+
<Drawer>
|
|
61
|
+
<DrawerTrigger asChild>
|
|
62
|
+
<Button variant="outline">Open right drawer</Button>
|
|
63
|
+
</DrawerTrigger>
|
|
64
|
+
<DrawerContent side="right">
|
|
65
|
+
<DrawerHeader>
|
|
66
|
+
<DrawerTitle>Token inspector</DrawerTitle>
|
|
67
|
+
<DrawerDescription>
|
|
68
|
+
Inspect and override design tokens for the active component.
|
|
69
|
+
</DrawerDescription>
|
|
70
|
+
</DrawerHeader>
|
|
71
|
+
<div className="flex flex-col gap-3 px-4">
|
|
72
|
+
<p className="text-sm text-muted-foreground">
|
|
73
|
+
Component: Button · Variant: primary · Size: xl
|
|
74
|
+
</p>
|
|
75
|
+
<p className="text-sm">
|
|
76
|
+
Token: <code className="text-xs">--color-primary</code>
|
|
77
|
+
</p>
|
|
78
|
+
</div>
|
|
79
|
+
</DrawerContent>
|
|
80
|
+
</Drawer>
|
|
81
|
+
),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// Side_Left — left-edge drawer
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
export const Side_Left: Story = {
|
|
88
|
+
render: () => (
|
|
89
|
+
<Drawer>
|
|
90
|
+
<DrawerTrigger asChild>
|
|
91
|
+
<Button variant="outline">Open left drawer</Button>
|
|
92
|
+
</DrawerTrigger>
|
|
93
|
+
<DrawerContent side="left">
|
|
94
|
+
<DrawerHeader>
|
|
95
|
+
<DrawerTitle>Navigation</DrawerTitle>
|
|
96
|
+
<DrawerDescription>
|
|
97
|
+
Jump to any section of the design system.
|
|
98
|
+
</DrawerDescription>
|
|
99
|
+
</DrawerHeader>
|
|
100
|
+
<nav className="flex flex-col gap-1 px-4 pb-4">
|
|
101
|
+
{["Tokens", "Components", "Patterns", "Ethics", "Docs"].map(
|
|
102
|
+
(item) => (
|
|
103
|
+
<Button key={item} variant="ghost" className="justify-start">
|
|
104
|
+
{item}
|
|
105
|
+
</Button>
|
|
106
|
+
)
|
|
107
|
+
)}
|
|
108
|
+
</nav>
|
|
109
|
+
</DrawerContent>
|
|
110
|
+
</Drawer>
|
|
111
|
+
),
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// Side_Top — top-edge drawer
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
export const Side_Top: Story = {
|
|
118
|
+
render: () => (
|
|
119
|
+
<Drawer>
|
|
120
|
+
<DrawerTrigger asChild>
|
|
121
|
+
<Button variant="outline">Open top drawer</Button>
|
|
122
|
+
</DrawerTrigger>
|
|
123
|
+
<DrawerContent side="top">
|
|
124
|
+
<DrawerHeader>
|
|
125
|
+
<DrawerTitle>System notice</DrawerTitle>
|
|
126
|
+
<DrawerDescription>
|
|
127
|
+
A scheduled maintenance window is active. Syncs will resume at
|
|
128
|
+
06:00 CDT.
|
|
129
|
+
</DrawerDescription>
|
|
130
|
+
</DrawerHeader>
|
|
131
|
+
<div className="flex justify-end gap-2 px-4 pb-4">
|
|
132
|
+
<DrawerClose asChild>
|
|
133
|
+
<Button variant="outline" size="lg">Dismiss</Button>
|
|
134
|
+
</DrawerClose>
|
|
135
|
+
</div>
|
|
136
|
+
</DrawerContent>
|
|
137
|
+
</Drawer>
|
|
138
|
+
),
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// WithFooter — bottom drawer with header + footer action buttons
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
export const WithFooter: Story = {
|
|
145
|
+
render: () => (
|
|
146
|
+
<Drawer>
|
|
147
|
+
<DrawerTrigger asChild>
|
|
148
|
+
<Button variant="outline">Open with footer</Button>
|
|
149
|
+
</DrawerTrigger>
|
|
150
|
+
<DrawerContent>
|
|
151
|
+
<DrawerHeader>
|
|
152
|
+
<DrawerTitle>Export tokens</DrawerTitle>
|
|
153
|
+
<DrawerDescription>
|
|
154
|
+
Choose a format and download the current token set for your fork.
|
|
155
|
+
</DrawerDescription>
|
|
156
|
+
</DrawerHeader>
|
|
157
|
+
<div className="flex flex-col gap-3 px-4">
|
|
158
|
+
<p className="text-sm text-muted-foreground">
|
|
159
|
+
Available formats: CSS custom properties, Style Dictionary JSON,
|
|
160
|
+
Figma Tokens JSON.
|
|
161
|
+
</p>
|
|
162
|
+
<p className="text-sm">
|
|
163
|
+
Last exported by Jordan Reeves on 2026-08-10.
|
|
164
|
+
</p>
|
|
165
|
+
</div>
|
|
166
|
+
<DrawerFooter className="flex-row justify-end gap-2">
|
|
167
|
+
<DrawerClose asChild>
|
|
168
|
+
<Button variant="ghost">Cancel</Button>
|
|
169
|
+
</DrawerClose>
|
|
170
|
+
<Button>Export CSS</Button>
|
|
171
|
+
</DrawerFooter>
|
|
172
|
+
</DrawerContent>
|
|
173
|
+
</Drawer>
|
|
174
|
+
),
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// ---------------------------------------------------------------------------
|
|
178
|
+
// RealisticUse — Submit feedback bottom drawer with Textarea
|
|
179
|
+
// ---------------------------------------------------------------------------
|
|
180
|
+
export const RealisticUse: Story = {
|
|
181
|
+
render: () => (
|
|
182
|
+
<Drawer>
|
|
183
|
+
<DrawerTrigger asChild>
|
|
184
|
+
<Button variant="outline">Submit feedback</Button>
|
|
185
|
+
</DrawerTrigger>
|
|
186
|
+
<DrawerContent>
|
|
187
|
+
<DrawerHeader>
|
|
188
|
+
<DrawerTitle>Submit feedback</DrawerTitle>
|
|
189
|
+
<DrawerDescription>
|
|
190
|
+
Share a bug report or design suggestion for jordan@reeves.design to
|
|
191
|
+
review.
|
|
192
|
+
</DrawerDescription>
|
|
193
|
+
</DrawerHeader>
|
|
194
|
+
<div className="flex flex-col gap-3 px-4">
|
|
195
|
+
<Label htmlFor="feedback-body">Your feedback</Label>
|
|
196
|
+
<Textarea
|
|
197
|
+
id="feedback-body"
|
|
198
|
+
rows={4}
|
|
199
|
+
placeholder="Describe the issue or suggestion clearly. Include the component name and the step to reproduce if it's a bug."
|
|
200
|
+
/>
|
|
201
|
+
</div>
|
|
202
|
+
<DrawerFooter className="flex-row justify-end gap-2">
|
|
203
|
+
<DrawerClose asChild>
|
|
204
|
+
<Button variant="outline">Cancel</Button>
|
|
205
|
+
</DrawerClose>
|
|
206
|
+
<Button type="submit">Submit</Button>
|
|
207
|
+
</DrawerFooter>
|
|
208
|
+
</DrawerContent>
|
|
209
|
+
</Drawer>
|
|
210
|
+
),
|
|
211
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// Motion: none of FileButton's own — hover/focus/active inherit from Button's
|
|
2
|
+
// token-driven contract (transition-colors + focus ring). The "state change"
|
|
3
|
+
// is an OS dialog outside the DOM; there is nothing to animate.
|
|
4
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
5
|
+
import * as React from "react"
|
|
6
|
+
import {
|
|
7
|
+
FileButton,
|
|
8
|
+
} from "@behavioral-agentic-design-system/core/components/ui/file-button"
|
|
9
|
+
import {
|
|
10
|
+
Avatar,
|
|
11
|
+
AvatarFallback,
|
|
12
|
+
} from "@behavioral-agentic-design-system/core/components/ui/avatar"
|
|
13
|
+
import {
|
|
14
|
+
Card,
|
|
15
|
+
CardContent,
|
|
16
|
+
CardDescription,
|
|
17
|
+
CardHeader,
|
|
18
|
+
CardTitle,
|
|
19
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card"
|
|
20
|
+
|
|
21
|
+
const meta: Meta<typeof FileButton> = {
|
|
22
|
+
title: "Components/FileButton",
|
|
23
|
+
component: FileButton,
|
|
24
|
+
parameters: {
|
|
25
|
+
layout: "centered",
|
|
26
|
+
docs: {
|
|
27
|
+
description: {
|
|
28
|
+
component:
|
|
29
|
+
"Click-to-browse file picker trigger. Renders as a BADS Button that programmatically clicks a visually-hidden <input type='file'> (aria-hidden, tabIndex=-1 — the button is the single interactive stop; Space/Enter opens the OS picker via Button's existing contract). onChange receives the selected File[] or null on cancel/empty; the input resets after every selection so the same file can be re-picked. Distinct from FileUpload (drag-and-drop dropzone with file list) — FileButton is the pure button affordance: profile photo change, 'Import CSV', document attachment in a composer. Does not upload; the consumer's onChange owns any network call.",
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
export default meta
|
|
35
|
+
type Story = StoryObj<typeof FileButton>
|
|
36
|
+
|
|
37
|
+
export const Default: Story = {
|
|
38
|
+
render: () => <FileButton onChange={() => {}} />,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const Variant_Solid: Story = {
|
|
42
|
+
render: () => (
|
|
43
|
+
<FileButton variant="default" accept="image/*" onChange={() => {}}>
|
|
44
|
+
Upload photo
|
|
45
|
+
</FileButton>
|
|
46
|
+
),
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const Multiple: Story = {
|
|
50
|
+
render: function MultipleStory() {
|
|
51
|
+
const [count, setCount] = React.useState(0)
|
|
52
|
+
return (
|
|
53
|
+
<div className="flex items-center gap-3">
|
|
54
|
+
<FileButton multiple onChange={(files) => setCount(files?.length ?? 0)}>
|
|
55
|
+
Upload files
|
|
56
|
+
</FileButton>
|
|
57
|
+
<span className="text-sm text-muted-foreground">
|
|
58
|
+
{count === 0
|
|
59
|
+
? "No files chosen"
|
|
60
|
+
: `${count} file${count === 1 ? "" : "s"} selected`}
|
|
61
|
+
</span>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export const Accepts_PDF: Story = {
|
|
68
|
+
render: () => (
|
|
69
|
+
<FileButton accept=".pdf" onChange={() => {}}>
|
|
70
|
+
Attach document
|
|
71
|
+
</FileButton>
|
|
72
|
+
),
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const Disabled: Story = {
|
|
76
|
+
render: () => <FileButton disabled onChange={() => {}} />,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const RealisticUse: Story = {
|
|
80
|
+
render: function RealisticUseStory() {
|
|
81
|
+
const [fileName, setFileName] = React.useState<string | null>(null)
|
|
82
|
+
return (
|
|
83
|
+
<Card className="w-96">
|
|
84
|
+
<CardHeader>
|
|
85
|
+
<CardTitle>Profile</CardTitle>
|
|
86
|
+
<CardDescription>
|
|
87
|
+
How you appear to your team on design.bads.com.
|
|
88
|
+
</CardDescription>
|
|
89
|
+
</CardHeader>
|
|
90
|
+
<CardContent className="flex items-center gap-4">
|
|
91
|
+
<Avatar className="size-12">
|
|
92
|
+
<AvatarFallback>JR</AvatarFallback>
|
|
93
|
+
</Avatar>
|
|
94
|
+
<div className="min-w-0 flex-1">
|
|
95
|
+
<p className="truncate text-sm font-medium text-foreground">
|
|
96
|
+
Jordan Reeves
|
|
97
|
+
</p>
|
|
98
|
+
<p
|
|
99
|
+
className="truncate text-sm text-muted-foreground"
|
|
100
|
+
title={fileName ?? undefined}
|
|
101
|
+
>
|
|
102
|
+
{fileName ?? "No file chosen"}
|
|
103
|
+
</p>
|
|
104
|
+
</div>
|
|
105
|
+
<FileButton
|
|
106
|
+
accept="image/*"
|
|
107
|
+
onChange={(files) => {
|
|
108
|
+
if (files) setFileName(files[0].name)
|
|
109
|
+
}}
|
|
110
|
+
>
|
|
111
|
+
Update avatar
|
|
112
|
+
</FileButton>
|
|
113
|
+
</CardContent>
|
|
114
|
+
</Card>
|
|
115
|
+
)
|
|
116
|
+
},
|
|
117
|
+
}
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FloatingIndicator — animated selection highlight that slides between nav/tab items.
|
|
3
|
+
*
|
|
4
|
+
* Implementation note: the indicator is a purely decorative, aria-hidden layer.
|
|
5
|
+
* All active-state ARIA (aria-selected, aria-current, data-state="active") belongs
|
|
6
|
+
* on the nav items themselves — FloatingIndicator provides only visual motion.
|
|
7
|
+
*
|
|
8
|
+
* Motion: token-driven var(--duration-base) + var(--ease-out) via inline style
|
|
9
|
+
* (explicit property list: left, top, width, height — never transition-all).
|
|
10
|
+
* Reduced-motion is handled automatically by the base-layer media query in styles.css.
|
|
11
|
+
*/
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
14
|
+
import { cn } from "@behavioral-agentic-design-system/core/lib/utils";
|
|
15
|
+
import {
|
|
16
|
+
FloatingIndicator,
|
|
17
|
+
useFloatingIndicator,
|
|
18
|
+
} from "@behavioral-agentic-design-system/core/components/ui/floating-indicator";
|
|
19
|
+
|
|
20
|
+
// ─── Meta ─────────────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
const meta: Meta<typeof FloatingIndicator> = {
|
|
23
|
+
title: "Components/FloatingIndicator",
|
|
24
|
+
component: FloatingIndicator,
|
|
25
|
+
parameters: {
|
|
26
|
+
layout: "centered",
|
|
27
|
+
docs: {
|
|
28
|
+
description: {
|
|
29
|
+
component:
|
|
30
|
+
"Animated selection highlight that slides between nav/tab items. Decorative aria-hidden layer — all active-state ARIA belongs on the nav items. Source: Mantine segmented-control pattern.",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
tags: ["autodocs"],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default meta;
|
|
38
|
+
type Story = StoryObj<typeof meta>;
|
|
39
|
+
|
|
40
|
+
// ─── Default — three-tab bar (Jordan Reeves's workspace) ──────────────────────
|
|
41
|
+
|
|
42
|
+
const WORKSPACE_TABS = [
|
|
43
|
+
{ value: "dashboard", label: "Dashboard" },
|
|
44
|
+
{ value: "analytics", label: "Analytics" },
|
|
45
|
+
{ value: "settings", label: "Settings" },
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
function TabBarDemo() {
|
|
49
|
+
const [active, setActive] = React.useState(0);
|
|
50
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
51
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
52
|
+
const [target, setTarget] = React.useState<HTMLElement | null>(null);
|
|
53
|
+
|
|
54
|
+
// Sync target with active index on mount and when index changes
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
57
|
+
}, [active]);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div className="space-y-4 w-[380px]">
|
|
61
|
+
<p className="text-xs text-muted-foreground">
|
|
62
|
+
Jordan Reeves · Watershed Analytics workspace
|
|
63
|
+
</p>
|
|
64
|
+
<div
|
|
65
|
+
ref={containerRef}
|
|
66
|
+
role="tablist"
|
|
67
|
+
aria-label="Workspace sections"
|
|
68
|
+
className="relative inline-flex rounded-lg bg-muted p-1 gap-0.5"
|
|
69
|
+
>
|
|
70
|
+
<FloatingIndicator
|
|
71
|
+
target={target}
|
|
72
|
+
parent={containerRef.current}
|
|
73
|
+
className="bg-background shadow-sm rounded-md"
|
|
74
|
+
/>
|
|
75
|
+
{WORKSPACE_TABS.map((tab, i) => (
|
|
76
|
+
<button
|
|
77
|
+
key={tab.value}
|
|
78
|
+
ref={(el) => {
|
|
79
|
+
itemRefs.current[i] = el;
|
|
80
|
+
}}
|
|
81
|
+
role="tab"
|
|
82
|
+
aria-selected={active === i}
|
|
83
|
+
onClick={() => setActive(i)}
|
|
84
|
+
className={cn(
|
|
85
|
+
"relative z-10 px-3 py-1.5 text-sm font-medium rounded-md transition-colors",
|
|
86
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
87
|
+
active === i
|
|
88
|
+
? "text-foreground"
|
|
89
|
+
: "text-muted-foreground hover:text-foreground"
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
{tab.label}
|
|
93
|
+
</button>
|
|
94
|
+
))}
|
|
95
|
+
</div>
|
|
96
|
+
<p className="text-xs text-muted-foreground">
|
|
97
|
+
Active: <span className="font-medium text-foreground">{WORKSPACE_TABS[active].label}</span>
|
|
98
|
+
</p>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export const Default: Story = {
|
|
104
|
+
render: () => <TabBarDemo />,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// ─── PillNav — horizontal pill navigation ─────────────────────────────────────
|
|
108
|
+
|
|
109
|
+
const PILL_NAV_ITEMS = [
|
|
110
|
+
{ value: "overview", label: "Overview" },
|
|
111
|
+
{ value: "components", label: "Components" },
|
|
112
|
+
{ value: "tokens", label: "Tokens" },
|
|
113
|
+
{ value: "docs", label: "Docs" },
|
|
114
|
+
];
|
|
115
|
+
|
|
116
|
+
function PillNavDemo() {
|
|
117
|
+
const [active, setActive] = React.useState(0);
|
|
118
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
119
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
120
|
+
const [target, setTarget] = React.useState<HTMLElement | null>(null);
|
|
121
|
+
|
|
122
|
+
React.useEffect(() => {
|
|
123
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
124
|
+
}, [active]);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div className="space-y-4 w-[420px]">
|
|
128
|
+
<p className="text-xs text-muted-foreground">Pill-style navigation — rounded-full items</p>
|
|
129
|
+
<div
|
|
130
|
+
ref={containerRef}
|
|
131
|
+
role="navigation"
|
|
132
|
+
aria-label="Section navigation"
|
|
133
|
+
className="relative inline-flex gap-1 bg-transparent"
|
|
134
|
+
>
|
|
135
|
+
{/* Pill indicator: rounded-full matches the item shape */}
|
|
136
|
+
<FloatingIndicator
|
|
137
|
+
target={target}
|
|
138
|
+
parent={containerRef.current}
|
|
139
|
+
className="bg-primary/10 rounded-full shadow-none"
|
|
140
|
+
/>
|
|
141
|
+
{PILL_NAV_ITEMS.map((item, i) => (
|
|
142
|
+
<button
|
|
143
|
+
key={item.value}
|
|
144
|
+
ref={(el) => {
|
|
145
|
+
itemRefs.current[i] = el;
|
|
146
|
+
}}
|
|
147
|
+
onClick={() => setActive(i)}
|
|
148
|
+
aria-current={active === i ? "page" : undefined}
|
|
149
|
+
className={cn(
|
|
150
|
+
"relative z-10 px-4 py-2 text-sm font-medium rounded-full transition-colors",
|
|
151
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
152
|
+
active === i
|
|
153
|
+
? "text-primary"
|
|
154
|
+
: "text-muted-foreground hover:text-foreground"
|
|
155
|
+
)}
|
|
156
|
+
>
|
|
157
|
+
{item.label}
|
|
158
|
+
</button>
|
|
159
|
+
))}
|
|
160
|
+
</div>
|
|
161
|
+
</div>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const PillNav: Story = {
|
|
166
|
+
render: () => <PillNavDemo />,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// ─── VerticalNav — sidebar navigation sliding indicator ───────────────────────
|
|
170
|
+
|
|
171
|
+
const SIDEBAR_NAV = [
|
|
172
|
+
{ value: "portfolio", label: "Portfolio" },
|
|
173
|
+
{ value: "clients", label: "Clients" },
|
|
174
|
+
{ value: "projects", label: "Projects" },
|
|
175
|
+
{ value: "reports", label: "Reports" },
|
|
176
|
+
{ value: "settings", label: "Settings" },
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
function VerticalNavDemo() {
|
|
180
|
+
const [active, setActive] = React.useState(0);
|
|
181
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
182
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
183
|
+
const [target, setTarget] = React.useState<HTMLElement | null>(null);
|
|
184
|
+
|
|
185
|
+
React.useEffect(() => {
|
|
186
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
187
|
+
}, [active]);
|
|
188
|
+
|
|
189
|
+
return (
|
|
190
|
+
<div className="flex gap-6 w-[360px]">
|
|
191
|
+
<nav aria-label="Design system sections" className="w-40">
|
|
192
|
+
<div
|
|
193
|
+
ref={containerRef}
|
|
194
|
+
className="relative flex flex-col gap-0.5"
|
|
195
|
+
>
|
|
196
|
+
<FloatingIndicator
|
|
197
|
+
target={target}
|
|
198
|
+
parent={containerRef.current}
|
|
199
|
+
className="bg-muted rounded-md shadow-none"
|
|
200
|
+
/>
|
|
201
|
+
{SIDEBAR_NAV.map((item, i) => (
|
|
202
|
+
<button
|
|
203
|
+
key={item.value}
|
|
204
|
+
ref={(el) => {
|
|
205
|
+
itemRefs.current[i] = el;
|
|
206
|
+
}}
|
|
207
|
+
onClick={() => setActive(i)}
|
|
208
|
+
aria-current={active === i ? "page" : undefined}
|
|
209
|
+
className={cn(
|
|
210
|
+
"relative z-10 w-full text-left px-3 py-2 text-sm font-medium rounded-md transition-colors",
|
|
211
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
212
|
+
active === i
|
|
213
|
+
? "text-foreground"
|
|
214
|
+
: "text-muted-foreground hover:text-foreground"
|
|
215
|
+
)}
|
|
216
|
+
>
|
|
217
|
+
{item.label}
|
|
218
|
+
</button>
|
|
219
|
+
))}
|
|
220
|
+
</div>
|
|
221
|
+
</nav>
|
|
222
|
+
<div className="flex-1 pt-1">
|
|
223
|
+
<p className="text-xs text-muted-foreground mb-1">Active section</p>
|
|
224
|
+
<p className="text-sm font-medium">{SIDEBAR_NAV[active].label}</p>
|
|
225
|
+
</div>
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export const VerticalNav: Story = {
|
|
231
|
+
render: () => <VerticalNavDemo />,
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
// ─── RealisticUse — segmented control with content ────────────────────────────
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Complete segmented control pattern: FloatingIndicator powers the sliding
|
|
238
|
+
* highlight inside a custom nav bar, with real content below each tab.
|
|
239
|
+
* Demonstrates the useFloatingIndicator hook for integrated state management.
|
|
240
|
+
*/
|
|
241
|
+
|
|
242
|
+
const DASHBOARD_TABS = [
|
|
243
|
+
{ value: "dashboard", label: "Dashboard" },
|
|
244
|
+
{ value: "analytics", label: "Analytics" },
|
|
245
|
+
{ value: "settings", label: "Settings" },
|
|
246
|
+
];
|
|
247
|
+
|
|
248
|
+
const DASHBOARD_CONTENT: Record<string, React.ReactNode> = {
|
|
249
|
+
dashboard: (
|
|
250
|
+
<div className="space-y-2">
|
|
251
|
+
<p className="text-sm font-medium text-foreground">Active projects — Seo-yun Park</p>
|
|
252
|
+
<p className="text-sm text-muted-foreground">
|
|
253
|
+
Watershed Analytics Q3 · On track · 12 components shipped
|
|
254
|
+
</p>
|
|
255
|
+
<p className="text-sm text-muted-foreground">
|
|
256
|
+
Civic Design System · In review · 4 tokens pending approval
|
|
257
|
+
</p>
|
|
258
|
+
</div>
|
|
259
|
+
),
|
|
260
|
+
analytics: (
|
|
261
|
+
<div className="space-y-2">
|
|
262
|
+
<p className="text-sm font-medium text-foreground">Usage metrics · Last 30 days</p>
|
|
263
|
+
<p className="text-sm text-muted-foreground">
|
|
264
|
+
Component renders: <span className="font-medium text-foreground">142,800</span>
|
|
265
|
+
</p>
|
|
266
|
+
<p className="text-sm text-muted-foreground">
|
|
267
|
+
Token overrides applied: <span className="font-medium text-foreground">2,340</span>
|
|
268
|
+
</p>
|
|
269
|
+
</div>
|
|
270
|
+
),
|
|
271
|
+
settings: (
|
|
272
|
+
<div className="space-y-2">
|
|
273
|
+
<p className="text-sm font-medium text-foreground">Workspace settings — Jordan Reeves</p>
|
|
274
|
+
<p className="text-sm text-muted-foreground">
|
|
275
|
+
Brand: Watershed Analytics · Slug: watershed
|
|
276
|
+
</p>
|
|
277
|
+
<p className="text-sm text-muted-foreground">
|
|
278
|
+
Theme: System default · AAA audit: passing (78/78 pairs)
|
|
279
|
+
</p>
|
|
280
|
+
</div>
|
|
281
|
+
),
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
function RealisticUseDemo() {
|
|
285
|
+
const [active, setActive] = React.useState(0);
|
|
286
|
+
const containerRef = React.useRef<HTMLDivElement>(null);
|
|
287
|
+
const { target, setTarget } = useFloatingIndicator(containerRef);
|
|
288
|
+
const itemRefs = React.useRef<(HTMLButtonElement | null)[]>([]);
|
|
289
|
+
|
|
290
|
+
React.useEffect(() => {
|
|
291
|
+
setTarget(itemRefs.current[active] ?? null);
|
|
292
|
+
}, [active]);
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<div className="w-[440px] space-y-4">
|
|
296
|
+
<div className="rounded-xl border border-border bg-card shadow-sm">
|
|
297
|
+
{/* Custom segmented nav bar */}
|
|
298
|
+
<div className="border-b border-border px-4 pt-4 pb-0">
|
|
299
|
+
<div
|
|
300
|
+
ref={containerRef}
|
|
301
|
+
role="tablist"
|
|
302
|
+
aria-label="Dashboard sections"
|
|
303
|
+
className="relative inline-flex gap-0 border-b-0"
|
|
304
|
+
>
|
|
305
|
+
<FloatingIndicator
|
|
306
|
+
target={target}
|
|
307
|
+
parent={containerRef.current}
|
|
308
|
+
className="rounded-t-md rounded-b-none bg-background shadow-none border border-b-0 border-border"
|
|
309
|
+
/>
|
|
310
|
+
{DASHBOARD_TABS.map((tab, i) => (
|
|
311
|
+
<button
|
|
312
|
+
key={tab.value}
|
|
313
|
+
ref={(el) => {
|
|
314
|
+
itemRefs.current[i] = el;
|
|
315
|
+
}}
|
|
316
|
+
role="tab"
|
|
317
|
+
aria-selected={active === i}
|
|
318
|
+
onClick={() => setActive(i)}
|
|
319
|
+
className={cn(
|
|
320
|
+
"relative z-10 px-4 py-2.5 text-sm font-medium transition-colors",
|
|
321
|
+
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 rounded-sm",
|
|
322
|
+
active === i
|
|
323
|
+
? "text-foreground"
|
|
324
|
+
: "text-muted-foreground hover:text-foreground"
|
|
325
|
+
)}
|
|
326
|
+
>
|
|
327
|
+
{tab.label}
|
|
328
|
+
</button>
|
|
329
|
+
))}
|
|
330
|
+
</div>
|
|
331
|
+
</div>
|
|
332
|
+
{/* Tab content */}
|
|
333
|
+
<div className="p-4">
|
|
334
|
+
{DASHBOARD_CONTENT[DASHBOARD_TABS[active].value]}
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
</div>
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
export const RealisticUse: Story = {
|
|
342
|
+
render: () => <RealisticUseDemo />,
|
|
343
|
+
};
|