@behavioral-agentic-design-system/core 0.40.0 → 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.
Files changed (60) hide show
  1. package/README.md +2 -0
  2. package/package.json +19 -3
  3. package/scripts/a11y-lint.cjs +41 -2
  4. package/scripts/health-report.mjs +16 -2
  5. package/scripts/lint-slop.mjs +25 -1
  6. package/scripts/wcag-audit.cjs +72 -5
  7. package/src/app/opengraph-image.tsx +5 -0
  8. package/src/app/preview/components/page.tsx +1269 -2
  9. package/src/app/shell.tsx +8 -5
  10. package/src/components/Foundations/Motion.stories.tsx +1 -0
  11. package/src/components/customize/design-controls.tsx +16 -1
  12. package/src/components/studio/studio.tsx +153 -0
  13. package/src/components/ui/anchor.tsx +37 -3
  14. package/src/components/ui/attachment.tsx +211 -0
  15. package/src/components/ui/chart.tsx +3 -0
  16. package/src/components/ui/code.tsx +1 -1
  17. package/src/components/ui/color-picker.tsx +1 -1
  18. package/src/components/ui/gauge-chart.tsx +238 -0
  19. package/src/components/ui/heatmap.tsx +256 -0
  20. package/src/components/ui/index.ts +9 -0
  21. package/src/components/ui/infinite-scroll.tsx +103 -0
  22. package/src/components/ui/json-input.tsx +351 -0
  23. package/src/components/ui/navigation-progress.tsx +281 -0
  24. package/src/components/ui/number-input.tsx +1 -4
  25. package/src/components/ui/password-input.tsx +2 -1
  26. package/src/components/ui/password-strength-input.tsx +288 -0
  27. package/src/components/ui/pill.tsx +140 -0
  28. package/src/components/ui/popover.tsx +27 -4
  29. package/src/components/ui/scroll-progress.tsx +100 -0
  30. package/src/components/ui/snackbar.tsx +393 -0
  31. package/src/components/ui/sortable-list.tsx +342 -0
  32. package/src/components/ui/squircle.tsx +1 -1
  33. package/src/components/ui/table.tsx +1 -1
  34. package/src/components/ui/tour.tsx +1 -3
  35. package/src/data/docs-index.ts +24 -0
  36. package/src/lib/clamp.ts +2 -0
  37. package/src/stories/Anchor.stories.tsx +54 -0
  38. package/src/stories/Attachment.stories.tsx +189 -0
  39. package/src/stories/Chart.stories.tsx +4 -0
  40. package/src/stories/Code.stories.tsx +1 -0
  41. package/src/stories/ColorPicker.stories.tsx +1 -0
  42. package/src/stories/GaugeChart.stories.tsx +163 -0
  43. package/src/stories/Heatmap.stories.tsx +172 -0
  44. package/src/stories/InfiniteScroll.stories.tsx +225 -0
  45. package/src/stories/JsonInput.stories.tsx +212 -0
  46. package/src/stories/NavigationProgress.stories.tsx +159 -0
  47. package/src/stories/NumberInput.stories.tsx +1 -0
  48. package/src/stories/PasswordInput.stories.tsx +4 -0
  49. package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
  50. package/src/stories/Pill.stories.tsx +201 -0
  51. package/src/stories/Popover.stories.tsx +29 -1
  52. package/src/stories/Portal.stories.tsx +3 -1
  53. package/src/stories/ScrollProgress.stories.tsx +117 -0
  54. package/src/stories/Snackbar.stories.tsx +315 -0
  55. package/src/stories/SortableList.stories.tsx +263 -0
  56. package/src/stories/Squircle.stories.tsx +1 -0
  57. package/src/stories/Table.stories.tsx +1 -0
  58. package/src/stories/Tour.stories.tsx +1 -0
  59. package/src/stories/story-groups.json +17 -6
  60. package/LICENSE +0 -21
@@ -0,0 +1,211 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import { PasswordStrengthInput } from "@behavioral-agentic-design-system/core/components/ui/password-strength-input"
4
+ import { Label } from "@behavioral-agentic-design-system/core/components/ui/label"
5
+ import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
6
+
7
+ const meta: Meta<typeof PasswordStrengthInput> = {
8
+ title: "Components/Forms/PasswordStrengthInput",
9
+ component: PasswordStrengthInput,
10
+ parameters: { layout: "centered" },
11
+ args: {
12
+ placeholder: "New password",
13
+ autoComplete: "new-password",
14
+ style: { width: 320 },
15
+ },
16
+ }
17
+
18
+ export default meta
19
+ type Story = StoryObj<typeof PasswordStrengthInput>
20
+
21
+ // ─── Basic states ─────────────────────────────────────────────────────────────
22
+
23
+ export const Default: Story = {}
24
+
25
+ export const ShowHints: Story = {
26
+ args: { showHints: true },
27
+ }
28
+
29
+ export const HideLabel: Story = {
30
+ args: { showLabel: false },
31
+ name: "Variant_HideLabel",
32
+ }
33
+
34
+ export const Segments_3: Story = {
35
+ name: "Variant_Segments3",
36
+ args: { segments: 3 },
37
+ }
38
+
39
+ export const Segments_5: Story = {
40
+ name: "Variant_Segments5",
41
+ args: { segments: 5 },
42
+ }
43
+
44
+ // ─── Sizes ────────────────────────────────────────────────────────────────────
45
+
46
+ export const Size_Sm: Story = {
47
+ args: { size: "sm" },
48
+ }
49
+
50
+ export const Size_Lg: Story = {
51
+ args: { size: "lg" },
52
+ }
53
+
54
+ export const Size_Xl: Story = {
55
+ args: { size: "xl" },
56
+ }
57
+
58
+ // ─── Disabled ─────────────────────────────────────────────────────────────────
59
+
60
+ export const Disabled: Story = {
61
+ args: { disabled: true },
62
+ }
63
+
64
+ // ─── Strength levels (controlled) ────────────────────────────────────────────
65
+
66
+ /** Demonstrates the four filled visual states without user interaction. */
67
+ export const Variant_StrengthWeak: Story = {
68
+ name: "Variant_StrengthWeak",
69
+ args: { value: "pass", onChange: () => {} },
70
+ }
71
+
72
+ export const Variant_StrengthFair: Story = {
73
+ name: "Variant_StrengthFair",
74
+ args: { value: "password1", onChange: () => {} },
75
+ }
76
+
77
+ export const Variant_StrengthGood: Story = {
78
+ name: "Variant_StrengthGood",
79
+ args: { value: "Password123", onChange: () => {} },
80
+ }
81
+
82
+ export const Variant_StrengthStrong: Story = {
83
+ name: "Variant_StrengthStrong",
84
+ args: { value: "P@ssword123!!", onChange: () => {} },
85
+ }
86
+
87
+ // ─── Realistic use: signup form ───────────────────────────────────────────────
88
+
89
+ /**
90
+ * A signup form using real names from the BADS content pool.
91
+ * Demonstrates controlled usage with form submission.
92
+ */
93
+ export const RealisticUse: Story = {
94
+ parameters: { controls: { disable: true } },
95
+ render: () => {
96
+ function SignupForm() {
97
+ const [password, setPassword] = React.useState("")
98
+ const [submitted, setSubmitted] = React.useState(false)
99
+
100
+ return submitted ? (
101
+ <div className="flex w-80 flex-col gap-3 rounded-lg border border-border bg-card p-5">
102
+ <p className="text-sm text-muted-foreground">
103
+ Welcome, Jordan — your account is ready.
104
+ </p>
105
+ <Button
106
+ size="sm"
107
+ variant="outline"
108
+ onClick={() => {
109
+ setPassword("")
110
+ setSubmitted(false)
111
+ }}
112
+ >
113
+ Start over
114
+ </Button>
115
+ </div>
116
+ ) : (
117
+ <form
118
+ className="flex w-80 flex-col gap-4 rounded-lg border border-border bg-card p-5"
119
+ onSubmit={(e) => {
120
+ e.preventDefault()
121
+ if (password.length >= 6) setSubmitted(true)
122
+ }}
123
+ >
124
+ <div className="space-y-1">
125
+ <h2 className="text-base font-semibold">Create your account</h2>
126
+ <p className="text-sm text-muted-foreground">
127
+ Northwind Health — design system access
128
+ </p>
129
+ </div>
130
+
131
+ <div className="flex flex-col gap-1.5">
132
+ <Label htmlFor="signup-email">Email</Label>
133
+ <input
134
+ id="signup-email"
135
+ type="email"
136
+ defaultValue="jordan.reeves@northwindhealth.com"
137
+ readOnly
138
+ className="h-9 rounded-md border border-input bg-transparent px-3 text-sm opacity-60 cursor-not-allowed"
139
+ />
140
+ </div>
141
+
142
+ <div className="flex flex-col gap-1.5">
143
+ <Label htmlFor="signup-password">Password</Label>
144
+ <PasswordStrengthInput
145
+ id="signup-password"
146
+ value={password}
147
+ onChange={(e) => setPassword(e.target.value)}
148
+ placeholder="Create a strong password"
149
+ autoComplete="new-password"
150
+ showHints
151
+ />
152
+ </div>
153
+
154
+ <Button
155
+ type="submit"
156
+ size="xl"
157
+ className="w-full"
158
+ disabled={password.length < 6}
159
+ >
160
+ Create account
161
+ </Button>
162
+ </form>
163
+ )
164
+ }
165
+ return <SignupForm />
166
+ },
167
+ }
168
+
169
+ // ─── Custom strength function ─────────────────────────────────────────────────
170
+
171
+ /**
172
+ * Demonstrates a custom strengthFn that enforces strict rules
173
+ * (e.g., minimum 10 chars + special char required for "Strong").
174
+ */
175
+ export const Variant_CustomStrengthFn: Story = {
176
+ name: "Variant_CustomStrengthFn",
177
+ parameters: { controls: { disable: true } },
178
+ render: () => {
179
+ function StrictForm() {
180
+ const [pw, setPw] = React.useState("")
181
+
182
+ function strictStrengthFn(value: string): 0 | 1 | 2 | 3 | 4 {
183
+ if (!value.length) return 0
184
+ let score = 0
185
+ if (value.length >= 10) score++
186
+ if (value.length >= 16) score++
187
+ if (/[A-Z]/.test(value) && /[a-z]/.test(value)) score++
188
+ if (/[0-9]/.test(value) && /[^A-Za-z0-9]/.test(value)) score++
189
+ return Math.min(4, Math.max(1, score)) as 0 | 1 | 2 | 3 | 4
190
+ }
191
+
192
+ return (
193
+ <div className="flex w-80 flex-col gap-3">
194
+ <p className="text-sm text-muted-foreground">
195
+ Strict scorer — requires ≥10 chars + symbol + mixed case for
196
+ "Strong."
197
+ </p>
198
+ <PasswordStrengthInput
199
+ value={pw}
200
+ onChange={(e) => setPw(e.target.value)}
201
+ placeholder="API key passphrase"
202
+ strengthFn={strictStrengthFn}
203
+ segments={5}
204
+ showHints
205
+ />
206
+ </div>
207
+ )
208
+ }
209
+ return <StrictForm />
210
+ },
211
+ }
@@ -0,0 +1,201 @@
1
+ import type { Meta, StoryObj } from "@storybook/react";
2
+ import { Pill, PillGroup } from "@behavioral-agentic-design-system/core/components/ui/pill";
3
+ import { Avatar, AvatarFallback } from "@behavioral-agentic-design-system/core/components/ui/avatar";
4
+ import { GitBranch, Globe, Lock, Palette } from "lucide-react";
5
+
6
+ const meta: Meta<typeof Pill> = {
7
+ title: "Components/Badges and avatars/Pill",
8
+ component: Pill,
9
+ parameters: { layout: "centered" },
10
+ tags: ["autodocs"],
11
+ argTypes: {
12
+ variant: { control: "select", options: ["default", "outline", "muted"] },
13
+ size: { control: "select", options: ["sm", "md", "lg"] },
14
+ disabled: { control: "boolean" },
15
+ },
16
+ };
17
+
18
+ export default meta;
19
+ type Story = StoryObj<typeof meta>;
20
+
21
+ // Labels come from content/personas/bads.json → primary.jargon / names / orgs
22
+ // (the real-content rule — no placeholder strings). Pill takes its text as
23
+ // children, unlike Tag's `label` prop.
24
+ export const Default: Story = {
25
+ args: { children: "design tokens" },
26
+ };
27
+
28
+ // Variant and size stories spread args into every pill in the row, so the
29
+ // Controls panel re-themes the whole group while the three labels stay fixed.
30
+ const jargonRow = (args: Story["args"]) => (
31
+ <PillGroup>
32
+ <Pill {...args}>design tokens</Pill>
33
+ <Pill {...args}>semantic layer</Pill>
34
+ <Pill {...args}>a11y contract</Pill>
35
+ </PillGroup>
36
+ );
37
+
38
+ export const Variant_Default: Story = {
39
+ args: { variant: "default" },
40
+ render: (args) => jargonRow(args),
41
+ };
42
+
43
+ export const Variant_Outline: Story = {
44
+ args: { variant: "outline" },
45
+ render: (args) => jargonRow(args),
46
+ };
47
+
48
+ export const Variant_Muted: Story = {
49
+ args: { variant: "muted" },
50
+ render: (args) => jargonRow(args),
51
+ };
52
+
53
+ // One of each variant at the given size. sm is the default: 14px text (BADS
54
+ // text-xs), the dense-metadata register.
55
+ const variantRow = (args: Story["args"]) => (
56
+ <PillGroup>
57
+ <Pill {...args}>design tokens</Pill>
58
+ <Pill {...args} variant="outline">semantic layer</Pill>
59
+ <Pill {...args} variant="muted">a11y contract</Pill>
60
+ </PillGroup>
61
+ );
62
+
63
+ export const Size_SM: Story = {
64
+ args: { size: "sm" },
65
+ render: (args) => variantRow(args),
66
+ };
67
+
68
+ export const Size_MD: Story = {
69
+ args: { size: "md" },
70
+ render: (args) => variantRow(args),
71
+ };
72
+
73
+ export const Size_LG: Story = {
74
+ args: { size: "lg" },
75
+ render: (args) => variantRow(args),
76
+ };
77
+
78
+ // Presentational only — Pill has no interactive state to disable. The dim
79
+ // mirrors a disabled owning control (an archived row, a locked fieldset);
80
+ // that control carries the disabled semantics for assistive tech.
81
+ export const Disabled: Story = {
82
+ args: { disabled: true },
83
+ render: (args) => variantRow(args),
84
+ };
85
+
86
+ // Leading icon slot: Lucide at strokeWidth 1.5, sized per pill size
87
+ // (size-3 at sm, size-3.5 at md, size-4 at lg). Fixed demo — three pills at
88
+ // three sizes, so there is nothing for the Controls panel to drive.
89
+ export const WithIcon: Story = {
90
+ parameters: { controls: { disable: true } },
91
+ render: () => (
92
+ <PillGroup>
93
+ <Pill icon={<GitBranch strokeWidth={1.5} />}>main</Pill>
94
+ <Pill size="md" variant="outline" icon={<Globe strokeWidth={1.5} />}>
95
+ design.bads.com
96
+ </Pill>
97
+ <Pill size="lg" variant="muted" icon={<Lock strokeWidth={1.5} />}>
98
+ private
99
+ </Pill>
100
+ </PillGroup>
101
+ ),
102
+ };
103
+
104
+ // An owner pill: the icon slot takes a 20px Avatar (size="xs") and the pill
105
+ // drops its left padding so the avatar sits flush, Mantine-style. lg gives
106
+ // the avatar room; at sm the avatar would be taller than the text line.
107
+ export const WithAvatar: Story = {
108
+ parameters: { controls: { disable: true } },
109
+ render: () => (
110
+ <PillGroup>
111
+ <Pill
112
+ size="lg"
113
+ className="pl-1"
114
+ icon={
115
+ <Avatar size="xs">
116
+ <AvatarFallback className="text-xs">JR</AvatarFallback>
117
+ </Avatar>
118
+ }
119
+ >
120
+ Jordan Reeves
121
+ </Pill>
122
+ <Pill
123
+ size="lg"
124
+ variant="outline"
125
+ className="pl-1"
126
+ icon={
127
+ <Avatar size="xs">
128
+ <AvatarFallback className="text-xs">SP</AvatarFallback>
129
+ </Avatar>
130
+ }
131
+ >
132
+ Seo-yun Park
133
+ </Pill>
134
+ </PillGroup>
135
+ ),
136
+ };
137
+
138
+ // Long-label contract: the pill truncates inside a narrow parent instead of
139
+ // bleeding sideways. The full value stays recoverable via `title`.
140
+ export const LongLabel: Story = {
141
+ parameters: { controls: { disable: true } },
142
+ render: () => (
143
+ <div className="w-56 rounded-lg border p-3">
144
+ <PillGroup>
145
+ <Pill title="Wilhelmina-Constance Featherstonehaugh-Vance">
146
+ Wilhelmina-Constance Featherstonehaugh-Vance
147
+ </Pill>
148
+ <Pill variant="outline" title="antidisestablishmentarianismphilosophical-test">
149
+ antidisestablishmentarianismphilosophical-test
150
+ </Pill>
151
+ <Pill variant="muted">李雪芹</Pill>
152
+ </PillGroup>
153
+ </div>
154
+ ),
155
+ };
156
+
157
+ // Metadata row on a component-registry card: taxonomy pills, an owner pill,
158
+ // a count pill. Nothing here is a status (Badge), nothing is removable (Tag),
159
+ // nothing toggles (Chip).
160
+ export const RealisticUse: Story = {
161
+ parameters: { controls: { disable: true } },
162
+ render: () => (
163
+ <div className="w-[360px] space-y-3 rounded-lg border p-4">
164
+ <div className="flex items-start justify-between gap-3">
165
+ <div className="min-w-0">
166
+ <p className="text-base font-semibold">Button</p>
167
+ <p className="text-sm text-muted-foreground">
168
+ Northwind Health · updated 2026-05-26
169
+ </p>
170
+ </div>
171
+ <Pill variant="outline" icon={<Palette strokeWidth={1.5} />}>
172
+ 36 components
173
+ </Pill>
174
+ </div>
175
+ <PillGroup aria-label="Topics">
176
+ <Pill>design tokens</Pill>
177
+ <Pill>a11y contract</Pill>
178
+ <Pill>CVA variants</Pill>
179
+ <Pill variant="muted">7:1 contrast</Pill>
180
+ <Pill variant="muted">44×44px target</Pill>
181
+ </PillGroup>
182
+ <div className="flex items-center justify-between gap-3 border-t pt-3">
183
+ <Pill
184
+ size="md"
185
+ variant="outline"
186
+ className="pl-1"
187
+ icon={
188
+ <Avatar size="xs">
189
+ <AvatarFallback className="text-xs">JR</AvatarFallback>
190
+ </Avatar>
191
+ }
192
+ >
193
+ jordan.reeves
194
+ </Pill>
195
+ <Pill size="md" variant="muted" icon={<GitBranch strokeWidth={1.5} />}>
196
+ main
197
+ </Pill>
198
+ </div>
199
+ </div>
200
+ ),
201
+ };
@@ -27,11 +27,39 @@ export const Default: Story = {
27
27
  </Popover>),
28
28
  };
29
29
 
30
+ export const Variant_WithArrow: Story = {
31
+ name: "Variant — with arrow",
32
+ parameters: { controls: { disable: true } },
33
+ render: () => (
34
+ <div className="flex gap-6 items-start pt-12">
35
+ <Popover>
36
+ <PopoverTrigger asChild><Button variant="outline" size="sm">Below</Button></PopoverTrigger>
37
+ <PopoverContent showArrow className="w-56">
38
+ <p className="text-sm">Arrow points up at the trigger.</p>
39
+ </PopoverContent>
40
+ </Popover>
41
+ <Popover>
42
+ <PopoverTrigger asChild><Button variant="outline" size="sm">Start-aligned</Button></PopoverTrigger>
43
+ <PopoverContent showArrow align="start" className="w-56">
44
+ <p className="text-sm">Arrow tracks to the start side of the panel.</p>
45
+ </PopoverContent>
46
+ </Popover>
47
+ <Popover>
48
+ <PopoverTrigger asChild><Button variant="outline" size="sm">End-aligned</Button></PopoverTrigger>
49
+ <PopoverContent showArrow align="end" className="w-56">
50
+ <p className="text-sm">Arrow tracks to the end side of the panel.</p>
51
+ </PopoverContent>
52
+ </Popover>
53
+ </div>
54
+ ),
55
+ };
56
+
30
57
  export const RealisticUse: Story = {
31
58
  render: () => (<Popover>
32
59
  <PopoverTrigger asChild><Button variant="outline">Open popover</Button></PopoverTrigger>
33
- <PopoverContent className="w-64">
60
+ <PopoverContent showArrow className="w-64">
34
61
  <p className="text-sm">Place anything inside the popover — settings, filters, a small form.</p>
35
62
  </PopoverContent>
36
63
  </Popover>),
37
64
  };
65
+
@@ -96,7 +96,9 @@ export const WithThemeScope: Story = {
96
96
  parameters: { controls: { disable: true } },
97
97
  render: () => (
98
98
  <>
99
- {/* Scope-local variable, defined from tokens (no hardcoded color). */}
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. */}
100
102
  <style>{`.portal-demo-scope { --demo-panel: var(--color-primary); --demo-panel-fg: var(--color-primary-foreground); }`}</style>
101
103
  <div className="portal-demo-scope flex w-96 flex-col gap-4 text-sm">
102
104
  <div className="rounded-lg border border-border bg-card p-4">
@@ -0,0 +1,117 @@
1
+ import type { Meta, StoryObj } from "@storybook/react"
2
+ import * as React from "react"
3
+ import { ScrollProgress } from "@behavioral-agentic-design-system/core/components/ui/scroll-progress"
4
+
5
+ const meta: Meta<typeof ScrollProgress> = {
6
+ title: "Components/Feedback/ScrollProgress",
7
+ component: ScrollProgress,
8
+ parameters: { layout: "fullscreen" },
9
+ tags: ["autodocs"],
10
+ }
11
+ export default meta
12
+ type Story = StoryObj<typeof ScrollProgress>
13
+
14
+ /** Inline bar inside a fixed-height scroll container (most testable in Storybook). */
15
+ export const Default: Story = {
16
+ parameters: { controls: { disable: true } },
17
+ render: () => {
18
+ const ref = React.useRef<HTMLDivElement>(null)
19
+ return (
20
+ <div ref={ref} className="relative max-h-[360px] overflow-y-auto border rounded-lg">
21
+ <ScrollProgress containerRef={ref} position="sticky" />
22
+ <div className="space-y-6 p-6">
23
+ {Array.from({ length: 16 }, (_, i) => (
24
+ <p key={i} className="text-sm text-muted-foreground">
25
+ Paragraph {i + 1}: Scroll down to see the progress bar advance.
26
+ This simulates a long article or settings panel.
27
+ </p>
28
+ ))}
29
+ </div>
30
+ </div>
31
+ )
32
+ },
33
+ }
34
+
35
+ /** Custom color and height. */
36
+ export const CustomStyle: Story = {
37
+ parameters: { controls: { disable: true } },
38
+ render: () => {
39
+ const ref = React.useRef<HTMLDivElement>(null)
40
+ return (
41
+ <div ref={ref} className="relative max-h-[320px] overflow-y-auto border rounded-lg">
42
+ <ScrollProgress
43
+ containerRef={ref}
44
+ position="sticky"
45
+ height="4px"
46
+ color="var(--destructive)"
47
+ trackColor="transparent"
48
+ />
49
+ <div className="space-y-6 p-6">
50
+ {Array.from({ length: 14 }, (_, i) => (
51
+ <p key={i} className="text-sm text-muted-foreground">
52
+ Item {i + 1}: Custom bar — 4px height, destructive color, no track.
53
+ </p>
54
+ ))}
55
+ </div>
56
+ </div>
57
+ )
58
+ },
59
+ }
60
+
61
+ /** Inline position — placed in flow inside a layout. */
62
+ export const Inline: Story = {
63
+ parameters: { controls: { disable: true } },
64
+ render: () => {
65
+ const ref = React.useRef<HTMLDivElement>(null)
66
+ return (
67
+ <div className="max-w-lg mx-auto space-y-2">
68
+ <div ref={ref} className="relative max-h-[300px] overflow-y-auto rounded-lg border">
69
+ <ScrollProgress containerRef={ref} position="inline" className="mb-0" />
70
+ <div className="space-y-6 p-5">
71
+ {Array.from({ length: 12 }, (_, i) => (
72
+ <p key={i} className="text-sm text-muted-foreground">
73
+ Paragraph {i + 1}: Inline indicator, rendered in document flow above content.
74
+ </p>
75
+ ))}
76
+ </div>
77
+ </div>
78
+ </div>
79
+ )
80
+ },
81
+ }
82
+
83
+ /** Realistic use: article reader with a sticky reading progress indicator. */
84
+ export const RealisticUse: Story = {
85
+ parameters: { controls: { disable: true } },
86
+ render: () => {
87
+ const ref = React.useRef<HTMLDivElement>(null)
88
+ return (
89
+ <div ref={ref} className="relative max-h-[500px] overflow-y-auto">
90
+ <header className="sticky top-0 z-10 border-b bg-background/95 backdrop-blur-sm">
91
+ <ScrollProgress containerRef={ref} position="sticky" />
92
+ <div className="px-5 py-3">
93
+ <p className="text-sm font-medium">Understanding Design Systems</p>
94
+ </div>
95
+ </header>
96
+ <article className="space-y-6 px-5 py-8 max-w-xl">
97
+ <h1 className="text-2xl font-semibold">Understanding Design Systems</h1>
98
+ {[
99
+ "A design system is a collection of reusable components guided by clear standards that can be assembled to build any number of applications.",
100
+ "Great design systems prioritize accessibility as a core constraint — not an afterthought applied at the end of a sprint.",
101
+ "Token-driven systems separate intent from implementation. A semantic token like `--primary` means something; a literal hex value means nothing.",
102
+ "Components are only as good as the context they document. A component without examples of misuse is half a component.",
103
+ "Version discipline keeps a design system trustworthy. Breaking changes are fine; undocumented breaking changes are trust-breaking.",
104
+ "The best design system is the one your team actually uses. A perfect spec shipped to nobody beats an imperfect one adopted everywhere.",
105
+ "Testing a design system is different from testing a product — you are testing the primitives that other tests depend on.",
106
+ "Accessibility testing cannot be delegated entirely to automated tools. A green axe score is a floor, not a ceiling.",
107
+ ].map((para, i) => (
108
+ <p key={i} className="text-sm leading-relaxed text-muted-foreground">
109
+ {para}
110
+ </p>
111
+ ))}
112
+ </article>
113
+ </div>
114
+ )
115
+ },
116
+ }
117
+