@behavioral-agentic-design-system/core 0.22.0 → 0.23.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 +3 -2
- 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 +124 -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/editable.tsx +56 -27
- package/src/components/ui/fieldset.tsx +238 -0
- package/src/components/ui/index.ts +2 -0
- package/src/components/ui/input-group.tsx +194 -0
- package/src/data/docs-index.ts +13 -0
- package/src/stories/Accordion.stories.tsx +21 -0
- package/src/stories/Button.stories.tsx +15 -0
- package/src/stories/CopyButton.stories.tsx +2 -2
- 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 +249 -0
- package/src/stories/InputGroup.stories.tsx +229 -0
- package/src/stories/Label.stories.tsx +2 -2
- package/src/stories/Tabs.stories.tsx +24 -0
- package/src/styles.css +0 -12
- package/src/tokens.json +45 -49
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@behavioral-agentic-design-system/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "BADS core — tokens, shadcn/ui components, and the BADS template shell (app routes, customize tab, theme hooks). Forks consume this and re-export, keeping client repos to ~30 lines of glue.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Matthew Stephens <work@matthewstephens.com> (https://github.com/matthewlarn)",
|
|
@@ -44,7 +44,8 @@
|
|
|
44
44
|
"bads-check-stories": "scripts/check-stories.mjs",
|
|
45
45
|
"bads-fix-stories": "scripts/fix-stories.mjs",
|
|
46
46
|
"bads-generate-stories": "scripts/generate-stories.cjs",
|
|
47
|
-
"bads-oklch-to-hex": "scripts/oklch-to-hex.cjs"
|
|
47
|
+
"bads-oklch-to-hex": "scripts/oklch-to-hex.cjs",
|
|
48
|
+
"bads-size-audit": "scripts/size-audit.cjs"
|
|
48
49
|
},
|
|
49
50
|
"exports": {
|
|
50
51
|
".": "./src/index.ts",
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* size-audit — flag raw `<button>` CTAs at text-xs without the escape
|
|
4
|
+
* hatch. Companion to `a11y-lint.js`. Wired via `pnpm size-audit`.
|
|
5
|
+
*
|
|
6
|
+
* Why a separate script: a11y-lint already catches text-[<14>px] (sub-
|
|
7
|
+
* 14px floor) but text-xs IS 14px in BADS' scale, so it passes a11y.
|
|
8
|
+
* The size-audit rule is *brand consistency*, not accessibility: every
|
|
9
|
+
* CTA across a BADS-derived consumer should be the same size, and the
|
|
10
|
+
* default size is text-sm (16px). text-xs on a clickable CTA is a
|
|
11
|
+
* brand regression even though it clears AAA.
|
|
12
|
+
*
|
|
13
|
+
* Scan scope:
|
|
14
|
+
* app/ — BADS showcase + preview surfaces
|
|
15
|
+
* components/ — BADS shared component compositions
|
|
16
|
+
* packages/core/src/components/ — BADS primitives
|
|
17
|
+
*
|
|
18
|
+
* Client forks adapt the SCAN_ROOTS to their own tree (typical:
|
|
19
|
+
* app/_content/, app/<shell>/, app/<prototype>/).
|
|
20
|
+
*
|
|
21
|
+
* Detection: line contains BOTH `text-xs` AND a className for a
|
|
22
|
+
* `<button>` opening tag in the same line OR within 8 lines after.
|
|
23
|
+
* The escape hatch is `// allow-text-xs-cta` on the line above the
|
|
24
|
+
* button.
|
|
25
|
+
*
|
|
26
|
+
* Run:
|
|
27
|
+
* pnpm size-audit # report violations, exit 1 on fail
|
|
28
|
+
* pnpm size-audit:warn # report but exit 0 (advisory)
|
|
29
|
+
* node scripts/size-audit.js path/to.tsx # scan a specific file
|
|
30
|
+
*
|
|
31
|
+
* Rule code: BADS-2. (BADS-1 = raw <button> not using BADS Button.)
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
'use strict';
|
|
35
|
+
|
|
36
|
+
const fs = require('fs');
|
|
37
|
+
const path = require('path');
|
|
38
|
+
|
|
39
|
+
// Packaged as the `bads-size-audit` bin: runs against the CONSUMER repo
|
|
40
|
+
// (cwd), so prototype repos and client forks get the CTA size contract
|
|
41
|
+
// without copying the script. Pass scan roots as positional args
|
|
42
|
+
// (`bads-size-audit app components`) or rely on the defaults below.
|
|
43
|
+
const ROOT = process.cwd();
|
|
44
|
+
const advisory = process.argv.includes('--warn');
|
|
45
|
+
const argPaths = process.argv.slice(2).filter((a) => !a.startsWith('--'));
|
|
46
|
+
const argRoots = argPaths.filter((p) => fs.existsSync(p) && fs.statSync(p).isDirectory());
|
|
47
|
+
const explicitPaths = argPaths.filter((p) => !argRoots.includes(p));
|
|
48
|
+
|
|
49
|
+
const SCAN_ROOTS = argRoots.length
|
|
50
|
+
? argRoots
|
|
51
|
+
: ['app', 'components', 'src'].filter((r) => fs.existsSync(path.join(ROOT, r)));
|
|
52
|
+
|
|
53
|
+
function walk(dir, out = []) {
|
|
54
|
+
if (!fs.existsSync(dir)) return out;
|
|
55
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
56
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
|
57
|
+
const full = path.join(dir, entry.name);
|
|
58
|
+
if (entry.isDirectory()) {
|
|
59
|
+
walk(full, out);
|
|
60
|
+
} else if (/\.tsx?$/.test(entry.name)) {
|
|
61
|
+
out.push(full);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return out;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const files = explicitPaths.length
|
|
68
|
+
? explicitPaths.map((p) => path.resolve(p))
|
|
69
|
+
: SCAN_ROOTS.flatMap((r) => walk(path.join(ROOT, r)));
|
|
70
|
+
|
|
71
|
+
const issues = [];
|
|
72
|
+
|
|
73
|
+
function flag(file, line, rule, message) {
|
|
74
|
+
issues.push({ file: path.relative(ROOT, file), line, rule, message });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const BUTTON_OPEN = /<button\b/;
|
|
78
|
+
const TEXT_XS = /\btext-xs\b/;
|
|
79
|
+
const ESCAPE_HATCH = /allow-text-xs-cta/;
|
|
80
|
+
|
|
81
|
+
for (const file of files) {
|
|
82
|
+
let src;
|
|
83
|
+
try { src = fs.readFileSync(file, 'utf8'); } catch { continue; }
|
|
84
|
+
if (file.endsWith('.test.ts') || file.endsWith('.spec.ts')) continue;
|
|
85
|
+
if (file.endsWith('.stories.tsx')) continue;
|
|
86
|
+
if (src.startsWith('/* GENERATED')) continue;
|
|
87
|
+
// The BADS Button primitive itself defines text-xs for the `xs` size
|
|
88
|
+
// variant — that's legitimate. The rule applies to consumers, not the
|
|
89
|
+
// primitive's own definition.
|
|
90
|
+
if (file.endsWith('/components/ui/button.tsx')) continue;
|
|
91
|
+
if (file.endsWith('/components/ui/toggle.tsx')) continue;
|
|
92
|
+
|
|
93
|
+
const lines = src.split('\n');
|
|
94
|
+
|
|
95
|
+
for (let i = 0; i < lines.length; i++) {
|
|
96
|
+
if (!BUTTON_OPEN.test(lines[i])) continue;
|
|
97
|
+
|
|
98
|
+
let foundTextXs = false;
|
|
99
|
+
let classLine = -1;
|
|
100
|
+
for (let j = i; j < Math.min(i + 8, lines.length); j++) {
|
|
101
|
+
if (TEXT_XS.test(lines[j])) {
|
|
102
|
+
foundTextXs = true;
|
|
103
|
+
classLine = j;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
if (/^[^"']*>/.test(lines[j].replace(/className=\{[^}]*\}/, ''))) {
|
|
107
|
+
if (j > i) break;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (!foundTextXs) continue;
|
|
111
|
+
|
|
112
|
+
let escaped = false;
|
|
113
|
+
for (let k = i - 1; k >= Math.max(0, i - 3); k--) {
|
|
114
|
+
if (ESCAPE_HATCH.test(lines[k])) {
|
|
115
|
+
escaped = true;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (escaped) continue;
|
|
120
|
+
|
|
121
|
+
flag(file, classLine + 1, 'BADS-2',
|
|
122
|
+
`Raw <button> with text-xs is below the CTA size contract (text-sm / 16px). Bump to text-sm, or add "// allow-text-xs-cta" on the line above the <button> with a reason (see prompts/cta-size-contract.md).`);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (issues.length === 0) {
|
|
127
|
+
console.log('✓ size-audit: every CTA reads at text-sm. No size divergence.');
|
|
128
|
+
process.exit(0);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const grouped = issues.reduce((acc, it) => {
|
|
132
|
+
(acc[it.file] = acc[it.file] || []).push(it);
|
|
133
|
+
return acc;
|
|
134
|
+
}, {});
|
|
135
|
+
|
|
136
|
+
for (const file of Object.keys(grouped).sort()) {
|
|
137
|
+
console.log(`\n${file}`);
|
|
138
|
+
for (const it of grouped[file]) {
|
|
139
|
+
const tag = `[${it.rule}]`;
|
|
140
|
+
console.log(` L${it.line} ${tag.padEnd(10)} ${it.message}`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
console.log(
|
|
145
|
+
`\n${issues.length} CTA size violation${issues.length === 1 ? '' : 's'} across ${Object.keys(grouped).length} file${Object.keys(grouped).length === 1 ? '' : 's'}.`,
|
|
146
|
+
);
|
|
147
|
+
process.exit(advisory ? 0 : 1);
|
package/src/api/layers/file.ts
CHANGED
package/src/app/layout.tsx
CHANGED
|
@@ -70,11 +70,36 @@ const sourceSerif = Source_Serif_4({
|
|
|
70
70
|
variable: "--font-source-serif",
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
// Title
|
|
74
|
-
//
|
|
73
|
+
// Title, description, and social/canonical metadata all derive from
|
|
74
|
+
// brand.config so each fork reflects its own identity without overriding this
|
|
75
|
+
// file. `url` (optional) drives metadataBase + canonical + the OG url;
|
|
76
|
+
// `description` (optional) is the meta/OG copy, falling back to the tagline.
|
|
77
|
+
// Read defensively so forks that predate these fields still build.
|
|
78
|
+
const siteTitle = brand.tagline ? `${brand.name} — ${brand.tagline}` : brand.name;
|
|
79
|
+
const siteDescription =
|
|
80
|
+
(brand as { description?: string }).description ??
|
|
81
|
+
brand.tagline ??
|
|
82
|
+
"Interactive design system and component dashboard";
|
|
83
|
+
const siteUrl = (brand as { url?: string }).url;
|
|
84
|
+
|
|
75
85
|
export const metadata: Metadata = {
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
...(siteUrl ? { metadataBase: new URL(siteUrl) } : {}),
|
|
87
|
+
title: siteTitle,
|
|
88
|
+
description: siteDescription,
|
|
89
|
+
applicationName: brand.name,
|
|
90
|
+
openGraph: {
|
|
91
|
+
title: siteTitle,
|
|
92
|
+
description: siteDescription,
|
|
93
|
+
siteName: brand.name,
|
|
94
|
+
type: "website",
|
|
95
|
+
...(siteUrl ? { url: siteUrl } : {}),
|
|
96
|
+
},
|
|
97
|
+
twitter: {
|
|
98
|
+
card: "summary_large_image",
|
|
99
|
+
title: siteTitle,
|
|
100
|
+
description: siteDescription,
|
|
101
|
+
},
|
|
102
|
+
...(siteUrl ? { alternates: { canonical: siteUrl } } : {}),
|
|
78
103
|
};
|
|
79
104
|
|
|
80
105
|
export default function RootLayout({
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ImageResponse } from "next/og";
|
|
2
|
+
import { brand } from "@/brand.config";
|
|
3
|
+
|
|
4
|
+
// Branded social-preview card (Open Graph + Twitter), derived entirely from
|
|
5
|
+
// brand.config so every fork gets its own image with zero per-fork code. A
|
|
6
|
+
// consumer surfaces it by re-exporting this route from its own app/ dir:
|
|
7
|
+
//
|
|
8
|
+
// // app/opengraph-image.tsx
|
|
9
|
+
// export { default, size, contentType, alt } from
|
|
10
|
+
// "@behavioral-agentic-design-system/core/app/opengraph-image";
|
|
11
|
+
//
|
|
12
|
+
// Kept font-free on purpose: it uses next/og's built-in font so the build
|
|
13
|
+
// never depends on a network font fetch (satori also can't read the woff2
|
|
14
|
+
// files @core ships). Hierarchy comes from size + color, not weight.
|
|
15
|
+
|
|
16
|
+
export const size = { width: 1200, height: 630 };
|
|
17
|
+
export const contentType = "image/png";
|
|
18
|
+
export const alt = brand.tagline
|
|
19
|
+
? `${brand.name} — ${brand.tagline}`
|
|
20
|
+
: brand.name;
|
|
21
|
+
|
|
22
|
+
export default function OpengraphImage() {
|
|
23
|
+
// Default brand color if the fork hasn't pinned one (BADS ships colors: []).
|
|
24
|
+
// #025fff doubles as BADS' own audited primary, so both look intentional.
|
|
25
|
+
const accent =
|
|
26
|
+
(brand.colors?.[0]?.primary as string | undefined) ?? "#025fff";
|
|
27
|
+
const description =
|
|
28
|
+
(brand as { description?: string }).description ?? brand.tagline ?? "";
|
|
29
|
+
|
|
30
|
+
return new ImageResponse(
|
|
31
|
+
(
|
|
32
|
+
<div
|
|
33
|
+
style={{
|
|
34
|
+
height: "100%",
|
|
35
|
+
width: "100%",
|
|
36
|
+
display: "flex",
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
justifyContent: "space-between",
|
|
39
|
+
background: "#0a0b0d",
|
|
40
|
+
color: "#ffffff",
|
|
41
|
+
padding: "88px",
|
|
42
|
+
fontFamily: "sans-serif",
|
|
43
|
+
}}
|
|
44
|
+
>
|
|
45
|
+
<div style={{ display: "flex", alignItems: "center", gap: "22px" }}>
|
|
46
|
+
<div
|
|
47
|
+
style={{
|
|
48
|
+
width: "56px",
|
|
49
|
+
height: "56px",
|
|
50
|
+
borderRadius: "16px",
|
|
51
|
+
background: accent,
|
|
52
|
+
}}
|
|
53
|
+
/>
|
|
54
|
+
<div
|
|
55
|
+
style={{
|
|
56
|
+
fontSize: "28px",
|
|
57
|
+
letterSpacing: "0.28em",
|
|
58
|
+
color: "#8b95a7",
|
|
59
|
+
textTransform: "uppercase",
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
Design System
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
|
|
66
|
+
<div
|
|
67
|
+
style={{
|
|
68
|
+
display: "flex",
|
|
69
|
+
flexDirection: "column",
|
|
70
|
+
gap: "28px",
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<div style={{ fontSize: "116px", lineHeight: 1, color: "#ffffff" }}>
|
|
74
|
+
{brand.name}
|
|
75
|
+
</div>
|
|
76
|
+
{description ? (
|
|
77
|
+
<div
|
|
78
|
+
style={{
|
|
79
|
+
fontSize: "40px",
|
|
80
|
+
lineHeight: 1.3,
|
|
81
|
+
color: "#b7c0cf",
|
|
82
|
+
maxWidth: "940px",
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
{description}
|
|
86
|
+
</div>
|
|
87
|
+
) : null}
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div
|
|
91
|
+
style={{
|
|
92
|
+
display: "flex",
|
|
93
|
+
height: "12px",
|
|
94
|
+
width: "100%",
|
|
95
|
+
borderRadius: "999px",
|
|
96
|
+
background: accent,
|
|
97
|
+
}}
|
|
98
|
+
/>
|
|
99
|
+
</div>
|
|
100
|
+
),
|
|
101
|
+
{ ...size },
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -19,6 +19,19 @@ import {
|
|
|
19
19
|
import { Button } from "@behavioral-agentic-design-system/core/components/ui/button";
|
|
20
20
|
import { ButtonGroup } from "@behavioral-agentic-design-system/core/components/ui/button-group";
|
|
21
21
|
import { Input } from "@behavioral-agentic-design-system/core/components/ui/input";
|
|
22
|
+
import {
|
|
23
|
+
InputGroup,
|
|
24
|
+
InputGroupInput,
|
|
25
|
+
InputGroupAddon,
|
|
26
|
+
InputGroupText,
|
|
27
|
+
InputGroupButton,
|
|
28
|
+
} from "@behavioral-agentic-design-system/core/components/ui/input-group";
|
|
29
|
+
import {
|
|
30
|
+
Fieldset,
|
|
31
|
+
FieldsetLegend,
|
|
32
|
+
FieldsetHelper,
|
|
33
|
+
FieldsetError,
|
|
34
|
+
} from "@behavioral-agentic-design-system/core/components/ui/fieldset";
|
|
22
35
|
import { Label } from "@behavioral-agentic-design-system/core/components/ui/label";
|
|
23
36
|
import { Badge } from "@behavioral-agentic-design-system/core/components/ui/badge";
|
|
24
37
|
import { Switch } from "@behavioral-agentic-design-system/core/components/ui/switch";
|
|
@@ -255,7 +268,7 @@ import {
|
|
|
255
268
|
SheetTitle,
|
|
256
269
|
SheetTrigger,
|
|
257
270
|
} from "@behavioral-agentic-design-system/core/components/ui/sheet";
|
|
258
|
-
import { TrendingUp, MoreHorizontal, Folder, File, FileText, Settings as SettingsIcon, Users as UsersIcon } from "lucide-react";
|
|
271
|
+
import { TrendingUp, MoreHorizontal, Folder, File, FileText, Settings as SettingsIcon, Users as UsersIcon, Search, Copy } from "lucide-react";
|
|
259
272
|
import {
|
|
260
273
|
Tree,
|
|
261
274
|
TreeItem,
|
|
@@ -636,20 +649,20 @@ export default function ComponentsPreview() {
|
|
|
636
649
|
<Section title="Form controls">
|
|
637
650
|
<div className="flex flex-wrap items-center gap-6">
|
|
638
651
|
<div className="flex items-center gap-2">
|
|
639
|
-
<Switch id="sw" defaultChecked />
|
|
652
|
+
<Switch id="sw" defaultChecked aria-label="Switch" />
|
|
640
653
|
<Label htmlFor="sw">Switch</Label>
|
|
641
654
|
</div>
|
|
642
655
|
<div className="flex items-center gap-2">
|
|
643
|
-
<Checkbox id="cb" defaultChecked />
|
|
656
|
+
<Checkbox id="cb" defaultChecked aria-label="Checkbox" />
|
|
644
657
|
<Label htmlFor="cb">Checkbox</Label>
|
|
645
658
|
</div>
|
|
646
659
|
<RadioGroup defaultValue="a" className="flex items-center gap-3">
|
|
647
660
|
<div className="flex items-center gap-2">
|
|
648
|
-
<RadioGroupItem id="r-a" value="a" />
|
|
661
|
+
<RadioGroupItem id="r-a" value="a" aria-label="Option A" />
|
|
649
662
|
<Label htmlFor="r-a">Option A</Label>
|
|
650
663
|
</div>
|
|
651
664
|
<div className="flex items-center gap-2">
|
|
652
|
-
<RadioGroupItem id="r-b" value="b" />
|
|
665
|
+
<RadioGroupItem id="r-b" value="b" aria-label="Option B" />
|
|
653
666
|
<Label htmlFor="r-b">Option B</Label>
|
|
654
667
|
</div>
|
|
655
668
|
</RadioGroup>
|
|
@@ -3023,6 +3036,112 @@ export default function ComponentsPreview() {
|
|
|
3023
3036
|
</div>
|
|
3024
3037
|
</div>
|
|
3025
3038
|
</Section>
|
|
3039
|
+
|
|
3040
|
+
<Section title="Input Group">
|
|
3041
|
+
<div className="flex flex-col gap-6">
|
|
3042
|
+
<div className="flex flex-wrap items-start gap-8">
|
|
3043
|
+
<div className="space-y-1.5">
|
|
3044
|
+
<p className="text-xs font-medium text-muted-foreground">Leading icon</p>
|
|
3045
|
+
<InputGroup className="w-72">
|
|
3046
|
+
<InputGroupAddon align="inline-start">
|
|
3047
|
+
<Search aria-hidden />
|
|
3048
|
+
</InputGroupAddon>
|
|
3049
|
+
<InputGroupInput placeholder="Search sessions" aria-label="Search" />
|
|
3050
|
+
</InputGroup>
|
|
3051
|
+
</div>
|
|
3052
|
+
<div className="space-y-1.5">
|
|
3053
|
+
<p className="text-xs font-medium text-muted-foreground">Currency prefix + unit suffix</p>
|
|
3054
|
+
<InputGroup className="w-72">
|
|
3055
|
+
<InputGroupAddon align="inline-start">
|
|
3056
|
+
<InputGroupText>$</InputGroupText>
|
|
3057
|
+
</InputGroupAddon>
|
|
3058
|
+
<InputGroupInput defaultValue="49.00" inputMode="decimal" aria-label="Amount" />
|
|
3059
|
+
<InputGroupAddon align="inline-end">
|
|
3060
|
+
<InputGroupText>/ mo</InputGroupText>
|
|
3061
|
+
</InputGroupAddon>
|
|
3062
|
+
</InputGroup>
|
|
3063
|
+
</div>
|
|
3064
|
+
</div>
|
|
3065
|
+
<div className="flex flex-wrap items-start gap-8">
|
|
3066
|
+
<div className="space-y-1.5">
|
|
3067
|
+
<p className="text-xs font-medium text-muted-foreground">Protocol prefix</p>
|
|
3068
|
+
<InputGroup className="w-72">
|
|
3069
|
+
<InputGroupAddon align="inline-start">
|
|
3070
|
+
<InputGroupText>https://</InputGroupText>
|
|
3071
|
+
</InputGroupAddon>
|
|
3072
|
+
<InputGroupInput defaultValue="ramanathan.co" aria-label="Website" />
|
|
3073
|
+
</InputGroup>
|
|
3074
|
+
</div>
|
|
3075
|
+
<div className="space-y-1.5">
|
|
3076
|
+
<p className="text-xs font-medium text-muted-foreground">Inline action</p>
|
|
3077
|
+
<InputGroup className="w-72">
|
|
3078
|
+
<InputGroupInput
|
|
3079
|
+
readOnly
|
|
3080
|
+
value="avery.castillo@protonmail.com"
|
|
3081
|
+
aria-label="Invite email"
|
|
3082
|
+
/>
|
|
3083
|
+
<InputGroupButton aria-label="Copy email">
|
|
3084
|
+
<Copy aria-hidden /> Copy
|
|
3085
|
+
</InputGroupButton>
|
|
3086
|
+
</InputGroup>
|
|
3087
|
+
</div>
|
|
3088
|
+
</div>
|
|
3089
|
+
</div>
|
|
3090
|
+
</Section>
|
|
3091
|
+
|
|
3092
|
+
<Section title="Fieldset">
|
|
3093
|
+
<div className="flex flex-wrap items-start gap-8">
|
|
3094
|
+
<Fieldset className="w-80">
|
|
3095
|
+
<FieldsetLegend>Notification preferences</FieldsetLegend>
|
|
3096
|
+
<FieldsetHelper>Choose how we reach Jordan Reeves.</FieldsetHelper>
|
|
3097
|
+
<div className="flex flex-col gap-3">
|
|
3098
|
+
<div className="flex items-center gap-2.5">
|
|
3099
|
+
<Checkbox id="fs-email" defaultChecked />
|
|
3100
|
+
<Label htmlFor="fs-email" className="font-normal">Email digest</Label>
|
|
3101
|
+
</div>
|
|
3102
|
+
<div className="flex items-center gap-2.5">
|
|
3103
|
+
<Checkbox id="fs-push" defaultChecked />
|
|
3104
|
+
<Label htmlFor="fs-push" className="font-normal">Push notifications</Label>
|
|
3105
|
+
</div>
|
|
3106
|
+
<div className="flex items-center gap-2.5">
|
|
3107
|
+
<Checkbox id="fs-sms" />
|
|
3108
|
+
<Label htmlFor="fs-sms" className="font-normal">SMS alerts</Label>
|
|
3109
|
+
</div>
|
|
3110
|
+
</div>
|
|
3111
|
+
</Fieldset>
|
|
3112
|
+
|
|
3113
|
+
<Fieldset invalid className="w-80">
|
|
3114
|
+
<FieldsetLegend>Contact method</FieldsetLegend>
|
|
3115
|
+
<FieldsetHelper>We’ll only use this for security alerts.</FieldsetHelper>
|
|
3116
|
+
<RadioGroup className="gap-3">
|
|
3117
|
+
<div className="flex items-center gap-2.5">
|
|
3118
|
+
<RadioGroupItem value="email" id="fs-c-email" />
|
|
3119
|
+
<Label htmlFor="fs-c-email" className="font-normal">Email</Label>
|
|
3120
|
+
</div>
|
|
3121
|
+
<div className="flex items-center gap-2.5">
|
|
3122
|
+
<RadioGroupItem value="phone" id="fs-c-phone" />
|
|
3123
|
+
<Label htmlFor="fs-c-phone" className="font-normal">Phone</Label>
|
|
3124
|
+
</div>
|
|
3125
|
+
</RadioGroup>
|
|
3126
|
+
<FieldsetError>Choose at least one contact method.</FieldsetError>
|
|
3127
|
+
</Fieldset>
|
|
3128
|
+
|
|
3129
|
+
<Fieldset disabled variant="unstyled" className="w-72">
|
|
3130
|
+
<FieldsetLegend>Release channel (locked)</FieldsetLegend>
|
|
3131
|
+
<FieldsetHelper>Locked while Marcus Lindqvist’s plan is read-only.</FieldsetHelper>
|
|
3132
|
+
<RadioGroup defaultValue="stable" className="gap-3">
|
|
3133
|
+
<div className="flex items-center gap-2.5">
|
|
3134
|
+
<RadioGroupItem value="stable" id="fs-r-stable" />
|
|
3135
|
+
<Label htmlFor="fs-r-stable" className="font-normal">Stable</Label>
|
|
3136
|
+
</div>
|
|
3137
|
+
<div className="flex items-center gap-2.5">
|
|
3138
|
+
<RadioGroupItem value="beta" id="fs-r-beta" />
|
|
3139
|
+
<Label htmlFor="fs-r-beta" className="font-normal">Beta</Label>
|
|
3140
|
+
</div>
|
|
3141
|
+
</RadioGroup>
|
|
3142
|
+
</Fieldset>
|
|
3143
|
+
</div>
|
|
3144
|
+
</Section>
|
|
3026
3145
|
</div>
|
|
3027
3146
|
</div>
|
|
3028
3147
|
);
|
package/src/app/shell.tsx
CHANGED
|
@@ -57,10 +57,13 @@ export function IframePreview({
|
|
|
57
57
|
src,
|
|
58
58
|
minWidth,
|
|
59
59
|
dark,
|
|
60
|
+
title,
|
|
60
61
|
}: {
|
|
61
62
|
src: string;
|
|
62
63
|
minWidth?: string;
|
|
63
64
|
dark: boolean;
|
|
65
|
+
/** Accessible label for the iframe — required by screen readers. Falls back to the src path. */
|
|
66
|
+
title?: string;
|
|
64
67
|
}) {
|
|
65
68
|
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
66
69
|
// Capture the initial src once on mount. After load, dark mode is applied via
|
|
@@ -99,6 +102,7 @@ export function IframePreview({
|
|
|
99
102
|
<iframe
|
|
100
103
|
ref={iframeRef}
|
|
101
104
|
src={initialSrcRef.current}
|
|
105
|
+
title={title ?? src}
|
|
102
106
|
onLoad={() => {
|
|
103
107
|
syncDarkMode();
|
|
104
108
|
setLoaded(true);
|
|
@@ -174,12 +178,12 @@ export type ShellProps = {
|
|
|
174
178
|
export const DEFAULT_TABS: ShellTab[] = [
|
|
175
179
|
{ value: "home", label: "Home", render: ({ goToTab }) => <HomeTab onBrowseDocs={() => goToTab("docs")} onBrowseComponents={() => goToTab("components")} /> },
|
|
176
180
|
{ value: "docs", label: "Docs", render: () => <DocsTab /> },
|
|
177
|
-
{ value: "components", label: "Components", render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" /> },
|
|
178
|
-
{ value: "cards", label: "Cards", render: ({ dark }) => <IframePreview dark={dark} src="/preview/cards" /> },
|
|
179
|
-
{ value: "dashboard", label: "Dashboard", hidden: "md", render: ({ dark }) => <IframePreview dark={dark} src="/preview/dashboard" minWidth="1400px" /> },
|
|
181
|
+
{ value: "components", label: "Components", render: ({ dark }) => <IframePreview dark={dark} src="/preview/components" title="Components preview" /> },
|
|
182
|
+
{ value: "cards", label: "Cards", render: ({ dark }) => <IframePreview dark={dark} src="/preview/cards" title="Cards preview" /> },
|
|
183
|
+
{ value: "dashboard", label: "Dashboard", hidden: "md", render: ({ dark }) => <IframePreview dark={dark} src="/preview/dashboard" minWidth="1400px" title="Dashboard preview" /> },
|
|
180
184
|
{ value: "layers", label: "Layers", render: () => <LayersTab /> },
|
|
181
|
-
{ value: "icons", label: "Icons", noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/icons" /> },
|
|
182
|
-
{ value: "
|
|
185
|
+
{ value: "icons", label: "Icons", noPreload: true, render: ({ dark }) => <IframePreview dark={dark} src="/preview/icons" title="Icons preview" /> },
|
|
186
|
+
{ value: "customize", label: "Customize", render: () => <CustomizeTab /> },
|
|
183
187
|
];
|
|
184
188
|
|
|
185
189
|
/**
|
|
@@ -408,6 +412,14 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
408
412
|
return (
|
|
409
413
|
<ShellNavContext.Provider value={navValue}>
|
|
410
414
|
<div className="min-h-screen bg-background flex flex-col">
|
|
415
|
+
{/* Skip-to-content: visually hidden until focused so keyboard users can
|
|
416
|
+
bypass the header and tab strip and jump straight to the panel area. */}
|
|
417
|
+
<a
|
|
418
|
+
href="#main-content"
|
|
419
|
+
className="sr-only focus:not-sr-only focus:absolute focus:z-50 focus:top-2 focus:left-2 focus:rounded-md focus:bg-primary focus:px-3 focus:py-2 focus:text-primary-foreground"
|
|
420
|
+
>
|
|
421
|
+
Skip to main content
|
|
422
|
+
</a>
|
|
411
423
|
<header className="border-b bg-card shrink-0">
|
|
412
424
|
<div className="flex h-14 items-center px-4 sm:px-6">
|
|
413
425
|
<div className="flex items-center gap-2 min-w-0">
|
|
@@ -547,7 +559,7 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
547
559
|
</TabsList>
|
|
548
560
|
</div>
|
|
549
561
|
|
|
550
|
-
<section className="relative flex-1 min-h-0 w-full overflow-hidden">
|
|
562
|
+
<section id="main-content" tabIndex={-1} className="relative flex-1 min-h-0 w-full overflow-hidden">
|
|
551
563
|
<div className="absolute inset-x-4 top-1 bottom-4 isolate overflow-hidden rounded-lg">
|
|
552
564
|
<TabsPanels>
|
|
553
565
|
{tabs.map((tab) => {
|
|
@@ -555,8 +567,20 @@ export function Shell({ tabs, defaultTab }: ShellProps) {
|
|
|
555
567
|
// everything else mounts once seen and stays for instant
|
|
556
568
|
// cross-fades. See ShellTab.noPreload.
|
|
557
569
|
const mounted = tab.noPreload ? activeTab === tab.value : seen.has(tab.value);
|
|
570
|
+
const isActive = activeTab === tab.value;
|
|
571
|
+
// Inactive forceMount panels are hidden from the a11y tree:
|
|
572
|
+
// `aria-hidden` removes them from the accessibility tree, and
|
|
573
|
+
// `inert` blocks focus into them — together they prevent multiple
|
|
574
|
+
// live <h1>s and duplicate landmark navigation while keeping the
|
|
575
|
+
// DOM mounted for the cross-fade. Active panel gets neither.
|
|
558
576
|
return mounted ? (
|
|
559
|
-
<TabsContent
|
|
577
|
+
<TabsContent
|
|
578
|
+
key={tab.value}
|
|
579
|
+
value={tab.value}
|
|
580
|
+
forceMount
|
|
581
|
+
aria-hidden={isActive ? undefined : true}
|
|
582
|
+
inert={isActive ? undefined : true}
|
|
583
|
+
>
|
|
560
584
|
{tab.render(ctx)}
|
|
561
585
|
</TabsContent>
|
|
562
586
|
) : null;
|