@behavioral-agentic-design-system/core 0.39.0 → 0.40.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 +8 -3
- package/scripts/a11y-lint.cjs +93 -39
- package/scripts/a11y-ratchet.mjs +10 -23
- package/scripts/bads-components.mjs +118 -0
- package/scripts/build-tokens.cjs +175 -17
- package/scripts/check-stories.mjs +1 -1
- package/scripts/health-report.mjs +52 -10
- package/scripts/lib/scan-roots.cjs +143 -0
- package/scripts/lint-component-source.mjs +100 -0
- package/scripts/lint-microanimation.mjs +267 -0
- package/scripts/lint-slop.mjs +21 -28
- package/scripts/lint-token-intent.mjs +10 -16
- package/scripts/size-audit.cjs +94 -27
- package/scripts/source-of-truth.cjs +58 -0
- package/scripts/ux-smoke.mjs +438 -0
- package/scripts/wcag-audit.cjs +49 -1
- package/src/api/layers/file.ts +2 -0
- package/src/app/preview/components/page.tsx +972 -0
- package/src/app/preview/health/page.tsx +8 -5
- package/src/app/preview/history/page.tsx +11 -0
- package/src/app/shell.tsx +261 -87
- package/src/components/customize/brand-mark-section.tsx +4 -2
- package/src/components/customize/design-controls.tsx +1 -1
- package/src/components/customize/discipline-section.tsx +91 -0
- 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 +9 -4
- package/src/components/home-tab.tsx +3 -0
- package/src/components/ui/accordion.tsx +7 -0
- package/src/components/ui/alert.tsx +1 -0
- package/src/components/ui/announcement-bar.tsx +256 -0
- package/src/components/ui/badge.tsx +1 -0
- package/src/components/ui/callout.tsx +218 -0
- package/src/components/ui/chart.tsx +2 -14
- package/src/components/ui/color-picker.tsx +1 -1
- package/src/components/ui/format-relative-time.tsx +139 -0
- package/src/components/ui/grid.tsx +255 -0
- package/src/components/ui/icon.tsx +108 -0
- package/src/components/ui/index.ts +8 -0
- package/src/components/ui/page-header.tsx +63 -0
- 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/select.tsx +89 -4
- package/src/components/ui/separator.tsx +1 -0
- package/src/components/ui/slider.tsx +83 -3
- package/src/components/ui/sparkline.tsx +15 -15
- package/src/components/ui/textarea.tsx +28 -1
- package/src/data/docs-index.ts +5 -0
- package/src/data/history.json +269 -0
- package/src/hooks/use-reduced-motion.ts +6 -0
- package/src/stories/Accordion.stories.tsx +59 -0
- package/src/stories/Alert.stories.tsx +3 -1
- package/src/stories/AnnouncementBar.stories.tsx +261 -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 +4 -0
- package/src/stories/ColorPicker.stories.tsx +23 -0
- package/src/stories/FormatRelativeTime.stories.tsx +116 -0
- package/src/stories/Grid.stories.tsx +197 -0
- package/src/stories/Icon.stories.tsx +175 -0
- package/src/stories/MultiSelect.stories.tsx +1 -1
- package/src/stories/PageHeader.stories.tsx +102 -0
- package/src/stories/Portal.stories.tsx +189 -0
- package/src/stories/Presence.stories.tsx +228 -0
- package/src/stories/ProgressStack.stories.tsx +287 -0
- package/src/stories/Select.stories.tsx +25 -0
- package/src/stories/Separator.stories.tsx +3 -0
- package/src/stories/Sheet.stories.tsx +9 -3
- package/src/stories/Slider.stories.tsx +54 -5
- package/src/stories/Sparkline.stories.tsx +39 -0
- package/src/stories/Textarea.stories.tsx +18 -0
- package/src/stories/story-groups.json +14 -5
- package/src/styles.css +133 -12
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Grid, GridCol } from "@behavioral-agentic-design-system/core/components/ui/grid";
|
|
4
|
+
import {
|
|
5
|
+
Card,
|
|
6
|
+
CardContent,
|
|
7
|
+
CardDescription,
|
|
8
|
+
CardHeader,
|
|
9
|
+
CardTitle,
|
|
10
|
+
} from "@behavioral-agentic-design-system/core/components/ui/card";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Grid is a non-CVA layout primitive — `Default` + `RealisticUse` per the
|
|
14
|
+
* storybook rule, plus one story per axis (span, offset, responsive) so the
|
|
15
|
+
* literal class maps are exercised end to end. Twelve tracks, fixed; a
|
|
16
|
+
* GridCol spans 1–12 and may be offset by leading empty tracks. The
|
|
17
|
+
* SimpleGrid sibling for unequal columns.
|
|
18
|
+
*/
|
|
19
|
+
const meta: Meta<typeof Grid> = {
|
|
20
|
+
title: "Components/Layout/Grid",
|
|
21
|
+
component: Grid,
|
|
22
|
+
parameters: { layout: "padded" },
|
|
23
|
+
tags: ["autodocs"],
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default meta;
|
|
27
|
+
type Story = StoryObj<typeof meta>;
|
|
28
|
+
|
|
29
|
+
function Cell({ label }: { label: string }) {
|
|
30
|
+
return (
|
|
31
|
+
<div className="flex h-16 items-center justify-center rounded-lg border border-dashed border-border bg-card">
|
|
32
|
+
<span className="truncate text-sm text-muted-foreground">{label}</span>
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const Default: Story = {
|
|
38
|
+
parameters: { controls: { disable: true } },
|
|
39
|
+
render: () => (
|
|
40
|
+
<Grid>
|
|
41
|
+
<GridCol span={8}>
|
|
42
|
+
<Cell label="span 8" />
|
|
43
|
+
</GridCol>
|
|
44
|
+
<GridCol span={4}>
|
|
45
|
+
<Cell label="span 4" />
|
|
46
|
+
</GridCol>
|
|
47
|
+
</Grid>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Spans: Story = {
|
|
52
|
+
parameters: { controls: { disable: true } },
|
|
53
|
+
render: () => (
|
|
54
|
+
<Grid gap="sm">
|
|
55
|
+
<GridCol span={12}>
|
|
56
|
+
<Cell label="12" />
|
|
57
|
+
</GridCol>
|
|
58
|
+
<GridCol span={6}>
|
|
59
|
+
<Cell label="6" />
|
|
60
|
+
</GridCol>
|
|
61
|
+
<GridCol span={6}>
|
|
62
|
+
<Cell label="6" />
|
|
63
|
+
</GridCol>
|
|
64
|
+
<GridCol span={4}>
|
|
65
|
+
<Cell label="4" />
|
|
66
|
+
</GridCol>
|
|
67
|
+
<GridCol span={4}>
|
|
68
|
+
<Cell label="4" />
|
|
69
|
+
</GridCol>
|
|
70
|
+
<GridCol span={4}>
|
|
71
|
+
<Cell label="4" />
|
|
72
|
+
</GridCol>
|
|
73
|
+
<GridCol span={3}>
|
|
74
|
+
<Cell label="3" />
|
|
75
|
+
</GridCol>
|
|
76
|
+
<GridCol span={9}>
|
|
77
|
+
<Cell label="9" />
|
|
78
|
+
</GridCol>
|
|
79
|
+
</Grid>
|
|
80
|
+
),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const Offset: Story = {
|
|
84
|
+
parameters: { controls: { disable: true } },
|
|
85
|
+
render: () => (
|
|
86
|
+
<Grid gap="sm">
|
|
87
|
+
<GridCol span={4} offset={4}>
|
|
88
|
+
<Cell label="span 4 · offset 4" />
|
|
89
|
+
</GridCol>
|
|
90
|
+
<GridCol span={3} offset={2}>
|
|
91
|
+
<Cell label="span 3 · offset 2" />
|
|
92
|
+
</GridCol>
|
|
93
|
+
<GridCol span={5}>
|
|
94
|
+
<Cell label="span 5" />
|
|
95
|
+
</GridCol>
|
|
96
|
+
<GridCol span={6} offset={6}>
|
|
97
|
+
<Cell label="span 6 · offset 6" />
|
|
98
|
+
</GridCol>
|
|
99
|
+
</Grid>
|
|
100
|
+
),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const Responsive: Story = {
|
|
104
|
+
parameters: { controls: { disable: true } },
|
|
105
|
+
render: () => (
|
|
106
|
+
<div>
|
|
107
|
+
<p className="mb-2 text-xs text-muted-foreground">
|
|
108
|
+
{`span={{ base: 12, md: 8 }} / span={{ base: 12, md: 4 }} — resize the viewport`}
|
|
109
|
+
</p>
|
|
110
|
+
<Grid gap="md">
|
|
111
|
+
<GridCol span={{ base: 12, md: 8 }}>
|
|
112
|
+
<Cell label="main" />
|
|
113
|
+
</GridCol>
|
|
114
|
+
<GridCol span={{ base: 12, md: 4 }}>
|
|
115
|
+
<Cell label="aside" />
|
|
116
|
+
</GridCol>
|
|
117
|
+
<GridCol span={{ base: 6, lg: 3 }}>
|
|
118
|
+
<Cell label="quarter" />
|
|
119
|
+
</GridCol>
|
|
120
|
+
<GridCol span={{ base: 6, lg: 3 }}>
|
|
121
|
+
<Cell label="quarter" />
|
|
122
|
+
</GridCol>
|
|
123
|
+
<GridCol span={{ base: 6, lg: 3 }}>
|
|
124
|
+
<Cell label="quarter" />
|
|
125
|
+
</GridCol>
|
|
126
|
+
<GridCol span={{ base: 6, lg: 3 }}>
|
|
127
|
+
<Cell label="quarter" />
|
|
128
|
+
</GridCol>
|
|
129
|
+
</Grid>
|
|
130
|
+
</div>
|
|
131
|
+
),
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const RealisticUse: Story = {
|
|
135
|
+
parameters: { controls: { disable: true } },
|
|
136
|
+
render: () => (
|
|
137
|
+
<Grid gap="lg">
|
|
138
|
+
<GridCol span={{ base: 12, lg: 8 }}>
|
|
139
|
+
<Card>
|
|
140
|
+
<CardHeader>
|
|
141
|
+
<CardTitle>Tokens v2 proposal</CardTitle>
|
|
142
|
+
<CardDescription>
|
|
143
|
+
Jordan Reeves — review May 26, 2026
|
|
144
|
+
</CardDescription>
|
|
145
|
+
</CardHeader>
|
|
146
|
+
<CardContent>
|
|
147
|
+
<p className="text-sm text-muted-foreground">
|
|
148
|
+
Consolidates the spacing scale to eight stops; retires four
|
|
149
|
+
orphaned color tokens. Both CSS files regenerate from a single
|
|
150
|
+
tokens.json change, and every fork picks it up on the next core
|
|
151
|
+
bump.
|
|
152
|
+
</p>
|
|
153
|
+
</CardContent>
|
|
154
|
+
</Card>
|
|
155
|
+
</GridCol>
|
|
156
|
+
<GridCol span={{ base: 12, lg: 4 }}>
|
|
157
|
+
<Card>
|
|
158
|
+
<CardHeader>
|
|
159
|
+
<CardTitle>Reviewers</CardTitle>
|
|
160
|
+
<CardDescription>Sign-off due 2026-05-26</CardDescription>
|
|
161
|
+
</CardHeader>
|
|
162
|
+
<CardContent>
|
|
163
|
+
<ul className="space-y-2 text-sm">
|
|
164
|
+
<li className="flex justify-between gap-3">
|
|
165
|
+
<span className="min-w-0 truncate">Seo-yun Park</span>
|
|
166
|
+
<span className="shrink-0 text-muted-foreground">Approved</span>
|
|
167
|
+
</li>
|
|
168
|
+
<li className="flex justify-between gap-3">
|
|
169
|
+
<span className="min-w-0 truncate">Marcus Lindqvist</span>
|
|
170
|
+
<span className="shrink-0 text-muted-foreground">Pending</span>
|
|
171
|
+
</li>
|
|
172
|
+
<li className="flex justify-between gap-3">
|
|
173
|
+
<span className="min-w-0 truncate">Anika Patel</span>
|
|
174
|
+
<span className="shrink-0 text-muted-foreground">Pending</span>
|
|
175
|
+
</li>
|
|
176
|
+
</ul>
|
|
177
|
+
</CardContent>
|
|
178
|
+
</Card>
|
|
179
|
+
</GridCol>
|
|
180
|
+
{[
|
|
181
|
+
{ label: "Components", value: "36" },
|
|
182
|
+
{ label: "Contrast floor", value: "7:1" },
|
|
183
|
+
{ label: "Story coverage", value: "98.4%" },
|
|
184
|
+
{ label: "Build hours avoided", value: "1,432" },
|
|
185
|
+
].map((stat) => (
|
|
186
|
+
<GridCol key={stat.label} span={{ base: 6, lg: 3 }}>
|
|
187
|
+
<Card>
|
|
188
|
+
<CardHeader>
|
|
189
|
+
<CardDescription>{stat.label}</CardDescription>
|
|
190
|
+
<CardTitle className="text-2xl tabular-nums">{stat.value}</CardTitle>
|
|
191
|
+
</CardHeader>
|
|
192
|
+
</Card>
|
|
193
|
+
</GridCol>
|
|
194
|
+
))}
|
|
195
|
+
</Grid>
|
|
196
|
+
),
|
|
197
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
3
|
+
import {
|
|
4
|
+
Bell,
|
|
5
|
+
CircleAlert,
|
|
6
|
+
CircleCheck,
|
|
7
|
+
Info,
|
|
8
|
+
Palette,
|
|
9
|
+
Search,
|
|
10
|
+
Sparkles,
|
|
11
|
+
TriangleAlert,
|
|
12
|
+
} from "lucide-react"
|
|
13
|
+
import { Icon } from "@behavioral-agentic-design-system/core/components/ui/icon"
|
|
14
|
+
import { ICON_ROLES } from "@behavioral-agentic-design-system/core/lib/get-icon-color"
|
|
15
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
16
|
+
|
|
17
|
+
const meta: Meta<typeof Icon> = {
|
|
18
|
+
title: "Components/Content and data/Icon",
|
|
19
|
+
component: Icon,
|
|
20
|
+
parameters: { layout: "centered" },
|
|
21
|
+
tags: ["autodocs"],
|
|
22
|
+
argTypes: {
|
|
23
|
+
size: { control: "select", options: ["sm", "default", "lg", "xl"] },
|
|
24
|
+
color: { control: "select", options: [undefined, ...ICON_ROLES] },
|
|
25
|
+
label: { control: "text" },
|
|
26
|
+
as: { control: false },
|
|
27
|
+
},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default meta
|
|
31
|
+
type Story = StoryObj<typeof meta>
|
|
32
|
+
|
|
33
|
+
export const Default: Story = {
|
|
34
|
+
args: { size: "default" },
|
|
35
|
+
render: (args) => <Icon as={Search} {...args} />,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function SizeRow({ size }: { size: "sm" | "default" | "lg" | "xl" }) {
|
|
39
|
+
return (
|
|
40
|
+
<div className="flex items-center gap-4">
|
|
41
|
+
<Icon as={Search} size={size} />
|
|
42
|
+
<Icon as={Bell} size={size} />
|
|
43
|
+
<Icon as={Palette} size={size} />
|
|
44
|
+
<Icon as={Sparkles} size={size} />
|
|
45
|
+
<span className="text-xs text-muted-foreground">{size}</span>
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const Size_Sm: Story = {
|
|
51
|
+
args: { size: "sm" },
|
|
52
|
+
render: (args) => <SizeRow size={args.size ?? "sm"} />,
|
|
53
|
+
}
|
|
54
|
+
export const Size_Default: Story = {
|
|
55
|
+
args: { size: "default" },
|
|
56
|
+
render: (args) => <SizeRow size={args.size ?? "default"} />,
|
|
57
|
+
}
|
|
58
|
+
export const Size_Lg: Story = {
|
|
59
|
+
args: { size: "lg" },
|
|
60
|
+
render: (args) => <SizeRow size={args.size ?? "lg"} />,
|
|
61
|
+
}
|
|
62
|
+
export const Size_Xl: Story = {
|
|
63
|
+
args: { size: "xl" },
|
|
64
|
+
render: (args) => <SizeRow size={args.size ?? "xl"} />,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Every semantic role from the `icon-*` token family. `inverse` sits on a
|
|
69
|
+
* filled primary chip because that is the only surface it is meant for.
|
|
70
|
+
*/
|
|
71
|
+
export const ColorRoles: Story = {
|
|
72
|
+
parameters: { controls: { disable: true } },
|
|
73
|
+
render: () => (
|
|
74
|
+
<div className="grid grid-cols-3 gap-x-8 gap-y-4 text-sm">
|
|
75
|
+
{ICON_ROLES.map((role) =>
|
|
76
|
+
role === "inverse" ? (
|
|
77
|
+
<div key={role} className="flex items-center gap-2">
|
|
78
|
+
<span className="inline-flex size-7 items-center justify-center rounded-md bg-primary">
|
|
79
|
+
<Icon as={Sparkles} color={role} />
|
|
80
|
+
</span>
|
|
81
|
+
<span className="text-muted-foreground">{role}</span>
|
|
82
|
+
</div>
|
|
83
|
+
) : (
|
|
84
|
+
<div key={role} className="flex items-center gap-2">
|
|
85
|
+
<Icon as={Sparkles} size="lg" color={role} />
|
|
86
|
+
<span className="text-muted-foreground">{role}</span>
|
|
87
|
+
</div>
|
|
88
|
+
)
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Decorative (default) vs labeled. A decorative icon is `aria-hidden`; a
|
|
96
|
+
* labeled one announces as an image named by its meaning — "Passing", not
|
|
97
|
+
* "check mark".
|
|
98
|
+
*/
|
|
99
|
+
export const Labeled: Story = {
|
|
100
|
+
parameters: { controls: { disable: true } },
|
|
101
|
+
render: () => (
|
|
102
|
+
<div className="flex flex-col gap-3 text-sm">
|
|
103
|
+
<div className="flex items-center gap-2">
|
|
104
|
+
<Icon as={CircleCheck} color="success" />
|
|
105
|
+
<span>Decorative — the text beside it carries the meaning</span>
|
|
106
|
+
</div>
|
|
107
|
+
<div className="flex items-center gap-2">
|
|
108
|
+
<Icon as={CircleCheck} color="success" label="Passing" />
|
|
109
|
+
<span className="text-muted-foreground">
|
|
110
|
+
Labeled — announced as image, “Passing”
|
|
111
|
+
</span>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
),
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* A pre-commit status list from content/personas/bads.json (notifications,
|
|
119
|
+
* error_messages, units): icons colored by role beside their text, plus a
|
|
120
|
+
* Button showing the icon inheriting currentColor from its parent.
|
|
121
|
+
*/
|
|
122
|
+
export const RealisticUse: Story = {
|
|
123
|
+
parameters: { controls: { disable: true } },
|
|
124
|
+
render: () => (
|
|
125
|
+
<div className="w-96 rounded-lg border border-border bg-card p-6">
|
|
126
|
+
<p className="mb-4 text-lg font-semibold">Pre-commit checks</p>
|
|
127
|
+
<ul className="flex flex-col gap-3 text-sm">
|
|
128
|
+
<li className="flex items-start gap-2">
|
|
129
|
+
<Icon as={CircleCheck} color="success" className="mt-0.5" />
|
|
130
|
+
<span>
|
|
131
|
+
<span className="font-medium">Story coverage check passed.</span>{" "}
|
|
132
|
+
<span className="text-muted-foreground">
|
|
133
|
+
All 36 components have matching stories.
|
|
134
|
+
</span>
|
|
135
|
+
</span>
|
|
136
|
+
</li>
|
|
137
|
+
<li className="flex items-start gap-2">
|
|
138
|
+
<Icon as={CircleAlert} color="error" className="mt-0.5" />
|
|
139
|
+
<span>
|
|
140
|
+
<span className="font-medium">Token build failed.</span>{" "}
|
|
141
|
+
<span className="text-muted-foreground">
|
|
142
|
+
Check tokens.json for syntax errors and run pnpm build:tokens
|
|
143
|
+
again.
|
|
144
|
+
</span>
|
|
145
|
+
</span>
|
|
146
|
+
</li>
|
|
147
|
+
<li className="flex items-start gap-2">
|
|
148
|
+
<Icon as={TriangleAlert} color="warning" className="mt-0.5" />
|
|
149
|
+
<span>
|
|
150
|
+
<span className="font-medium">7:1 contrast</span>{" "}
|
|
151
|
+
<span className="text-muted-foreground">
|
|
152
|
+
— two token pairs are AA only.
|
|
153
|
+
</span>
|
|
154
|
+
</span>
|
|
155
|
+
</li>
|
|
156
|
+
<li className="flex items-start gap-2">
|
|
157
|
+
<Icon as={Info} color="info" className="mt-0.5" />
|
|
158
|
+
<span className="text-muted-foreground">
|
|
159
|
+
44×44px target enforced on every CTA.
|
|
160
|
+
</span>
|
|
161
|
+
</li>
|
|
162
|
+
</ul>
|
|
163
|
+
<div className="mt-5 flex gap-2">
|
|
164
|
+
<Button size="xl">
|
|
165
|
+
<Icon as={Search} size="lg" />
|
|
166
|
+
Search components
|
|
167
|
+
</Button>
|
|
168
|
+
<Button size="xl" variant="outline">
|
|
169
|
+
<Icon as={Palette} size="lg" />
|
|
170
|
+
Customize
|
|
171
|
+
</Button>
|
|
172
|
+
</div>
|
|
173
|
+
</div>
|
|
174
|
+
),
|
|
175
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Trigger text is font-medium (text-sm/16px) to satisfy the
|
|
1
|
+
// Trigger text is font-medium (text-sm/16px) to satisfy the BADS-WEIGHT AAA
|
|
2
2
|
// weight floor — text below 18px must be font-medium or heavier.
|
|
3
3
|
import type { Meta, StoryObj } from "@storybook/react"
|
|
4
4
|
import * as React from "react"
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import { PageHeader } from "@behavioral-agentic-design-system/core/components/ui/page-header"
|
|
3
|
+
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof PageHeader> = {
|
|
6
|
+
title: "Components/Layout/PageHeader",
|
|
7
|
+
component: PageHeader,
|
|
8
|
+
parameters: { layout: "padded" },
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
}
|
|
11
|
+
export default meta
|
|
12
|
+
type Story = StoryObj<typeof meta>
|
|
13
|
+
|
|
14
|
+
export const Default: Story = {
|
|
15
|
+
args: {
|
|
16
|
+
title: "Workspace settings",
|
|
17
|
+
},
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const WithDescription: Story = {
|
|
21
|
+
args: {
|
|
22
|
+
title: "Workspace settings",
|
|
23
|
+
description: "Manage your workspace preferences, integrations, and team access.",
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const WithEyebrow: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
eyebrow: "Account",
|
|
30
|
+
title: "Billing & plans",
|
|
31
|
+
description: "Manage your subscription and payment methods.",
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const WithAction: Story = {
|
|
36
|
+
parameters: { controls: { disable: true } },
|
|
37
|
+
render: () => (
|
|
38
|
+
<PageHeader
|
|
39
|
+
title="Team members"
|
|
40
|
+
description="Invite people and manage their roles."
|
|
41
|
+
action={<Button size="xl">Invite member</Button>}
|
|
42
|
+
/>
|
|
43
|
+
),
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const WithEyebrowAndAction: Story = {
|
|
47
|
+
parameters: { controls: { disable: true } },
|
|
48
|
+
render: () => (
|
|
49
|
+
<PageHeader
|
|
50
|
+
eyebrow="Projects"
|
|
51
|
+
title="Meridian rebrand"
|
|
52
|
+
description="Brand identity, design tokens, and component library for Meridian Financial."
|
|
53
|
+
action={
|
|
54
|
+
<>
|
|
55
|
+
<Button variant="outline" size="lg">Export</Button>
|
|
56
|
+
<Button size="xl">New component</Button>
|
|
57
|
+
</>
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const Bordered: Story = {
|
|
64
|
+
parameters: { controls: { disable: true } },
|
|
65
|
+
render: () => (
|
|
66
|
+
<div>
|
|
67
|
+
<PageHeader
|
|
68
|
+
title="Notifications"
|
|
69
|
+
description="Choose what you want to be notified about."
|
|
70
|
+
bordered
|
|
71
|
+
/>
|
|
72
|
+
<p className="mt-6 text-sm text-muted-foreground">Content below the border…</p>
|
|
73
|
+
</div>
|
|
74
|
+
),
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const RealisticUse: Story = {
|
|
78
|
+
parameters: { controls: { disable: true } },
|
|
79
|
+
render: () => (
|
|
80
|
+
<div className="w-full max-w-3xl space-y-6">
|
|
81
|
+
<PageHeader
|
|
82
|
+
eyebrow="Design system"
|
|
83
|
+
title="Component library"
|
|
84
|
+
description="149 primitives and compositions ready for your next client engagement. All WCAG AAA."
|
|
85
|
+
bordered
|
|
86
|
+
action={
|
|
87
|
+
<>
|
|
88
|
+
<Button variant="outline" size="lg">Import tokens</Button>
|
|
89
|
+
<Button size="xl">Add component</Button>
|
|
90
|
+
</>
|
|
91
|
+
}
|
|
92
|
+
/>
|
|
93
|
+
<div className="space-y-3">
|
|
94
|
+
{["Button", "Combobox", "MultiSelect"].map((name) => (
|
|
95
|
+
<div key={name} className="rounded-md border border-border p-4 text-sm text-foreground">
|
|
96
|
+
{name}
|
|
97
|
+
</div>
|
|
98
|
+
))}
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
),
|
|
102
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
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
|
+
{/* Scope-local variable, defined from tokens (no hardcoded color). */}
|
|
100
|
+
<style>{`.portal-demo-scope { --demo-panel: var(--color-primary); --demo-panel-fg: var(--color-primary-foreground); }`}</style>
|
|
101
|
+
<div className="portal-demo-scope flex w-96 flex-col gap-4 text-sm">
|
|
102
|
+
<div className="rounded-lg border border-border bg-card p-4">
|
|
103
|
+
<p className="font-medium">Page wrapper with .portal-demo-scope</p>
|
|
104
|
+
<p className="text-muted-foreground">
|
|
105
|
+
The two panels below are portaled to body. Both use{" "}
|
|
106
|
+
<code className="font-mono">var(--demo-panel)</code>.
|
|
107
|
+
</p>
|
|
108
|
+
</div>
|
|
109
|
+
<Portal>
|
|
110
|
+
<div
|
|
111
|
+
className="fixed bottom-4 left-4 z-50 rounded-md border border-border px-3 py-2"
|
|
112
|
+
style={{
|
|
113
|
+
background: "var(--demo-panel, var(--color-card))",
|
|
114
|
+
color: "var(--demo-panel-fg, var(--color-card-foreground))",
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
No provider — the scoped var() misses, falls back to card
|
|
118
|
+
</div>
|
|
119
|
+
</Portal>
|
|
120
|
+
<PortalThemeProvider scope="portal-demo-scope">
|
|
121
|
+
<Portal>
|
|
122
|
+
<div
|
|
123
|
+
className="fixed right-4 bottom-4 z-50 rounded-md px-3 py-2"
|
|
124
|
+
style={{
|
|
125
|
+
background: "var(--demo-panel, var(--color-card))",
|
|
126
|
+
color: "var(--demo-panel-fg, var(--color-card-foreground))",
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
With provider — scope class travels, var() resolves to primary
|
|
130
|
+
</div>
|
|
131
|
+
</Portal>
|
|
132
|
+
</PortalThemeProvider>
|
|
133
|
+
</div>
|
|
134
|
+
</>
|
|
135
|
+
),
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Unsaved-changes bar: a form deep in the page owns the state, but the bar
|
|
140
|
+
* must sit above every ancestor's overflow/transform — so it portals to
|
|
141
|
+
* body and animates in/out with Presence. Copy from
|
|
142
|
+
* content/personas/bads.json → primary.microcopy.
|
|
143
|
+
*/
|
|
144
|
+
export const RealisticUse: Story = {
|
|
145
|
+
render: function RealisticUseStory() {
|
|
146
|
+
const initial = "@behavioral-agentic-design-system"
|
|
147
|
+
const [value, setValue] = React.useState(initial)
|
|
148
|
+
const dirty = value !== initial
|
|
149
|
+
return (
|
|
150
|
+
<div className="w-96 overflow-hidden rounded-lg border border-border bg-card p-6">
|
|
151
|
+
<p className="text-lg font-semibold">Customize your tokens</p>
|
|
152
|
+
<p className="mb-5 text-sm text-muted-foreground">
|
|
153
|
+
Edit the scope to reveal the bar. This card has overflow-hidden — the
|
|
154
|
+
bar still escapes because it renders at body.
|
|
155
|
+
</p>
|
|
156
|
+
<div className="flex flex-col gap-3">
|
|
157
|
+
<Label htmlFor="portal-scope">npm scope</Label>
|
|
158
|
+
<Input
|
|
159
|
+
id="portal-scope"
|
|
160
|
+
value={value}
|
|
161
|
+
onChange={(e) => setValue(e.target.value)}
|
|
162
|
+
/>
|
|
163
|
+
</div>
|
|
164
|
+
<Portal>
|
|
165
|
+
<Presence present={dirty} transition="slide-up" asChild>
|
|
166
|
+
<div
|
|
167
|
+
role="status"
|
|
168
|
+
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"
|
|
169
|
+
>
|
|
170
|
+
<span className="text-sm font-medium">Unsaved changes</span>
|
|
171
|
+
<div className="flex items-center gap-2">
|
|
172
|
+
<Button
|
|
173
|
+
size="xl"
|
|
174
|
+
variant="ghost"
|
|
175
|
+
onClick={() => setValue(initial)}
|
|
176
|
+
>
|
|
177
|
+
Cancel
|
|
178
|
+
</Button>
|
|
179
|
+
<Button size="xl" onClick={() => setValue(initial)}>
|
|
180
|
+
Save changes
|
|
181
|
+
</Button>
|
|
182
|
+
</div>
|
|
183
|
+
</div>
|
|
184
|
+
</Presence>
|
|
185
|
+
</Portal>
|
|
186
|
+
</div>
|
|
187
|
+
)
|
|
188
|
+
},
|
|
189
|
+
}
|