@behavioral-agentic-design-system/core 0.39.1 → 0.42.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/README.md +2 -0
- package/package.json +26 -5
- package/scripts/a11y-lint.cjs +88 -8
- package/scripts/bads-components.mjs +118 -0
- package/scripts/build-tokens.cjs +133 -12
- package/scripts/check-stories.mjs +1 -1
- package/scripts/health-report.mjs +16 -2
- package/scripts/lint-component-source.mjs +100 -0
- package/scripts/lint-microanimation.mjs +267 -0
- package/scripts/lint-slop.mjs +25 -1
- package/scripts/size-audit.cjs +79 -0
- package/scripts/source-of-truth.cjs +58 -0
- package/scripts/ux-smoke.mjs +438 -0
- package/scripts/wcag-audit.cjs +121 -6
- package/src/api/layers/file.ts +1 -0
- package/src/app/opengraph-image.tsx +5 -0
- package/src/app/preview/components/page.tsx +2237 -2
- package/src/app/shell.tsx +17 -16
- package/src/components/Foundations/Motion.stories.tsx +1 -0
- package/src/components/customize/brand-mark-section.tsx +4 -2
- package/src/components/customize/design-controls.tsx +17 -2
- package/src/components/customize/discipline-section.tsx +3 -6
- package/src/components/customize/font-pickers.tsx +1 -1
- package/src/components/customize/letter-spacing.tsx +1 -1
- package/src/components/customize/save-bar.tsx +2 -2
- package/src/components/customize/theme-io.tsx +7 -7
- package/src/components/customize/type-scale.tsx +1 -1
- package/src/components/customize-tab.tsx +7 -4
- package/src/components/home-tab.tsx +3 -0
- package/src/components/studio/studio.tsx +153 -0
- package/src/components/ui/accordion.tsx +7 -0
- package/src/components/ui/alert.tsx +1 -0
- package/src/components/ui/anchor.tsx +37 -3
- package/src/components/ui/announcement-bar.tsx +256 -0
- package/src/components/ui/attachment.tsx +211 -0
- package/src/components/ui/badge.tsx +1 -0
- package/src/components/ui/callout.tsx +218 -0
- package/src/components/ui/chart.tsx +5 -14
- package/src/components/ui/code.tsx +1 -1
- package/src/components/ui/color-picker.tsx +2 -2
- package/src/components/ui/format-relative-time.tsx +139 -0
- package/src/components/ui/gauge-chart.tsx +238 -0
- package/src/components/ui/grid.tsx +255 -0
- package/src/components/ui/heatmap.tsx +256 -0
- package/src/components/ui/icon.tsx +108 -0
- package/src/components/ui/index.ts +17 -0
- package/src/components/ui/infinite-scroll.tsx +103 -0
- package/src/components/ui/json-input.tsx +351 -0
- package/src/components/ui/navigation-progress.tsx +281 -0
- package/src/components/ui/number-input.tsx +1 -4
- package/src/components/ui/page-header.tsx +63 -0
- package/src/components/ui/password-input.tsx +2 -1
- package/src/components/ui/password-strength-input.tsx +288 -0
- package/src/components/ui/pill.tsx +140 -0
- package/src/components/ui/popover.tsx +27 -4
- package/src/components/ui/portal.tsx +111 -0
- package/src/components/ui/presence.tsx +172 -0
- package/src/components/ui/progress-stack.tsx +258 -0
- package/src/components/ui/scroll-progress.tsx +100 -0
- package/src/components/ui/select.tsx +89 -4
- package/src/components/ui/separator.tsx +1 -0
- package/src/components/ui/slider.tsx +83 -3
- package/src/components/ui/snackbar.tsx +393 -0
- package/src/components/ui/sortable-list.tsx +342 -0
- package/src/components/ui/sparkline.tsx +2 -14
- package/src/components/ui/squircle.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/textarea.tsx +28 -1
- package/src/components/ui/tour.tsx +1 -3
- package/src/data/docs-index.ts +25 -0
- package/src/hooks/use-reduced-motion.ts +6 -0
- package/src/lib/clamp.ts +2 -0
- package/src/stories/Accordion.stories.tsx +59 -0
- package/src/stories/Alert.stories.tsx +3 -1
- package/src/stories/Anchor.stories.tsx +54 -0
- package/src/stories/AnnouncementBar.stories.tsx +261 -0
- package/src/stories/Attachment.stories.tsx +189 -0
- package/src/stories/Badge.stories.tsx +3 -0
- package/src/stories/Calendar.stories.tsx +1 -1
- package/src/stories/Callout.stories.tsx +219 -0
- package/src/stories/Chart.stories.tsx +8 -0
- package/src/stories/Code.stories.tsx +1 -0
- package/src/stories/ColorPicker.stories.tsx +24 -0
- package/src/stories/FormatRelativeTime.stories.tsx +116 -0
- package/src/stories/GaugeChart.stories.tsx +163 -0
- package/src/stories/Grid.stories.tsx +197 -0
- package/src/stories/Heatmap.stories.tsx +172 -0
- package/src/stories/Icon.stories.tsx +175 -0
- package/src/stories/InfiniteScroll.stories.tsx +225 -0
- package/src/stories/JsonInput.stories.tsx +212 -0
- package/src/stories/MultiSelect.stories.tsx +1 -1
- package/src/stories/NavigationProgress.stories.tsx +159 -0
- package/src/stories/NumberInput.stories.tsx +1 -0
- package/src/stories/PageHeader.stories.tsx +102 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
- package/src/stories/Pill.stories.tsx +201 -0
- package/src/stories/Popover.stories.tsx +29 -1
- package/src/stories/Portal.stories.tsx +191 -0
- package/src/stories/Presence.stories.tsx +228 -0
- package/src/stories/ProgressStack.stories.tsx +287 -0
- package/src/stories/ScrollProgress.stories.tsx +117 -0
- package/src/stories/Select.stories.tsx +25 -0
- package/src/stories/Separator.stories.tsx +3 -0
- package/src/stories/Slider.stories.tsx +54 -5
- package/src/stories/Snackbar.stories.tsx +315 -0
- package/src/stories/SortableList.stories.tsx +263 -0
- package/src/stories/Sparkline.stories.tsx +3 -0
- package/src/stories/Squircle.stories.tsx +1 -0
- package/src/stories/Table.stories.tsx +1 -0
- package/src/stories/Textarea.stories.tsx +18 -0
- package/src/stories/Tour.stories.tsx +1 -0
- package/src/stories/story-groups.json +26 -6
- package/src/styles.css +133 -12
- package/LICENSE +0 -21
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { Portal } from "@behavioral-agentic-design-system/core/components/ui/portal"
|
|
4
|
+
import { Presence } from "@behavioral-agentic-design-system/core/components/ui/presence"
|
|
5
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
6
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge"
|
|
7
|
+
import { Input } from "@behavioral-agentic-design-system/core/components/ui/input"
|
|
8
|
+
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label"
|
|
9
|
+
import { PortalThemeProvider } from "../hooks/use-portal-theme-class"
|
|
10
|
+
|
|
11
|
+
const meta: Meta<typeof Portal> = {
|
|
12
|
+
title: "Components/Overlays/Portal",
|
|
13
|
+
component: Portal,
|
|
14
|
+
parameters: { layout: "centered" },
|
|
15
|
+
tags: ["autodocs"],
|
|
16
|
+
argTypes: {
|
|
17
|
+
disabled: { control: "boolean" },
|
|
18
|
+
container: { control: false },
|
|
19
|
+
},
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default meta
|
|
23
|
+
type Story = StoryObj<typeof meta>
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The Badge is a React child of this story but a DOM child of `<body>` —
|
|
27
|
+
* it renders pinned to the top-right corner of the canvas, outside the
|
|
28
|
+
* centered story frame. Inspect the DOM to see it sitting after the root.
|
|
29
|
+
*/
|
|
30
|
+
export const Default: Story = {
|
|
31
|
+
args: { disabled: false },
|
|
32
|
+
render: (args) => (
|
|
33
|
+
<div className="w-80 rounded-lg border border-border bg-card p-4 text-sm">
|
|
34
|
+
<p className="font-medium">This card is in the story tree.</p>
|
|
35
|
+
<p className="text-muted-foreground">
|
|
36
|
+
The badge in the top-right corner is portaled to document.body — same
|
|
37
|
+
React parent, different DOM parent.
|
|
38
|
+
</p>
|
|
39
|
+
<Portal {...args}>
|
|
40
|
+
<Badge className="fixed top-4 right-4 z-50" variant="secondary">
|
|
41
|
+
Portaled to body
|
|
42
|
+
</Badge>
|
|
43
|
+
</Portal>
|
|
44
|
+
</div>
|
|
45
|
+
),
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Any element can be the target — here a ref'd bordered box. */
|
|
49
|
+
export const WithContainer: Story = {
|
|
50
|
+
render: function WithContainerStory() {
|
|
51
|
+
const [box, setBox] = React.useState<HTMLDivElement | null>(null)
|
|
52
|
+
return (
|
|
53
|
+
<div className="flex w-96 flex-col gap-4 text-sm">
|
|
54
|
+
<div className="rounded-lg border border-border bg-card p-4">
|
|
55
|
+
<p className="font-medium">Source</p>
|
|
56
|
+
<p className="text-muted-foreground">
|
|
57
|
+
The badge below is declared here…
|
|
58
|
+
</p>
|
|
59
|
+
<Portal container={box}>
|
|
60
|
+
<Badge variant="outline">Rendered into the target</Badge>
|
|
61
|
+
</Portal>
|
|
62
|
+
</div>
|
|
63
|
+
<div
|
|
64
|
+
ref={setBox}
|
|
65
|
+
className="flex min-h-16 items-center gap-2 rounded-lg border border-dashed border-border p-4"
|
|
66
|
+
>
|
|
67
|
+
<span className="text-muted-foreground">Target:</span>
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
)
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** `disabled` renders the children in place — nothing moves. */
|
|
75
|
+
export const Disabled: Story = {
|
|
76
|
+
args: { disabled: true },
|
|
77
|
+
render: (args) => (
|
|
78
|
+
<div className="flex w-80 items-center gap-3 rounded-lg border border-border bg-card p-4 text-sm">
|
|
79
|
+
<span className="text-muted-foreground">Inline:</span>
|
|
80
|
+
<Portal {...args}>
|
|
81
|
+
<Badge variant="outline">Not portaled</Badge>
|
|
82
|
+
</Portal>
|
|
83
|
+
</div>
|
|
84
|
+
),
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The reason this primitive exists. A theme-scoped custom property declared
|
|
89
|
+
* on a page wrapper (`.portal-demo-scope { --demo-panel: … }`) does not reach
|
|
90
|
+
* a raw portal at `<body>`. Portal merges the `PortalThemeProvider` scope
|
|
91
|
+
* class onto its root, so the same var() resolves inside the portal.
|
|
92
|
+
* Both panels read `var(--demo-panel)`; only the one with the provider is
|
|
93
|
+
* painted.
|
|
94
|
+
*/
|
|
95
|
+
export const WithThemeScope: Story = {
|
|
96
|
+
parameters: { controls: { disable: true } },
|
|
97
|
+
render: () => (
|
|
98
|
+
<>
|
|
99
|
+
{/* allow-inline-style: this story demonstrates the PortalThemeProvider
|
|
100
|
+
pattern itself, which needs a class-scoped custom property — no
|
|
101
|
+
Tailwind utility can express that, and the values ARE tokens. */}
|
|
102
|
+
<style>{`.portal-demo-scope { --demo-panel: var(--color-primary); --demo-panel-fg: var(--color-primary-foreground); }`}</style>
|
|
103
|
+
<div className="portal-demo-scope flex w-96 flex-col gap-4 text-sm">
|
|
104
|
+
<div className="rounded-lg border border-border bg-card p-4">
|
|
105
|
+
<p className="font-medium">Page wrapper with .portal-demo-scope</p>
|
|
106
|
+
<p className="text-muted-foreground">
|
|
107
|
+
The two panels below are portaled to body. Both use{" "}
|
|
108
|
+
<code className="font-mono">var(--demo-panel)</code>.
|
|
109
|
+
</p>
|
|
110
|
+
</div>
|
|
111
|
+
<Portal>
|
|
112
|
+
<div
|
|
113
|
+
className="fixed bottom-4 left-4 z-50 rounded-md border border-border px-3 py-2"
|
|
114
|
+
style={{
|
|
115
|
+
background: "var(--demo-panel, var(--color-card))",
|
|
116
|
+
color: "var(--demo-panel-fg, var(--color-card-foreground))",
|
|
117
|
+
}}
|
|
118
|
+
>
|
|
119
|
+
No provider — the scoped var() misses, falls back to card
|
|
120
|
+
</div>
|
|
121
|
+
</Portal>
|
|
122
|
+
<PortalThemeProvider scope="portal-demo-scope">
|
|
123
|
+
<Portal>
|
|
124
|
+
<div
|
|
125
|
+
className="fixed right-4 bottom-4 z-50 rounded-md px-3 py-2"
|
|
126
|
+
style={{
|
|
127
|
+
background: "var(--demo-panel, var(--color-card))",
|
|
128
|
+
color: "var(--demo-panel-fg, var(--color-card-foreground))",
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
With provider — scope class travels, var() resolves to primary
|
|
132
|
+
</div>
|
|
133
|
+
</Portal>
|
|
134
|
+
</PortalThemeProvider>
|
|
135
|
+
</div>
|
|
136
|
+
</>
|
|
137
|
+
),
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Unsaved-changes bar: a form deep in the page owns the state, but the bar
|
|
142
|
+
* must sit above every ancestor's overflow/transform — so it portals to
|
|
143
|
+
* body and animates in/out with Presence. Copy from
|
|
144
|
+
* content/personas/bads.json → primary.microcopy.
|
|
145
|
+
*/
|
|
146
|
+
export const RealisticUse: Story = {
|
|
147
|
+
render: function RealisticUseStory() {
|
|
148
|
+
const initial = "@behavioral-agentic-design-system"
|
|
149
|
+
const [value, setValue] = React.useState(initial)
|
|
150
|
+
const dirty = value !== initial
|
|
151
|
+
return (
|
|
152
|
+
<div className="w-96 overflow-hidden rounded-lg border border-border bg-card p-6">
|
|
153
|
+
<p className="text-lg font-semibold">Customize your tokens</p>
|
|
154
|
+
<p className="mb-5 text-sm text-muted-foreground">
|
|
155
|
+
Edit the scope to reveal the bar. This card has overflow-hidden — the
|
|
156
|
+
bar still escapes because it renders at body.
|
|
157
|
+
</p>
|
|
158
|
+
<div className="flex flex-col gap-3">
|
|
159
|
+
<Label htmlFor="portal-scope">npm scope</Label>
|
|
160
|
+
<Input
|
|
161
|
+
id="portal-scope"
|
|
162
|
+
value={value}
|
|
163
|
+
onChange={(e) => setValue(e.target.value)}
|
|
164
|
+
/>
|
|
165
|
+
</div>
|
|
166
|
+
<Portal>
|
|
167
|
+
<Presence present={dirty} transition="slide-up" asChild>
|
|
168
|
+
<div
|
|
169
|
+
role="status"
|
|
170
|
+
className="fixed inset-x-4 bottom-4 z-50 mx-auto flex max-w-lg items-center justify-between gap-4 rounded-lg border border-border bg-popover p-3 text-popover-foreground shadow-lg"
|
|
171
|
+
>
|
|
172
|
+
<span className="text-sm font-medium">Unsaved changes</span>
|
|
173
|
+
<div className="flex items-center gap-2">
|
|
174
|
+
<Button
|
|
175
|
+
size="xl"
|
|
176
|
+
variant="ghost"
|
|
177
|
+
onClick={() => setValue(initial)}
|
|
178
|
+
>
|
|
179
|
+
Cancel
|
|
180
|
+
</Button>
|
|
181
|
+
<Button size="xl" onClick={() => setValue(initial)}>
|
|
182
|
+
Save changes
|
|
183
|
+
</Button>
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
</Presence>
|
|
187
|
+
</Portal>
|
|
188
|
+
</div>
|
|
189
|
+
)
|
|
190
|
+
},
|
|
191
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import { CircleCheck } from "lucide-react"
|
|
4
|
+
import {
|
|
5
|
+
Presence,
|
|
6
|
+
type PresenceTransition,
|
|
7
|
+
} from "@behavioral-agentic-design-system/core/components/ui/presence"
|
|
8
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
9
|
+
import {
|
|
10
|
+
Alert,
|
|
11
|
+
AlertDescription,
|
|
12
|
+
AlertTitle,
|
|
13
|
+
} from "@behavioral-agentic-design-system/core/components/ui/alert"
|
|
14
|
+
import { Input } from "@behavioral-agentic-design-system/core/components/ui/input"
|
|
15
|
+
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label"
|
|
16
|
+
|
|
17
|
+
const meta: Meta<typeof Presence> = {
|
|
18
|
+
title: "Components/Feedback/Presence",
|
|
19
|
+
component: Presence,
|
|
20
|
+
parameters: { layout: "centered" },
|
|
21
|
+
tags: ["autodocs"],
|
|
22
|
+
argTypes: {
|
|
23
|
+
transition: {
|
|
24
|
+
control: "select",
|
|
25
|
+
options: ["fade", "scale", "slide-up", "slide-down", "slide-left", "slide-right"],
|
|
26
|
+
},
|
|
27
|
+
unmountOnExit: { control: "boolean" },
|
|
28
|
+
asChild: { control: false },
|
|
29
|
+
present: { control: false },
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default meta
|
|
34
|
+
type Story = StoryObj<typeof meta>
|
|
35
|
+
|
|
36
|
+
// Content from content/personas/bads.json → primary.names / companies.
|
|
37
|
+
const PANEL_TITLE = "Jordan Reeves"
|
|
38
|
+
const PANEL_BODY = "Northwind Systems · design system lead"
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Shared harness: a toggle Button drives `present`, the panel underneath
|
|
42
|
+
* animates in and out. Every story below reuses it with a different
|
|
43
|
+
* `transition` so the sidebar reads as the full keyframe matrix.
|
|
44
|
+
*/
|
|
45
|
+
function Harness({
|
|
46
|
+
transition,
|
|
47
|
+
unmountOnExit = true,
|
|
48
|
+
}: {
|
|
49
|
+
transition: PresenceTransition
|
|
50
|
+
unmountOnExit?: boolean
|
|
51
|
+
}) {
|
|
52
|
+
const [present, setPresent] = React.useState(true)
|
|
53
|
+
return (
|
|
54
|
+
<div className="flex w-80 flex-col gap-4">
|
|
55
|
+
<Button
|
|
56
|
+
variant="outline"
|
|
57
|
+
onClick={() => setPresent((p) => !p)}
|
|
58
|
+
aria-expanded={present}
|
|
59
|
+
aria-controls="presence-harness-panel"
|
|
60
|
+
>
|
|
61
|
+
{present ? "Hide panel" : "Show panel"}
|
|
62
|
+
</Button>
|
|
63
|
+
{/* Fixed-height slot so the layout doesn't jump while the exit plays. */}
|
|
64
|
+
<div className="h-24">
|
|
65
|
+
<Presence
|
|
66
|
+
id="presence-harness-panel"
|
|
67
|
+
present={present}
|
|
68
|
+
transition={transition}
|
|
69
|
+
unmountOnExit={unmountOnExit}
|
|
70
|
+
className="rounded-lg border border-border bg-card p-4 text-card-foreground shadow-sm"
|
|
71
|
+
>
|
|
72
|
+
<p className="text-sm font-medium">{PANEL_TITLE}</p>
|
|
73
|
+
<p className="text-sm text-muted-foreground">{PANEL_BODY}</p>
|
|
74
|
+
<p className="mt-2 text-xs text-muted-foreground">
|
|
75
|
+
transition: <code className="font-mono">{transition}</code>
|
|
76
|
+
</p>
|
|
77
|
+
</Presence>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// `present` is owned by the harness's toggle button; `transition` and
|
|
84
|
+
// `unmountOnExit` come from args so the Controls panel drives them.
|
|
85
|
+
const renderHarness = (args: Story["args"]) => (
|
|
86
|
+
<Harness
|
|
87
|
+
transition={args?.transition ?? "fade"}
|
|
88
|
+
unmountOnExit={args?.unmountOnExit ?? true}
|
|
89
|
+
/>
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
export const Default: Story = {
|
|
93
|
+
args: { transition: "fade", unmountOnExit: true },
|
|
94
|
+
render: (args) => renderHarness(args),
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const Variant_Fade: Story = {
|
|
98
|
+
args: { transition: "fade" },
|
|
99
|
+
render: (args) => renderHarness(args),
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export const Variant_Scale: Story = {
|
|
103
|
+
args: { transition: "scale" },
|
|
104
|
+
render: (args) => renderHarness(args),
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export const Variant_SlideUp: Story = {
|
|
108
|
+
args: { transition: "slide-up" },
|
|
109
|
+
render: (args) => renderHarness(args),
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const Variant_SlideDown: Story = {
|
|
113
|
+
args: { transition: "slide-down" },
|
|
114
|
+
render: (args) => renderHarness(args),
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export const Variant_SlideLeft: Story = {
|
|
118
|
+
args: { transition: "slide-left" },
|
|
119
|
+
render: (args) => renderHarness(args),
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const Variant_SlideRight: Story = {
|
|
123
|
+
args: { transition: "slide-right" },
|
|
124
|
+
render: (args) => renderHarness(args),
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* `unmountOnExit={false}` keeps the element in the DOM with the `hidden`
|
|
129
|
+
* attribute after the exit animation — inspect the DOM to see it. Use this
|
|
130
|
+
* for expensive subtrees (charts, iframes) that should keep their state.
|
|
131
|
+
*/
|
|
132
|
+
export const KeepMounted: Story = {
|
|
133
|
+
args: { transition: "scale", unmountOnExit: false },
|
|
134
|
+
render: (args) => renderHarness(args),
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* `asChild` merges the presence attributes onto the single child instead of
|
|
139
|
+
* adding a wrapper div — here the Alert itself animates.
|
|
140
|
+
*/
|
|
141
|
+
export const AsChild: Story = {
|
|
142
|
+
render: function AsChildStory() {
|
|
143
|
+
const [present, setPresent] = React.useState(true)
|
|
144
|
+
return (
|
|
145
|
+
<div className="flex w-96 flex-col gap-4">
|
|
146
|
+
<Button variant="outline" onClick={() => setPresent((p) => !p)}>
|
|
147
|
+
{present ? "Dismiss alert" : "Show alert"}
|
|
148
|
+
</Button>
|
|
149
|
+
<div className="min-h-20">
|
|
150
|
+
<Presence present={present} transition="slide-down" asChild>
|
|
151
|
+
<Alert>
|
|
152
|
+
<CircleCheck strokeWidth={1.5} />
|
|
153
|
+
<AlertTitle>Story coverage check passed</AlertTitle>
|
|
154
|
+
<AlertDescription>
|
|
155
|
+
All 36 components have matching stories.
|
|
156
|
+
</AlertDescription>
|
|
157
|
+
</Alert>
|
|
158
|
+
</Presence>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
)
|
|
162
|
+
},
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* A settings form whose "Save changes" shows an inline confirmation that
|
|
167
|
+
* animates in, holds for a moment, then animates out — the exit frame is
|
|
168
|
+
* what conditional rendering can't do. Copy from
|
|
169
|
+
* content/personas/bads.json → primary.notifications / microcopy.
|
|
170
|
+
*/
|
|
171
|
+
export const RealisticUse: Story = {
|
|
172
|
+
render: function RealisticUseStory() {
|
|
173
|
+
const [saved, setSaved] = React.useState(false)
|
|
174
|
+
React.useEffect(() => {
|
|
175
|
+
if (!saved) return
|
|
176
|
+
const t = window.setTimeout(() => setSaved(false), 2400)
|
|
177
|
+
return () => window.clearTimeout(t)
|
|
178
|
+
}, [saved])
|
|
179
|
+
return (
|
|
180
|
+
<form
|
|
181
|
+
className="flex w-96 flex-col gap-5 rounded-lg border border-border bg-card p-6"
|
|
182
|
+
onSubmit={(e) => {
|
|
183
|
+
e.preventDefault()
|
|
184
|
+
setSaved(true)
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
<div>
|
|
188
|
+
<p className="text-lg font-semibold">Customize your tokens</p>
|
|
189
|
+
<p className="text-sm text-muted-foreground">
|
|
190
|
+
36 components, all passing AAA contrast.
|
|
191
|
+
</p>
|
|
192
|
+
</div>
|
|
193
|
+
<div className="flex flex-col gap-3">
|
|
194
|
+
<Label htmlFor="presence-scope">npm scope</Label>
|
|
195
|
+
<Input
|
|
196
|
+
id="presence-scope"
|
|
197
|
+
defaultValue="@behavioral-agentic-design-system"
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
<div className="flex items-center gap-3">
|
|
201
|
+
<Button type="submit" size="xl">
|
|
202
|
+
Save changes
|
|
203
|
+
</Button>
|
|
204
|
+
<Button type="button" variant="ghost" size="xl">
|
|
205
|
+
Cancel
|
|
206
|
+
</Button>
|
|
207
|
+
</div>
|
|
208
|
+
<div className="min-h-12" aria-live="polite">
|
|
209
|
+
<Presence present={saved} transition="slide-up" asChild>
|
|
210
|
+
<div className="flex items-start gap-2 rounded-md bg-muted px-3 py-2 text-sm">
|
|
211
|
+
<CircleCheck
|
|
212
|
+
strokeWidth={1.5}
|
|
213
|
+
className="mt-0.5 size-4 shrink-0 text-icon-success"
|
|
214
|
+
aria-hidden="true"
|
|
215
|
+
/>
|
|
216
|
+
<span>
|
|
217
|
+
<span className="font-medium">Token changes saved.</span>{" "}
|
|
218
|
+
<span className="text-muted-foreground">
|
|
219
|
+
Run pnpm build:tokens to regenerate CSS.
|
|
220
|
+
</span>
|
|
221
|
+
</span>
|
|
222
|
+
</div>
|
|
223
|
+
</Presence>
|
|
224
|
+
</div>
|
|
225
|
+
</form>
|
|
226
|
+
)
|
|
227
|
+
},
|
|
228
|
+
}
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { ProgressStack } from "@behavioral-agentic-design-system/core/components/ui/progress-stack";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ProgressStack renders a multi-segment stacked horizontal bar for categorical
|
|
6
|
+
* breakdowns: storage used by file type, budget allocated by team, skill
|
|
7
|
+
* proficiency spread across domains.
|
|
8
|
+
*
|
|
9
|
+
* Segment colors cycle through the --chart-1..5 family by default so the bar
|
|
10
|
+
* reads as part of the same system as BADS charts. Override per segment via the
|
|
11
|
+
* `color` field.
|
|
12
|
+
*
|
|
13
|
+
* Accessibility: the track is `role="img"` with an `aria-label`. A
|
|
14
|
+
* visually-hidden description list carries the label + percentage for each
|
|
15
|
+
* segment. Always supply `aria-label` and, for sighted users, pair with
|
|
16
|
+
* `showLegend` so the breakdown is visible without assistive technology.
|
|
17
|
+
*
|
|
18
|
+
* Motion: each segment's width animates from 0 on mount using --duration-slow +
|
|
19
|
+
* --ease-out with a 40 ms per-segment stagger. Reduced-motion users see the
|
|
20
|
+
* final state immediately.
|
|
21
|
+
*/
|
|
22
|
+
const meta: Meta<typeof ProgressStack> = {
|
|
23
|
+
title: "Components/Content and data/ProgressStack",
|
|
24
|
+
component: ProgressStack,
|
|
25
|
+
parameters: { layout: "centered" },
|
|
26
|
+
tags: ["autodocs"],
|
|
27
|
+
argTypes: {
|
|
28
|
+
size: { control: "select", options: ["sm", "default", "lg"] },
|
|
29
|
+
showLegend: { control: "boolean" },
|
|
30
|
+
showValues: { control: "boolean" },
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default meta;
|
|
35
|
+
type Story = StoryObj<typeof meta>;
|
|
36
|
+
|
|
37
|
+
// ─── Segment fixtures ─────────────────────────────────────────────────────────
|
|
38
|
+
|
|
39
|
+
const storageSegments = [
|
|
40
|
+
{ value: 38, label: "Documents" },
|
|
41
|
+
{ value: 29, label: "Media" },
|
|
42
|
+
{ value: 16, label: "System" },
|
|
43
|
+
{ value: 8, label: "Other" },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const budgetSegments = [
|
|
47
|
+
{ value: 42, label: "Engineering" },
|
|
48
|
+
{ value: 28, label: "Design" },
|
|
49
|
+
{ value: 18, label: "Marketing" },
|
|
50
|
+
{ value: 12, label: "Operations" },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
const skillSegments = [
|
|
54
|
+
{ value: 90, label: "TypeScript" },
|
|
55
|
+
{ value: 75, label: "Design systems" },
|
|
56
|
+
{ value: 60, label: "Accessibility" },
|
|
57
|
+
{ value: 45, label: "Motion design" },
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
const twoSegments = [
|
|
61
|
+
{ value: 65, label: "Used" },
|
|
62
|
+
{ value: 35, label: "Available" },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
const customColors = [
|
|
66
|
+
{ value: 40, label: "Q1", color: "var(--primary)" },
|
|
67
|
+
{ value: 25, label: "Q2", color: "var(--success)" },
|
|
68
|
+
{ value: 20, label: "Q3", color: "var(--warning)" },
|
|
69
|
+
{ value: 15, label: "Q4", color: "var(--destructive)" },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
// ─── Stories ──────────────────────────────────────────────────────────────────
|
|
73
|
+
|
|
74
|
+
export const Default: Story = {
|
|
75
|
+
args: {
|
|
76
|
+
segments: storageSegments,
|
|
77
|
+
"aria-label": "Storage breakdown",
|
|
78
|
+
size: "default",
|
|
79
|
+
showLegend: false,
|
|
80
|
+
showValues: false,
|
|
81
|
+
},
|
|
82
|
+
render: (args) => (
|
|
83
|
+
<div className="w-80">
|
|
84
|
+
<ProgressStack {...args} />
|
|
85
|
+
</div>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const WithLegend: Story = {
|
|
90
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
91
|
+
<div className="w-80">
|
|
92
|
+
<ProgressStack
|
|
93
|
+
segments={storageSegments}
|
|
94
|
+
aria-label="Storage breakdown"
|
|
95
|
+
showLegend
|
|
96
|
+
/>
|
|
97
|
+
</div>
|
|
98
|
+
),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const WithValues: Story = {
|
|
102
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
103
|
+
<div className="w-80">
|
|
104
|
+
<ProgressStack
|
|
105
|
+
segments={storageSegments}
|
|
106
|
+
aria-label="Storage breakdown"
|
|
107
|
+
showLegend
|
|
108
|
+
showValues
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
),
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export const Size_Sm: Story = {
|
|
115
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
116
|
+
<div className="w-80">
|
|
117
|
+
<ProgressStack
|
|
118
|
+
segments={storageSegments}
|
|
119
|
+
size="sm"
|
|
120
|
+
aria-label="Storage breakdown"
|
|
121
|
+
showLegend
|
|
122
|
+
showValues
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
),
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const Size_Default: Story = {
|
|
129
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
130
|
+
<div className="w-80">
|
|
131
|
+
<ProgressStack
|
|
132
|
+
segments={storageSegments}
|
|
133
|
+
size="default"
|
|
134
|
+
aria-label="Storage breakdown"
|
|
135
|
+
showLegend
|
|
136
|
+
showValues
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
),
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const Size_Lg: Story = {
|
|
143
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
144
|
+
<div className="w-80">
|
|
145
|
+
<ProgressStack
|
|
146
|
+
segments={storageSegments}
|
|
147
|
+
size="lg"
|
|
148
|
+
aria-label="Storage breakdown"
|
|
149
|
+
showLegend
|
|
150
|
+
showValues
|
|
151
|
+
/>
|
|
152
|
+
</div>
|
|
153
|
+
),
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export const Sizes: Story = {
|
|
157
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
158
|
+
<div className="flex w-80 flex-col gap-6">
|
|
159
|
+
{(["sm", "default", "lg"] as const).map((size) => (
|
|
160
|
+
<div key={size} className="flex flex-col gap-2">
|
|
161
|
+
<p className="text-xs text-muted-foreground font-medium">size="{size}"</p>
|
|
162
|
+
<ProgressStack
|
|
163
|
+
segments={storageSegments}
|
|
164
|
+
size={size}
|
|
165
|
+
aria-label={`Storage breakdown — ${size}`}
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
168
|
+
))}
|
|
169
|
+
</div>
|
|
170
|
+
),
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export const TwoSegments: Story = {
|
|
174
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
175
|
+
<div className="w-72">
|
|
176
|
+
<ProgressStack
|
|
177
|
+
segments={twoSegments}
|
|
178
|
+
aria-label="Disk usage"
|
|
179
|
+
showLegend
|
|
180
|
+
showValues
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
183
|
+
),
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const CustomColors: Story = {
|
|
187
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
188
|
+
<div className="w-80">
|
|
189
|
+
<ProgressStack
|
|
190
|
+
segments={customColors}
|
|
191
|
+
aria-label="Quarterly revenue split"
|
|
192
|
+
showLegend
|
|
193
|
+
showValues
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
),
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
export const PartialFill: Story = {
|
|
200
|
+
name: "Partial fill (max prop)",
|
|
201
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
202
|
+
<div className="w-80 flex flex-col gap-2">
|
|
203
|
+
<p className="text-xs text-muted-foreground">
|
|
204
|
+
70 GB used of 128 GB — segments fill only the used portion
|
|
205
|
+
</p>
|
|
206
|
+
<ProgressStack
|
|
207
|
+
segments={[
|
|
208
|
+
{ value: 38, label: "Documents" },
|
|
209
|
+
{ value: 22, label: "Media" },
|
|
210
|
+
{ value: 10, label: "System" },
|
|
211
|
+
]}
|
|
212
|
+
max={128}
|
|
213
|
+
aria-label="Storage: 70 of 128 GB used"
|
|
214
|
+
showLegend
|
|
215
|
+
formatValue={(v) => `${v} GB`}
|
|
216
|
+
/>
|
|
217
|
+
</div>
|
|
218
|
+
),
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
export const CustomFormat: Story = {
|
|
222
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
223
|
+
<div className="w-80">
|
|
224
|
+
<ProgressStack
|
|
225
|
+
segments={[
|
|
226
|
+
{ value: 42_000, label: "Engineering" },
|
|
227
|
+
{ value: 28_000, label: "Design" },
|
|
228
|
+
{ value: 18_000, label: "Marketing" },
|
|
229
|
+
{ value: 12_000, label: "Operations" },
|
|
230
|
+
]}
|
|
231
|
+
aria-label="Annual budget allocation"
|
|
232
|
+
showLegend
|
|
233
|
+
showValues
|
|
234
|
+
formatValue={(v) =>
|
|
235
|
+
`$${(v / 1000).toFixed(0)}k`
|
|
236
|
+
}
|
|
237
|
+
/>
|
|
238
|
+
</div>
|
|
239
|
+
),
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const RealisticUse: Story = {
|
|
243
|
+
parameters: { controls: { disable: true } }, render: () => (
|
|
244
|
+
<div className="w-[480px] rounded-lg border bg-card p-6 flex flex-col gap-6">
|
|
245
|
+
<div>
|
|
246
|
+
<p className="text-xs font-medium uppercase tracking-wide text-muted-foreground mb-3">
|
|
247
|
+
Repository storage
|
|
248
|
+
</p>
|
|
249
|
+
<ProgressStack
|
|
250
|
+
segments={storageSegments}
|
|
251
|
+
aria-label="Repository storage breakdown"
|
|
252
|
+
showLegend
|
|
253
|
+
showValues
|
|
254
|
+
size="default"
|
|
255
|
+
formatValue={(v, t) => `${Math.round((v / t) * 100)}%`}
|
|
256
|
+
/>
|
|
257
|
+
</div>
|
|
258
|
+
<div>
|
|
259
|
+
<p className="text-xs font-medium uppercase tracking-wide text-muted-foreground mb-3">
|
|
260
|
+
Q3 budget utilization
|
|
261
|
+
</p>
|
|
262
|
+
<ProgressStack
|
|
263
|
+
segments={budgetSegments}
|
|
264
|
+
aria-label="Q3 budget by department"
|
|
265
|
+
showLegend
|
|
266
|
+
showValues
|
|
267
|
+
size="default"
|
|
268
|
+
formatValue={(v) => `$${v}k`}
|
|
269
|
+
/>
|
|
270
|
+
</div>
|
|
271
|
+
<div>
|
|
272
|
+
<p className="text-xs font-medium uppercase tracking-wide text-muted-foreground mb-3">
|
|
273
|
+
Token coverage (partially filled)
|
|
274
|
+
</p>
|
|
275
|
+
<ProgressStack
|
|
276
|
+
segments={skillSegments}
|
|
277
|
+
max={100}
|
|
278
|
+
aria-label="Token documentation coverage"
|
|
279
|
+
showLegend
|
|
280
|
+
showValues
|
|
281
|
+
size="sm"
|
|
282
|
+
formatValue={(v) => `${v}%`}
|
|
283
|
+
/>
|
|
284
|
+
</div>
|
|
285
|
+
</div>
|
|
286
|
+
),
|
|
287
|
+
};
|