@behavioral-agentic-design-system/core 0.40.0 → 0.45.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 +41 -9
- package/scripts/a11y-lint.cjs +66 -3
- package/scripts/check-spec.mjs +73 -0
- package/scripts/deal-directions.mjs +186 -0
- package/scripts/health-report.mjs +23 -3
- package/scripts/lib/counted-lint.mjs +100 -0
- package/scripts/lib/marketing-library.mjs +129 -0
- package/scripts/lib/on-system.mjs +249 -0
- package/scripts/lib/random.mjs +22 -0
- package/scripts/lib/spec-parse.d.mts +25 -0
- package/scripts/lib/spec-parse.mjs +188 -0
- package/scripts/lib/tells.mjs +128 -0
- package/scripts/lint-css-vars.mjs +175 -0
- package/scripts/lint-html-nesting.mjs +116 -0
- package/scripts/lint-live-ctas.mjs +138 -0
- package/scripts/lint-slop.mjs +25 -1
- package/scripts/on-system-score.mjs +95 -0
- package/scripts/slop-rules.mjs +1 -1
- package/scripts/source-images.mjs +180 -0
- package/scripts/ux-tells.mjs +78 -0
- package/scripts/wcag-audit.cjs +72 -5
- package/src/api/brand-colors.ts +3 -0
- package/src/api/brand-fonts.ts +3 -0
- package/src/api/brand-mark.ts +6 -1
- package/src/api/dev-write-guard.ts +53 -0
- package/src/api/layers/file.ts +7 -4
- package/src/api/onboarding-extract.ts +85 -30
- package/src/api/onboarding.ts +3 -0
- package/src/api/save-tokens.ts +3 -0
- package/src/app/layout.tsx +6 -0
- package/src/app/opengraph-image.tsx +5 -0
- package/src/app/preview/canvas/page.tsx +12 -0
- package/src/app/preview/components/page.tsx +2003 -2
- package/src/app/preview/studio/blank-screen.tsx +143 -0
- package/src/app/preview/studio/page.tsx +7 -0
- package/src/app/shell.tsx +168 -49
- package/src/components/Foundations/Motion.stories.tsx +1 -0
- package/src/components/canvas/canvas.tsx +458 -0
- package/src/components/canvas/layout.ts +72 -0
- package/src/components/canvas/parse-canvas.ts +32 -0
- package/src/components/canvas/sample.ts +90 -0
- package/src/components/canvas/spec-frame.tsx +43 -0
- package/src/components/canvas/types.ts +33 -0
- package/src/components/customize/design-controls.tsx +16 -1
- package/src/components/docs-tab.tsx +7 -7
- package/src/components/home-recent.tsx +73 -0
- package/src/components/home-tab.tsx +13 -13
- package/src/components/layers-tab.tsx +2 -2
- package/src/components/markdown-preview.tsx +60 -12
- package/src/components/studio/control-panel.tsx +299 -0
- package/src/components/studio/control-row.tsx +77 -0
- package/src/components/studio/preview-frame.tsx +165 -0
- package/src/components/studio/preview-pane.tsx +247 -0
- package/src/components/studio/studio.tsx +158 -0
- package/src/components/studio/types.ts +218 -0
- package/src/components/studio/use-studio-tweaks.ts +128 -0
- package/src/components/studio/use-studio-view-state.ts +72 -0
- package/src/components/ui/anchor.tsx +37 -3
- package/src/components/ui/attachment.tsx +211 -0
- package/src/components/ui/autocomplete.tsx +1 -1
- package/src/components/ui/chart.tsx +3 -0
- package/src/components/ui/code.tsx +1 -1
- package/src/components/ui/color-picker.tsx +21 -5
- package/src/components/ui/data-table.tsx +64 -3
- package/src/components/ui/date-field.tsx +1 -1
- package/src/components/ui/editable.tsx +1 -0
- package/src/components/ui/faceted-filter.tsx +187 -0
- package/src/components/ui/gauge-chart.tsx +252 -0
- package/src/components/ui/heatmap.tsx +256 -0
- package/src/components/ui/index.ts +9 -0
- package/src/components/ui/infinite-scroll.tsx +103 -0
- package/src/components/ui/inline-edit.tsx +175 -0
- package/src/components/ui/json-input.tsx +351 -0
- package/src/components/ui/month-picker.tsx +1 -1
- package/src/components/ui/navigation-progress.tsx +281 -0
- package/src/components/ui/number-input.tsx +27 -7
- package/src/components/ui/otp-input.tsx +208 -0
- package/src/components/ui/password-input.tsx +2 -1
- package/src/components/ui/password-strength-input.tsx +288 -0
- package/src/components/ui/phone-input.tsx +274 -0
- package/src/components/ui/pill.tsx +140 -0
- package/src/components/ui/popover.tsx +27 -4
- package/src/components/ui/scroll-progress.tsx +100 -0
- package/src/components/ui/search-input.tsx +1 -1
- package/src/components/ui/snackbar.tsx +393 -0
- package/src/components/ui/sortable-list.tsx +342 -0
- package/src/components/ui/squircle.tsx +1 -1
- package/src/components/ui/table.tsx +1 -1
- package/src/components/ui/tags-input.tsx +1 -1
- package/src/components/ui/timer.tsx +1 -0
- package/src/components/ui/tour.tsx +1 -3
- package/src/components/ui/transfer-list.tsx +13 -26
- package/src/components/ui/week-picker.tsx +1 -1
- package/src/components/ui/year-picker.tsx +1 -1
- package/src/data/component-added.json +958 -0
- package/src/data/docs-index.ts +36 -0
- package/src/hooks/use-global-mono-font.ts +1 -0
- package/src/hooks/use-global-primary-color.ts +1 -0
- package/src/hooks/use-global-sans-font.ts +1 -0
- package/src/hooks/use-global-serif-font.ts +1 -0
- package/src/hooks/use-global-type-scale.ts +17 -2
- package/src/hooks/use-mobile.ts +2 -0
- package/src/hooks/use-sync-type-scale.ts +7 -11
- package/src/lib/clamp.ts +2 -0
- package/src/lib/spec-parse.ts +4 -0
- package/src/lib/svg-sanitize.ts +19 -9
- package/src/stories/Anchor.stories.tsx +54 -0
- package/src/stories/Attachment.stories.tsx +189 -0
- package/src/stories/Autocomplete.stories.tsx +2 -0
- package/src/stories/Canvas.stories.tsx +45 -0
- package/src/stories/Chart.stories.tsx +4 -0
- package/src/stories/Code.stories.tsx +1 -0
- package/src/stories/ColorPicker.stories.tsx +41 -0
- package/src/stories/DataTable.stories.tsx +30 -0
- package/src/stories/DateField.stories.tsx +21 -0
- package/src/stories/Editable.stories.tsx +2 -0
- package/src/stories/FacetedFilter.stories.tsx +197 -0
- package/src/stories/GaugeChart.stories.tsx +169 -0
- package/src/stories/Heatmap.stories.tsx +172 -0
- package/src/stories/InfiniteScroll.stories.tsx +225 -0
- package/src/stories/InlineEdit.stories.tsx +106 -0
- package/src/stories/JsonInput.stories.tsx +212 -0
- package/src/stories/MarkdownPreview.stories.tsx +53 -0
- package/src/stories/MonthPicker.stories.tsx +21 -0
- package/src/stories/NavigationProgress.stories.tsx +159 -0
- package/src/stories/NumberInput.stories.tsx +26 -0
- package/src/stories/OtpInput.stories.tsx +110 -0
- package/src/stories/PasswordInput.stories.tsx +4 -0
- package/src/stories/PasswordStrengthInput.stories.tsx +211 -0
- package/src/stories/PhoneInput.stories.tsx +127 -0
- package/src/stories/Pill.stories.tsx +201 -0
- package/src/stories/Popover.stories.tsx +29 -1
- package/src/stories/Portal.stories.tsx +3 -1
- package/src/stories/ScrollProgress.stories.tsx +117 -0
- package/src/stories/SearchInput.stories.tsx +2 -0
- package/src/stories/Snackbar.stories.tsx +315 -0
- package/src/stories/SortableList.stories.tsx +263 -0
- package/src/stories/Squircle.stories.tsx +1 -0
- package/src/stories/Table.stories.tsx +1 -0
- package/src/stories/TagsInput.stories.tsx +2 -0
- package/src/stories/Timer.stories.tsx +26 -0
- package/src/stories/Tour.stories.tsx +1 -0
- package/src/stories/TransferList.stories.tsx +4 -0
- package/src/stories/WeekPicker.stories.tsx +21 -0
- package/src/stories/YearPicker.stories.tsx +21 -0
- package/src/stories/story-groups.json +33 -16
- package/src/tokens.json +82 -54
|
@@ -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
|
-
{/*
|
|
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
|
+
|
|
@@ -103,6 +103,8 @@ export const Loading: Story = {
|
|
|
103
103
|
),
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
// Enter pressed to confirm an IME candidate (Japanese, Chinese, Korean) is ignored by this component.
|
|
107
|
+
// Not scriptable in a story; check by hand with an IME on.
|
|
106
108
|
export const RealisticUse: Story = {
|
|
107
109
|
decorators: [
|
|
108
110
|
(Story) => (
|