@behavioral-agentic-design-system/core 0.22.0 → 0.24.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 +6 -4
- package/scripts/size-audit.cjs +147 -0
- package/src/api/layers/file.ts +0 -1
- package/src/app/layout.tsx +29 -4
- package/src/app/opengraph-image.tsx +103 -0
- package/src/app/preview/components/page.tsx +405 -5
- package/src/app/shell.tsx +31 -7
- package/src/components/customize-tab.tsx +111 -139
- package/src/components/home-tab.tsx +7 -14
- package/src/components/layers-tab.tsx +5 -0
- package/src/components/onboarding-wizard.tsx +1 -1
- package/src/components/ui/copy-button.tsx +2 -2
- package/src/components/ui/data-list.tsx +169 -0
- package/src/components/ui/editable.tsx +56 -27
- package/src/components/ui/fieldset.tsx +244 -0
- package/src/components/ui/index.ts +4 -0
- package/src/components/ui/input-group.tsx +204 -0
- package/src/components/ui/qr-code.tsx +107 -0
- package/src/data/docs-index.ts +14 -0
- package/src/stories/Accordion.stories.tsx +21 -0
- package/src/stories/Button.stories.tsx +15 -0
- package/src/stories/CopyButton.stories.tsx +3 -3
- package/src/stories/DataList.stories.tsx +160 -0
- package/src/stories/Dialog.stories.tsx +33 -0
- package/src/stories/Editable.stories.tsx +34 -7
- package/src/stories/Field.stories.tsx +1 -1
- package/src/stories/Fieldset.stories.tsx +253 -0
- package/src/stories/InputGroup.stories.tsx +227 -0
- package/src/stories/Label.stories.tsx +2 -2
- package/src/stories/QrCode.stories.tsx +146 -0
- package/src/stories/Tabs.stories.tsx +24 -0
- package/src/styles.css +0 -12
- package/src/tokens.json +45 -49
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { encode } from "uqr"
|
|
3
|
+
import { cn } from "../../lib/utils"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* QR code display primitive. Encodes an arbitrary string (URL, ID, TOTP
|
|
7
|
+
* URI) into a scannable matrix via `uqr` (zero-dependency Reed–Solomon
|
|
8
|
+
* encoder) and renders the SVG itself so every color stays token-driven:
|
|
9
|
+
* dark modules are a single path filled with `currentColor` (inherits
|
|
10
|
+
* `text-foreground`), and the light modules + quiet zone are transparent —
|
|
11
|
+
* the root paints `bg-background`. No hardcoded #000/#fff anywhere, so
|
|
12
|
+
* brand re-theming propagates and the wcag audit owns the pair.
|
|
13
|
+
*
|
|
14
|
+
* Scannability contract: the module/quiet-zone pair must stay at or above
|
|
15
|
+
* ~3:1 contrast or cameras stop locking on — the default foreground/
|
|
16
|
+
* background pair sits near 21:1 in both modes. Dark mode renders an
|
|
17
|
+
* inverted (light-on-dark) code; modern scanners read inversion fine, but
|
|
18
|
+
* if a surface must serve legacy scanners, place the component on a light
|
|
19
|
+
* `bg-background` island rather than restyling module colors. A 4-module
|
|
20
|
+
* quiet zone (ISO/IEC 18004 recommendation) is baked into the viewBox so
|
|
21
|
+
* it scales with the code and can't be cropped away by padding changes.
|
|
22
|
+
*
|
|
23
|
+
* Display-only — never focusable, no interaction, no motion (same class
|
|
24
|
+
* as Kbd and DataList). The root is `role="img"` with a required
|
|
25
|
+
* accessible name: `aria-label` ?? `title` ?? "QR code: <value>".
|
|
26
|
+
*
|
|
27
|
+
* <QRCode value="https://design.bads.com/share/tokens-v2-proposal"
|
|
28
|
+
* title="Scan to open the tokens proposal" />
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/** Quiet-zone width in modules, baked into the SVG viewBox (ISO/IEC 18004). */
|
|
32
|
+
const QUIET_ZONE_MODULES = 4
|
|
33
|
+
|
|
34
|
+
export interface QRCodeProps
|
|
35
|
+
extends Omit<React.ComponentProps<"span">, "children"> {
|
|
36
|
+
/** The string encoded into the matrix (URL, ID, TOTP URI, …). */
|
|
37
|
+
value: string
|
|
38
|
+
/** Rendered width and height in px. Default 160. */
|
|
39
|
+
size?: number
|
|
40
|
+
/**
|
|
41
|
+
* Reed–Solomon error-correction level — how much of the code can be
|
|
42
|
+
* damaged or obscured and still scan. Higher levels densify the matrix.
|
|
43
|
+
* L ≈ 7%, M ≈ 15% (default), Q ≈ 25%, H ≈ 30%.
|
|
44
|
+
*/
|
|
45
|
+
errorCorrection?: "L" | "M" | "Q" | "H"
|
|
46
|
+
/**
|
|
47
|
+
* Accessible name for the code. Also mirrored as the native `title`
|
|
48
|
+
* attribute so sighted users can hover-recover the payload. Falls back
|
|
49
|
+
* to `aria-label`, then to "QR code: <value>".
|
|
50
|
+
*/
|
|
51
|
+
title?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function QRCode({
|
|
55
|
+
value,
|
|
56
|
+
size = 160,
|
|
57
|
+
errorCorrection = "M",
|
|
58
|
+
title,
|
|
59
|
+
className,
|
|
60
|
+
"aria-label": ariaLabel,
|
|
61
|
+
...props
|
|
62
|
+
}: QRCodeProps) {
|
|
63
|
+
// uqr's own defaults are ecc "L" and border 1 — both set explicitly:
|
|
64
|
+
// "M" matches the industry default, and a 1-module quiet zone is too
|
|
65
|
+
// tight for reliable camera lock-on.
|
|
66
|
+
const matrix = encode(value, {
|
|
67
|
+
ecc: errorCorrection,
|
|
68
|
+
border: QUIET_ZONE_MODULES,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// One path segment per dark module; light modules stay transparent so
|
|
72
|
+
// the root's bg-background provides the quiet zone in both themes.
|
|
73
|
+
let d = ""
|
|
74
|
+
for (let y = 0; y < matrix.size; y++) {
|
|
75
|
+
const row = matrix.data[y]
|
|
76
|
+
for (let x = 0; x < matrix.size; x++) {
|
|
77
|
+
if (row[x]) d += `M${x} ${y}h1v1h-1z`
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<span
|
|
83
|
+
data-slot="qr-code"
|
|
84
|
+
role="img"
|
|
85
|
+
aria-label={ariaLabel ?? title ?? `QR code: ${value}`}
|
|
86
|
+
title={title}
|
|
87
|
+
className={cn(
|
|
88
|
+
"inline-flex shrink-0 rounded-sm bg-background text-foreground",
|
|
89
|
+
className,
|
|
90
|
+
)}
|
|
91
|
+
{...props}
|
|
92
|
+
>
|
|
93
|
+
<svg
|
|
94
|
+
viewBox={`0 0 ${matrix.size} ${matrix.size}`}
|
|
95
|
+
width={size}
|
|
96
|
+
height={size}
|
|
97
|
+
shapeRendering="crispEdges"
|
|
98
|
+
aria-hidden="true"
|
|
99
|
+
focusable="false"
|
|
100
|
+
>
|
|
101
|
+
<path d={d} fill="currentColor" />
|
|
102
|
+
</svg>
|
|
103
|
+
</span>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export { QRCode }
|
package/src/data/docs-index.ts
CHANGED
|
@@ -27,6 +27,7 @@ export const DOCS_INDEX: DocGroup[] = [
|
|
|
27
27
|
{ title: "README", path: "README.md", summary: "The first thing to read — what BADS is, how to run it, where to look next." },
|
|
28
28
|
{ title: "Brief", path: "BRIEF.md", summary: "The one-pager — what BADS is, who it's for, what it refuses." },
|
|
29
29
|
{ title: "Design system stack", path: "DESIGN_SYSTEM_STACK.md", summary: "The 10-layer architecture in one document." },
|
|
30
|
+
{ title: "Tech stack", path: "docs/tech-stack.md", summary: "What BADS is built on and why — framework, tokens, testing, AI layer — plus the 30-second spoken answer." },
|
|
30
31
|
{ title: "Sync model", path: "BADS_SYNC.md", summary: "How forks pull upstream BADS improvements." },
|
|
31
32
|
],
|
|
32
33
|
},
|
|
@@ -102,6 +103,7 @@ export const DOCS_INDEX: DocGroup[] = [
|
|
|
102
103
|
entries: [
|
|
103
104
|
{ title: "Design rules", path: "DESIGN.md", summary: "Visual system + accessibility baseline." },
|
|
104
105
|
{ title: "Chart color palette", path: "docs/chart-color-palette.md", summary: "Accessible 5-color categorical palette for data viz — Okabe-Ito-derived, reviewed against WCAG 1.4.11 non-text contrast." },
|
|
106
|
+
{ title: "Privacy-first design (8 principles)", path: "layer-2-ethics-responsibility/privacy-first-design.md", summary: "Matthew Stephens' 8-principle privacy framework: minimize collection, transparency, expiration, no dark patterns, user control, ethical monetization, sustainable practices, accountability — mapped to BADS enforcement." },
|
|
105
107
|
{ title: "Gamification — responsible vs. manipulative", path: "layer-2-ethics-responsibility/gamification.md", summary: "Sir's 10 Core Drives (Octalysis 8 + Exploration & Discovery + Challenge & Competition) + the test gates that decide when Black Hat ships and when it refuses." },
|
|
106
108
|
{ title: "Corrections log", path: "corrections.md", summary: "Per-fork anti-pattern log. Read before every Path B build." },
|
|
107
109
|
{ title: "Anti-defaults refresh", path: "prompts/anti-defaults-refresh.md", summary: "Quarterly pressure-test of the current anti-defaults." },
|
|
@@ -125,6 +127,18 @@ export const DOCS_INDEX: DocGroup[] = [
|
|
|
125
127
|
{ title: "5 · Component needs", path: "prompts/5-component-needs.md" },
|
|
126
128
|
{ title: "6 · Patterns", path: "prompts/6-patterns.md" },
|
|
127
129
|
{ title: "Chromatic setup", path: "docs/chromatic-setup.md" },
|
|
130
|
+
{
|
|
131
|
+
title: "Handoff runbook",
|
|
132
|
+
path: "docs/handoff-runbook.md",
|
|
133
|
+
summary:
|
|
134
|
+
"Transferring a finished fork to the client's own team — quality pass, repo transfer, secret rotation, knowledge transfer, wind-down.",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
title: "Fork sync migration",
|
|
138
|
+
path: "docs/fork-sync-migration.md",
|
|
139
|
+
summary:
|
|
140
|
+
"workspace:* to npm-consume — the migration every client fork runs so daily component releases actually arrive.",
|
|
141
|
+
},
|
|
128
142
|
{ title: "Chromatic prompt", path: "prompts/chromatic.md" },
|
|
129
143
|
],
|
|
130
144
|
},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { userEvent, within, expect } from "storybook/test";
|
|
2
3
|
import {
|
|
3
4
|
Accordion,
|
|
4
5
|
AccordionItem,
|
|
@@ -110,6 +111,26 @@ export const Disabled: Story = {
|
|
|
110
111
|
),
|
|
111
112
|
};
|
|
112
113
|
|
|
114
|
+
export const Interaction_Opens: Story = {
|
|
115
|
+
tags: ["test"],
|
|
116
|
+
render: () => (
|
|
117
|
+
<Accordion type="single" collapsible className="w-[400px]">
|
|
118
|
+
<AccordionItem value="item-1">
|
|
119
|
+
<AccordionTrigger>What is BADS?</AccordionTrigger>
|
|
120
|
+
<AccordionContent>A portable, agentic design system.</AccordionContent>
|
|
121
|
+
</AccordionItem>
|
|
122
|
+
</Accordion>
|
|
123
|
+
),
|
|
124
|
+
play: async ({ canvasElement }) => {
|
|
125
|
+
const canvas = within(canvasElement);
|
|
126
|
+
const trigger = canvas.getByRole("button", { name: /what is bads/i });
|
|
127
|
+
expect(trigger).toHaveAttribute("data-state", "closed");
|
|
128
|
+
await userEvent.click(trigger);
|
|
129
|
+
expect(trigger).toHaveAttribute("data-state", "open");
|
|
130
|
+
expect(canvas.getByText("A portable, agentic design system.")).toBeVisible();
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
113
134
|
export const RealisticUse: Story = {
|
|
114
135
|
render: () => (
|
|
115
136
|
<div className="w-[480px] rounded-lg border bg-card p-6">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Meta, StoryObj } from "@storybook/react"
|
|
2
|
+
import { userEvent, within, expect, fn } from "storybook/test"
|
|
2
3
|
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button"
|
|
3
4
|
import { Heart } from "lucide-react"
|
|
4
5
|
|
|
@@ -125,6 +126,20 @@ export const RealisticUse: Story = {
|
|
|
125
126
|
// base class. Default and the icon sizes used to fall through to rounded-full
|
|
126
127
|
// (pill / circle) while the rest were rounded-md; this row exists so that
|
|
127
128
|
// inconsistency can't silently come back.
|
|
129
|
+
export const Interaction_Click: Story = {
|
|
130
|
+
tags: ["test"],
|
|
131
|
+
args: {
|
|
132
|
+
children: "Save Changes",
|
|
133
|
+
onClick: fn(),
|
|
134
|
+
},
|
|
135
|
+
play: async ({ canvasElement, args }) => {
|
|
136
|
+
const canvas = within(canvasElement);
|
|
137
|
+
const button = canvas.getByRole("button", { name: /save changes/i });
|
|
138
|
+
await userEvent.click(button);
|
|
139
|
+
expect(args.onClick).toHaveBeenCalledOnce();
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
|
|
128
143
|
export const AllSizes: Story = {
|
|
129
144
|
render: () => (
|
|
130
145
|
<div className="flex flex-wrap items-center gap-3">
|
|
@@ -10,7 +10,7 @@ const meta: Meta<typeof CopyButton> = {
|
|
|
10
10
|
docs: {
|
|
11
11
|
description: {
|
|
12
12
|
component:
|
|
13
|
-
"Button that copies a string to the clipboard. Idle → Copied state swap via opacity + scale transition (var(--duration-fast) + var(--ease-out)). Announces 'Copied to clipboard' via aria-live=polite. Icon-only mode requires aria-label. Gracefully falls back to document.execCommand in non-secure contexts. Not a form submit — always type=button via Button primitive.",
|
|
13
|
+
"Button that copies a string to the clipboard. Idle → Copied state swap via opacity + scale transition (var(--duration-fast) + var(--ease-out)). Announces 'Copied to clipboard' via aria-live=polite. The visible Copied state renders in the success (green) color with the check + label at gap-1.5 (the confirmation is aria-hidden, so the color is decorative and the state is announced via the live region). Icon-only mode requires aria-label. Gracefully falls back to document.execCommand in non-secure contexts. Not a form submit — always type=button via Button primitive.",
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
16
|
},
|
|
@@ -20,7 +20,7 @@ type Story = StoryObj<typeof CopyButton>
|
|
|
20
20
|
|
|
21
21
|
export const Default: Story = {
|
|
22
22
|
render: () => (
|
|
23
|
-
<CopyButton value="
|
|
23
|
+
<CopyButton value="jordan@reeves.design">Copy email</CopyButton>
|
|
24
24
|
),
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -42,7 +42,7 @@ export const Variant_Ghost: Story = {
|
|
|
42
42
|
|
|
43
43
|
export const Variant_Secondary: Story = {
|
|
44
44
|
render: () => (
|
|
45
|
-
<CopyButton value="https://
|
|
45
|
+
<CopyButton value="https://design.bads.com/share/tokens-v2-proposal" variant="secondary">
|
|
46
46
|
Copy link
|
|
47
47
|
</CopyButton>
|
|
48
48
|
),
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import {
|
|
4
|
+
DataList,
|
|
5
|
+
DataListItem,
|
|
6
|
+
DataListLabel,
|
|
7
|
+
DataListValue,
|
|
8
|
+
} from "@behavioral-agentic-design-system/core/components/ui/data-list";
|
|
9
|
+
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
10
|
+
import { Separator } from "@behavioral-agentic-design-system/core/components/ui/separator";
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof DataList> = {
|
|
13
|
+
title: "Components/DataList",
|
|
14
|
+
component: DataList,
|
|
15
|
+
parameters: {
|
|
16
|
+
layout: "centered",
|
|
17
|
+
docs: {
|
|
18
|
+
description: {
|
|
19
|
+
component:
|
|
20
|
+
"Semantic key–value list. Renders a native <dl> with <dt>/<dd> pairs, so screen readers announce a description list and associate each term with its description — semantics a div grid cannot produce. Orientation vertical (default) stacks label over value; horizontal lays each pair on a grid row with the label column aligned across all rows via CSS subgrid. Sizes sm / default / lg scale rhythm and type. Display-only: no interaction, no motion. Use for profile panels, invoice summaries, settings recaps, metadata blocks.",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
argTypes: {
|
|
25
|
+
orientation: { control: "select", options: ["vertical", "horizontal"] },
|
|
26
|
+
size: { control: "select", options: ["sm", "default", "lg"] },
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default meta;
|
|
31
|
+
type Story = StoryObj<typeof meta>;
|
|
32
|
+
|
|
33
|
+
const pair = (label: string, value: React.ReactNode) => (
|
|
34
|
+
<DataListItem>
|
|
35
|
+
<DataListLabel>{label}</DataListLabel>
|
|
36
|
+
<DataListValue>{value}</DataListValue>
|
|
37
|
+
</DataListItem>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const Default: Story = {
|
|
41
|
+
render: () => (
|
|
42
|
+
<DataList className="w-80">
|
|
43
|
+
{pair("Name", "Jordan Reeves")}
|
|
44
|
+
{pair("Role", "Design Systems Lead")}
|
|
45
|
+
{pair("Email", "jordan@reeves.design")}
|
|
46
|
+
{pair("Workspace", "design.bads.com")}
|
|
47
|
+
{pair("Member since", "Jan 15, 2026")}
|
|
48
|
+
</DataList>
|
|
49
|
+
),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const Orientation_Vertical: Story = {
|
|
53
|
+
render: () => (
|
|
54
|
+
<DataList orientation="vertical" className="w-80">
|
|
55
|
+
{pair("Component", "Button · v2.4.0")}
|
|
56
|
+
{pair("Reviewed by", "Seo-yun Park")}
|
|
57
|
+
{pair("Last token change", "May 26, 2026")}
|
|
58
|
+
{pair("Contrast floor", "7:1 contrast")}
|
|
59
|
+
</DataList>
|
|
60
|
+
),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const Orientation_Horizontal: Story = {
|
|
64
|
+
render: () => (
|
|
65
|
+
<DataList orientation="horizontal" className="w-96">
|
|
66
|
+
{pair("Invoice", "INV-2026-0187")}
|
|
67
|
+
{pair("Billed to", "Anika Patel")}
|
|
68
|
+
{pair("Billing email", "anika.patel@stripe.com")}
|
|
69
|
+
{pair("Amount", "$249.00")}
|
|
70
|
+
{pair("Issued", "May 26, 2026")}
|
|
71
|
+
{pair(
|
|
72
|
+
"Status",
|
|
73
|
+
<Badge variant="secondary" className="align-middle">
|
|
74
|
+
Paid
|
|
75
|
+
</Badge>,
|
|
76
|
+
)}
|
|
77
|
+
</DataList>
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const Size_Sm: Story = {
|
|
82
|
+
render: () => (
|
|
83
|
+
<DataList size="sm" orientation="horizontal" className="w-80">
|
|
84
|
+
{pair("Owner", "Marcus Lindqvist")}
|
|
85
|
+
{pair("Email", "marcus@lindqvist.dev")}
|
|
86
|
+
{pair("Plan", "Team · $249.00/yr")}
|
|
87
|
+
</DataList>
|
|
88
|
+
),
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const Size_Default: Story = {
|
|
92
|
+
render: () => (
|
|
93
|
+
<DataList size="default" orientation="horizontal" className="w-80">
|
|
94
|
+
{pair("Owner", "Marcus Lindqvist")}
|
|
95
|
+
{pair("Email", "marcus@lindqvist.dev")}
|
|
96
|
+
{pair("Plan", "Team · $249.00/yr")}
|
|
97
|
+
</DataList>
|
|
98
|
+
),
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const Size_Lg: Story = {
|
|
102
|
+
render: () => (
|
|
103
|
+
<DataList size="lg" orientation="horizontal" className="w-96">
|
|
104
|
+
{pair("Owner", "Marcus Lindqvist")}
|
|
105
|
+
{pair("Email", "marcus@lindqvist.dev")}
|
|
106
|
+
{pair("Plan", "Team · $249.00/yr")}
|
|
107
|
+
</DataList>
|
|
108
|
+
),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const LongValues: Story = {
|
|
112
|
+
render: () => (
|
|
113
|
+
<DataList orientation="horizontal" className="w-80">
|
|
114
|
+
{pair("Full name", "Wilhelmina-Constance Featherstonehaugh-Vance")}
|
|
115
|
+
{pair(
|
|
116
|
+
"Email",
|
|
117
|
+
"wilhelmina.featherstonehaugh-vance@subdomain.consulting.example.org",
|
|
118
|
+
)}
|
|
119
|
+
{pair("Share link", "https://design.bads.com/share/tokens-v2-proposal")}
|
|
120
|
+
</DataList>
|
|
121
|
+
),
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const RealisticUse: Story = {
|
|
125
|
+
render: () => (
|
|
126
|
+
<div className="w-[26rem] rounded-lg border bg-card p-5 shadow-sm">
|
|
127
|
+
<div className="space-y-1">
|
|
128
|
+
<h3 className="text-sm font-semibold text-foreground">
|
|
129
|
+
Invoice INV-2026-0187
|
|
130
|
+
</h3>
|
|
131
|
+
<p className="text-sm text-muted-foreground">
|
|
132
|
+
Design system license · annual renewal
|
|
133
|
+
</p>
|
|
134
|
+
</div>
|
|
135
|
+
<Separator className="my-4" />
|
|
136
|
+
<DataList orientation="horizontal">
|
|
137
|
+
{pair("Billed to", "Jordan Reeves")}
|
|
138
|
+
{pair("Email", "jordan@reeves.design")}
|
|
139
|
+
{pair("Address", "1401 South Congress Ave, Suite 200, Austin, TX 78704")}
|
|
140
|
+
{pair("Issued", "May 26, 2026")}
|
|
141
|
+
{pair("Due", "Nov 20, 2026")}
|
|
142
|
+
{pair(
|
|
143
|
+
"Amount due",
|
|
144
|
+
<span className="font-semibold">$12,500.00</span>,
|
|
145
|
+
)}
|
|
146
|
+
{pair(
|
|
147
|
+
"Status",
|
|
148
|
+
<Badge variant="secondary" className="align-middle">
|
|
149
|
+
Awaiting payment
|
|
150
|
+
</Badge>,
|
|
151
|
+
)}
|
|
152
|
+
</DataList>
|
|
153
|
+
<Separator className="my-4" />
|
|
154
|
+
<DataList size="sm">
|
|
155
|
+
{pair("Includes", "36 components, all passing AAA contrast")}
|
|
156
|
+
{pair("Support contact", "seoyun.park@figma.com")}
|
|
157
|
+
</DataList>
|
|
158
|
+
</div>
|
|
159
|
+
),
|
|
160
|
+
};
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// canonical demonstration. Mechanism is identical here; no separate\
|
|
6
6
|
// story added because the demo would duplicate Sheet's.
|
|
7
7
|
import { Meta, StoryObj } from "@storybook/react";
|
|
8
|
+
import { userEvent, within, expect, waitFor } from "storybook/test";
|
|
8
9
|
import {
|
|
9
10
|
Dialog,
|
|
10
11
|
DialogTrigger,
|
|
@@ -161,6 +162,38 @@ export const Size_Full: Story = {
|
|
|
161
162
|
),
|
|
162
163
|
};
|
|
163
164
|
|
|
165
|
+
export const Interaction_Opens: Story = {
|
|
166
|
+
tags: ["test"],
|
|
167
|
+
render: () => (
|
|
168
|
+
<Dialog>
|
|
169
|
+
<DialogTrigger asChild>
|
|
170
|
+
<Button>Open Dialog</Button>
|
|
171
|
+
</DialogTrigger>
|
|
172
|
+
<DialogContent size="sm">
|
|
173
|
+
<DialogHeader>
|
|
174
|
+
<DialogTitle>Confirm Action</DialogTitle>
|
|
175
|
+
<DialogDescription>This action cannot be undone.</DialogDescription>
|
|
176
|
+
</DialogHeader>
|
|
177
|
+
<DialogFooter>
|
|
178
|
+
<DialogClose asChild>
|
|
179
|
+
<Button variant="outline">Cancel</Button>
|
|
180
|
+
</DialogClose>
|
|
181
|
+
</DialogFooter>
|
|
182
|
+
</DialogContent>
|
|
183
|
+
</Dialog>
|
|
184
|
+
),
|
|
185
|
+
play: async ({ canvasElement }) => {
|
|
186
|
+
const canvas = within(canvasElement);
|
|
187
|
+
await userEvent.click(canvas.getByRole("button", { name: /open dialog/i }));
|
|
188
|
+
// Dialog portals to document.body — query from there. The content's
|
|
189
|
+
// fade-in-0 entrance starts at opacity 0, so toBeVisible() must wait
|
|
190
|
+
// for the animation to finish rather than assert on mount.
|
|
191
|
+
const dialog = await within(document.body).findByRole("dialog");
|
|
192
|
+
await waitFor(() => expect(dialog).toBeVisible());
|
|
193
|
+
expect(within(dialog).getByText("Confirm Action")).toBeVisible();
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
164
197
|
export const RealisticUse: Story = {
|
|
165
198
|
render: () => (
|
|
166
199
|
<Dialog>
|
|
@@ -29,6 +29,9 @@ export const Default: Story = {
|
|
|
29
29
|
),
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
// The overlay input covers only the preview area, so the Save/Cancel controls
|
|
33
|
+
// render below it (visible) once editing begins — not hidden behind the input.
|
|
34
|
+
// Save/Cancel are the BADS Button primitive (default + ghost), spaced with gap-2.
|
|
32
35
|
export const WithControls: Story = {
|
|
33
36
|
render: () => (
|
|
34
37
|
<div className="w-64">
|
|
@@ -67,6 +70,8 @@ export const SubmitMode_Enter: Story = {
|
|
|
67
70
|
),
|
|
68
71
|
}
|
|
69
72
|
|
|
73
|
+
// Disabled renders as a single dimmed (opacity-50) preview label — the overlay
|
|
74
|
+
// input stays hidden, so the value is not ghosted over itself.
|
|
70
75
|
export const Disabled: Story = {
|
|
71
76
|
render: () => (
|
|
72
77
|
<div className="w-64">
|
|
@@ -87,6 +92,26 @@ export const WithPlaceholder: Story = {
|
|
|
87
92
|
),
|
|
88
93
|
}
|
|
89
94
|
|
|
95
|
+
// Keyboard contract: Enter/Space on the preview opens edit mode (focus moves to
|
|
96
|
+
// the input), Escape cancels and Enter (submitMode enter/both) saves — in both
|
|
97
|
+
// cases focus RETURNS to the preview instead of stranding on the aria-hidden
|
|
98
|
+
// input or an unmounted Save/Cancel button. Blur-submit (clicking elsewhere)
|
|
99
|
+
// deliberately does NOT steal focus back. `label` names the edit input for
|
|
100
|
+
// screen readers; without it the input falls back to the placeholder text.
|
|
101
|
+
export const KeyboardFocusReturn: Story = {
|
|
102
|
+
render: () => (
|
|
103
|
+
<div className="w-64">
|
|
104
|
+
<Editable defaultValue="Tab here, press Enter, then Escape" label="Demo field" submitMode="both">
|
|
105
|
+
<EditablePreview />
|
|
106
|
+
<EditableControl>
|
|
107
|
+
<EditableSubmit />
|
|
108
|
+
<EditableCancel />
|
|
109
|
+
</EditableControl>
|
|
110
|
+
</Editable>
|
|
111
|
+
</div>
|
|
112
|
+
),
|
|
113
|
+
}
|
|
114
|
+
|
|
90
115
|
export const Controlled: Story = {
|
|
91
116
|
render: () => {
|
|
92
117
|
const [value, setValue] = React.useState("Maya Chen")
|
|
@@ -105,29 +130,31 @@ export const Controlled: Story = {
|
|
|
105
130
|
|
|
106
131
|
export const RealisticUse: Story = {
|
|
107
132
|
render: () => {
|
|
108
|
-
const [name, setName] = React.useState("
|
|
109
|
-
const [
|
|
133
|
+
const [name, setName] = React.useState("Brand refresh sprint")
|
|
134
|
+
const [lead, setLead] = React.useState("Maya Chen")
|
|
110
135
|
|
|
111
136
|
return (
|
|
112
137
|
<div className="w-72 rounded-lg border border-border bg-card p-4 shadow-sm">
|
|
113
138
|
<p className="mb-3 text-xs font-medium uppercase tracking-wide text-muted-foreground">
|
|
114
|
-
|
|
139
|
+
Project Details
|
|
115
140
|
</p>
|
|
116
141
|
<div className="space-y-1">
|
|
117
|
-
<label className="text-xs text-muted-foreground">
|
|
142
|
+
<label className="text-xs text-muted-foreground">Project name</label>
|
|
118
143
|
<Editable
|
|
119
144
|
value={name}
|
|
120
145
|
onValueChange={setName}
|
|
146
|
+
label="Project name"
|
|
121
147
|
submitMode="blur"
|
|
122
148
|
>
|
|
123
149
|
<EditablePreview className="text-base font-medium" />
|
|
124
150
|
</Editable>
|
|
125
151
|
</div>
|
|
126
152
|
<div className="mt-3 space-y-1">
|
|
127
|
-
<label className="text-xs text-muted-foreground">
|
|
153
|
+
<label className="text-xs text-muted-foreground">Design lead</label>
|
|
128
154
|
<Editable
|
|
129
|
-
value={
|
|
130
|
-
onValueChange={
|
|
155
|
+
value={lead}
|
|
156
|
+
onValueChange={setLead}
|
|
157
|
+
label="Design lead"
|
|
131
158
|
submitMode="both"
|
|
132
159
|
>
|
|
133
160
|
<EditablePreview />
|
|
@@ -26,7 +26,7 @@ export const Default: Story = {
|
|
|
26
26
|
<Field name="email" required>
|
|
27
27
|
<FieldLabel>Email address</FieldLabel>
|
|
28
28
|
<FieldControl>
|
|
29
|
-
<Input type="email" placeholder="
|
|
29
|
+
<Input type="email" placeholder="jordan@reeves.design" autoComplete="email" />
|
|
30
30
|
</FieldControl>
|
|
31
31
|
<FieldHelper>We'll never share it.</FieldHelper>
|
|
32
32
|
</Field>
|