@hahlex/millar-mcp 0.0.0-stage → 0.1.0-draft.1
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/LICENSE +21 -0
- package/dist/docs/CHANGELOG.md +21 -0
- package/dist/docs/GLOSSARY.md +77 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +39566 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +6 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +1115 -0
- package/dist/server.js.map +1 -0
- package/dist/skills/millar-animation/SKILL.md +66 -0
- package/dist/skills/millar-animation/references/animation-research-patterns.md +28 -0
- package/dist/skills/millar-animation/references/motion-choreography.md +80 -0
- package/dist/skills/millar-build-web/SKILL.md +59 -0
- package/dist/skills/millar-build-web/references/seo-cwv-and-copy.md +24 -0
- package/dist/skills/millar-build-web/references/web-architecture-checklist.md +47 -0
- package/dist/skills/millar-create-image/SKILL.md +62 -0
- package/dist/skills/millar-create-image/references/human-editorial-photography.md +74 -0
- package/dist/skills/millar-create-image/references/hybrid-plate-compositing.md +43 -0
- package/dist/skills/millar-create-image/references/image-art-direction.md +74 -0
- package/dist/skills/millar-create-image/references/multi-page-asset-map.md +27 -0
- package/dist/skills/millar-create-image/references/natural-editorial-illustration.md +57 -0
- package/dist/skills/millar-create-image/references/procedural-gallery-craft.md +84 -0
- package/dist/skills/millar-create-image/scripts/embed-provenance.mjs +185 -0
- package/dist/skills/millar-deep-research/SKILL.md +62 -0
- package/dist/skills/millar-deep-research/references/visual-extraction-protocol.md +36 -0
- package/dist/skills/millar-deep-research/references/world-class-benchmarks.md +30 -0
- package/dist/skills/millar-design/SKILL.md +83 -0
- package/dist/skills/millar-design/references/aesthetic-movements.md +49 -0
- package/dist/skills/millar-design/references/cross-page-sync-audit.md +25 -0
- package/dist/skills/millar-design/references/style-dna-contract.md +89 -0
- package/dist/skills/millar-verify-web/SKILL.md +76 -0
- package/dist/skills/millar-verify-web/references/five-layer-qa-gate.md +104 -0
- package/dist/skills/millar-verify-web/references/two-axis-review-rubric.md +23 -0
- package/dist/skills/millar-verify-web/scripts/millar-audit.mjs +617 -0
- package/dist/skills/millar-web-workflow/SKILL.md +60 -0
- package/dist/skills/millar-web-workflow/references/creative-divergence-protocol.md +52 -0
- package/dist/skills/millar-web-workflow/references/track-routing-and-gates.md +32 -0
- package/dist/skills-loader.d.ts +47 -0
- package/dist/skills-loader.d.ts.map +1 -0
- package/dist/skills-loader.js +204 -0
- package/dist/skills-loader.js.map +1 -0
- package/dist/sources/packages/marketing/src/assets/BrandAndGeometricAssets.tsx +373 -0
- package/dist/sources/packages/marketing/src/assets/SchematicAndProductAssets.tsx +497 -0
- package/dist/sources/packages/marketing/src/sections/MarketingSections.tsx +946 -0
- package/dist/sources/packages/marketing/src/templates/PageTemplates.tsx +304 -0
- package/dist/sources/packages/ui/src/components/Button.tsx +162 -0
- package/dist/sources/packages/ui/src/components/FormControls.tsx +476 -0
- package/dist/sources/packages/ui/src/components/Layout.tsx +176 -0
- package/dist/sources/packages/ui/src/components/OverlaysAndFeedback.tsx +291 -0
- package/dist/sources/packages/ui/src/components/SurfacesAndData.tsx +564 -0
- package/dist/stdio.d.ts +3 -0
- package/dist/stdio.d.ts.map +1 -0
- package/dist/stdio.js +37380 -0
- package/dist/stdio.js.map +1 -0
- package/package.json +48 -3
- package/README.md +0 -3
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Alert,
|
|
4
|
+
AppShell,
|
|
5
|
+
Badge,
|
|
6
|
+
Button,
|
|
7
|
+
Card,
|
|
8
|
+
DataTable,
|
|
9
|
+
FilterBar,
|
|
10
|
+
IconAdd,
|
|
11
|
+
IconHome,
|
|
12
|
+
IconLayers,
|
|
13
|
+
IconRefresh,
|
|
14
|
+
IconSettings,
|
|
15
|
+
IconShield,
|
|
16
|
+
IconUsers,
|
|
17
|
+
PageHeader,
|
|
18
|
+
Stat,
|
|
19
|
+
} from "@hahlex/millar-ui";
|
|
20
|
+
import { HahlexLockup } from "../assets/index.js";
|
|
21
|
+
import {
|
|
22
|
+
ArchitectureGridSection,
|
|
23
|
+
BentoNarrativeMosaic,
|
|
24
|
+
ClosingConversionBand,
|
|
25
|
+
EditorialEssaySplit,
|
|
26
|
+
HeroSpatialStage,
|
|
27
|
+
HeroTypographicPoster,
|
|
28
|
+
MetricMirrorSection,
|
|
29
|
+
MillarSiteFooter,
|
|
30
|
+
NativeAccordionFaq,
|
|
31
|
+
ProductStageShowcase,
|
|
32
|
+
WorkflowLoopSection,
|
|
33
|
+
} from "../sections/index.js";
|
|
34
|
+
|
|
35
|
+
/* ============================================================================
|
|
36
|
+
* Marketing Page Templates (Diverse Compositions, Top-Level <footer> Outside <main>)
|
|
37
|
+
* ============================================================================ */
|
|
38
|
+
|
|
39
|
+
export interface TemplatePreviewProps {
|
|
40
|
+
embedded?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function ProductLaunchTemplate({ embedded = false }: TemplatePreviewProps = {}) {
|
|
44
|
+
const MainTag = embedded ? "div" : "main";
|
|
45
|
+
const [notice, setNotice] = useState<string | null>(null);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div style={{ backgroundColor: "var(--bg-editorial)", color: "var(--fg-default)" }}>
|
|
49
|
+
<MainTag>
|
|
50
|
+
{notice ? (
|
|
51
|
+
<div style={{ padding: "16px clamp(16px, 4vw, 48px) 0" }}>
|
|
52
|
+
<Alert
|
|
53
|
+
tone="info"
|
|
54
|
+
title="Template preview interaction"
|
|
55
|
+
message={notice}
|
|
56
|
+
action={
|
|
57
|
+
<Button variant="ghost" size="sm" onClick={() => setNotice(null)}>
|
|
58
|
+
Dismiss
|
|
59
|
+
</Button>
|
|
60
|
+
}
|
|
61
|
+
/>
|
|
62
|
+
</div>
|
|
63
|
+
) : null}
|
|
64
|
+
<HeroSpatialStage
|
|
65
|
+
headingLevel={embedded ? "h3" : "h1"}
|
|
66
|
+
headline="One measured language for every Hahlex surface."
|
|
67
|
+
lead="Shared foundations, photo-free marketing craft, and accessible product primitives compiled from a single W3C DTCG 2025.10 source."
|
|
68
|
+
primaryCtaLabel="Explore Foundations"
|
|
69
|
+
secondaryCtaLabel="Inspect MCP Server"
|
|
70
|
+
onPrimaryCta={() => setNotice('Clicked "Explore Foundations" primary CTA in ProductLaunchTemplate.')}
|
|
71
|
+
onSecondaryCta={() => setNotice('Clicked "Inspect MCP Server" secondary CTA in ProductLaunchTemplate.')}
|
|
72
|
+
/>
|
|
73
|
+
<EditorialEssaySplit
|
|
74
|
+
heading="Warm editorial authority without photographic crutches."
|
|
75
|
+
body="Most AI-generated landing pages collapse into identical card grids the moment photography is absent. Millar replaces decorative filler with six intentional composition patterns, parametric diagrams, and stylized product chrome that look finished on initial paint."
|
|
76
|
+
quote="Every margin, axis, and contrast ratio is calibrated before the first line of product code ships."
|
|
77
|
+
quoteAttribution="Millar Visual Philosophy · Measured Warmth"
|
|
78
|
+
/>
|
|
79
|
+
<ProductStageShowcase />
|
|
80
|
+
<BentoNarrativeMosaic
|
|
81
|
+
heading="Built for designers, engineers, and autonomous coding agents"
|
|
82
|
+
lead="Tokens, live previews, and deterministic compliance checks come from one compiled registry so guidelines never drift from code."
|
|
83
|
+
/>
|
|
84
|
+
<WorkflowLoopSection />
|
|
85
|
+
<MetricMirrorSection />
|
|
86
|
+
<NativeAccordionFaq />
|
|
87
|
+
<ClosingConversionBand
|
|
88
|
+
onCta={() => setNotice('Clicked closing conversion CTA "Explore Millar Portal" in ProductLaunchTemplate.')}
|
|
89
|
+
/>
|
|
90
|
+
</MainTag>
|
|
91
|
+
<MillarSiteFooter embedded={embedded} />
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function EditorialFeatureTemplate({ embedded = false }: TemplatePreviewProps = {}) {
|
|
97
|
+
const MainTag = embedded ? "div" : "main";
|
|
98
|
+
const [notice, setNotice] = useState<string | null>(null);
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div style={{ backgroundColor: "var(--bg-editorial)", color: "var(--fg-default)" }}>
|
|
102
|
+
<MainTag>
|
|
103
|
+
{notice ? (
|
|
104
|
+
<div style={{ padding: "16px clamp(16px, 4vw, 48px) 0" }}>
|
|
105
|
+
<Alert
|
|
106
|
+
tone="info"
|
|
107
|
+
title="Template preview interaction"
|
|
108
|
+
message={notice}
|
|
109
|
+
action={
|
|
110
|
+
<Button variant="ghost" size="sm" onClick={() => setNotice(null)}>
|
|
111
|
+
Dismiss
|
|
112
|
+
</Button>
|
|
113
|
+
}
|
|
114
|
+
/>
|
|
115
|
+
</div>
|
|
116
|
+
) : null}
|
|
117
|
+
<HeroTypographicPoster
|
|
118
|
+
headingLevel={embedded ? "h3" : "h1"}
|
|
119
|
+
headline="Design systems should enforce craft, not write essays about it."
|
|
120
|
+
lead="Millar pairs Swiss typographic restraint with warm Hahlex materiality and machine-verifiable MCP compliance rules."
|
|
121
|
+
ctaLabel="Read Architecture"
|
|
122
|
+
onCta={() => setNotice('Clicked "Read Architecture" CTA in EditorialFeatureTemplate.')}
|
|
123
|
+
/>
|
|
124
|
+
<ArchitectureGridSection />
|
|
125
|
+
<EditorialEssaySplit
|
|
126
|
+
heading="Separated registers, unmistakable brand DNA."
|
|
127
|
+
body="Product apps demand crisp 1-glance density and zero CSS gradients. Marketing surfaces earn expressive pacing and purposeful approved horizon lighting. Both share Geist, Inter, Geist Mono, and one harmonized OKLCH Warm Sand ramp."
|
|
128
|
+
quote="Product and Marketing speak with one accent, never one rigid template."
|
|
129
|
+
quoteAttribution="Hahlex Design Governance · ADR-0002"
|
|
130
|
+
/>
|
|
131
|
+
<ClosingConversionBand
|
|
132
|
+
headline="Adopt Millar in your next Hahlex release."
|
|
133
|
+
ctaLabel="View Integration Guide"
|
|
134
|
+
onCta={() => setNotice('Clicked "View Integration Guide" closing CTA in EditorialFeatureTemplate.')}
|
|
135
|
+
/>
|
|
136
|
+
</MainTag>
|
|
137
|
+
<MillarSiteFooter embedded={embedded} />
|
|
138
|
+
</div>
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* ============================================================================
|
|
143
|
+
* Product/App Workspace Templates (Zero Gradients, 1-Glance Operational Density)
|
|
144
|
+
* ============================================================================ */
|
|
145
|
+
|
|
146
|
+
const INITIAL_DIRECTORY_ROWS = [
|
|
147
|
+
{ id: "r1", name: "Warm Sand Tokens", owner: "Core Platform", status: "Approved", contrast: "16.03:1" },
|
|
148
|
+
{ id: "r2", name: "Marketing Section Library", owner: "Brand Engineering", status: "Draft", contrast: "17.44:1" },
|
|
149
|
+
{ id: "r3", name: "Education Extension Pack", owner: "Hahlex Education", status: "Draft", contrast: "7.12:1" },
|
|
150
|
+
];
|
|
151
|
+
|
|
152
|
+
export function DirectoryWorkspaceTemplate({ embedded = false }: TemplatePreviewProps = {}) {
|
|
153
|
+
const [activeNav, setActiveNav] = useState<"directory" | "teams" | "settings">("directory");
|
|
154
|
+
const [query, setQuery] = useState("");
|
|
155
|
+
const [records, setRecords] = useState(INITIAL_DIRECTORY_ROWS);
|
|
156
|
+
const [proposalSeq, setProposalSeq] = useState(1);
|
|
157
|
+
|
|
158
|
+
const rows = records.filter(
|
|
159
|
+
(r) =>
|
|
160
|
+
r.name.toLowerCase().includes(query.toLowerCase()) ||
|
|
161
|
+
r.owner.toLowerCase().includes(query.toLowerCase()) ||
|
|
162
|
+
r.status.toLowerCase().includes(query.toLowerCase())
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
const handleAddProposal = () => {
|
|
166
|
+
const seq = proposalSeq;
|
|
167
|
+
setProposalSeq((n) => n + 1);
|
|
168
|
+
setRecords((prev) => [
|
|
169
|
+
{
|
|
170
|
+
id: `p-${seq}`,
|
|
171
|
+
name: `Domain Proposal #${seq}`,
|
|
172
|
+
owner: "Product Squad",
|
|
173
|
+
status: "Draft",
|
|
174
|
+
contrast: "12.09:1",
|
|
175
|
+
},
|
|
176
|
+
...prev,
|
|
177
|
+
]);
|
|
178
|
+
setActiveNav("directory");
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
return (
|
|
182
|
+
<AppShell
|
|
183
|
+
embedded={embedded}
|
|
184
|
+
brand={<HahlexLockup size={24} />}
|
|
185
|
+
onNavigate={(id) => setActiveNav(id as "directory" | "teams" | "settings")}
|
|
186
|
+
navItems={[
|
|
187
|
+
{ id: "directory", label: "Catalog", href: "#directory", icon: <IconLayers size="md" />, active: activeNav === "directory" },
|
|
188
|
+
{ id: "teams", label: "Teams", href: "#teams", icon: <IconUsers size="md" />, active: activeNav === "teams" },
|
|
189
|
+
{ id: "settings", label: "Governance", href: "#settings", icon: <IconSettings size="md" />, active: activeNav === "settings" },
|
|
190
|
+
]}
|
|
191
|
+
>
|
|
192
|
+
<PageHeader
|
|
193
|
+
embedded={embedded}
|
|
194
|
+
title={activeNav === "directory" ? "System Packages" : activeNav === "teams" ? "Steward Squads" : "Governance Policy"}
|
|
195
|
+
meta={<Badge tone="brand">{rows.length} items</Badge>}
|
|
196
|
+
primaryAction={
|
|
197
|
+
<Button variant="primary" icon={<IconAdd size="md" />} onClick={handleAddProposal}>
|
|
198
|
+
New proposal
|
|
199
|
+
</Button>
|
|
200
|
+
}
|
|
201
|
+
/>
|
|
202
|
+
{activeNav === "directory" ? (
|
|
203
|
+
<>
|
|
204
|
+
<FilterBar
|
|
205
|
+
searchValue={query}
|
|
206
|
+
onSearchChange={setQuery}
|
|
207
|
+
searchPlaceholder="Filter packages..."
|
|
208
|
+
activePills={query ? [{ key: "q", label: `Query: ${query}`, onRemove: () => setQuery("") }] : []}
|
|
209
|
+
onClearAll={() => setQuery("")}
|
|
210
|
+
/>
|
|
211
|
+
<DataTable
|
|
212
|
+
caption="Millar ecosystem packages"
|
|
213
|
+
columns={[
|
|
214
|
+
{ key: "name", header: "Package" },
|
|
215
|
+
{ key: "owner", header: "Steward" },
|
|
216
|
+
{
|
|
217
|
+
key: "status",
|
|
218
|
+
header: "Lifecycle",
|
|
219
|
+
render: (row) => <Badge tone={row.status === "Approved" ? "success" : "brand"}>{String(row.status)}</Badge>,
|
|
220
|
+
},
|
|
221
|
+
{ key: "contrast", header: "Min Contrast", align: "right", numeric: true },
|
|
222
|
+
]}
|
|
223
|
+
rows={rows}
|
|
224
|
+
rowKey={(r) => r.id}
|
|
225
|
+
/>
|
|
226
|
+
</>
|
|
227
|
+
) : activeNav === "teams" ? (
|
|
228
|
+
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))", gap: 14 }}>
|
|
229
|
+
<Card surface="base" padding="compact">
|
|
230
|
+
<strong>Core Platform</strong>
|
|
231
|
+
<span style={{ fontSize: "var(--text-meta)", color: "var(--fg-muted)" }}>Owns DTCG tokens, compiler, and validator gates.</span>
|
|
232
|
+
</Card>
|
|
233
|
+
<Card surface="base" padding="compact">
|
|
234
|
+
<strong>Brand Engineering</strong>
|
|
235
|
+
<span style={{ fontSize: "var(--text-meta)", color: "var(--fg-muted)" }}>Owns photo-free Marketing sections and visual assets.</span>
|
|
236
|
+
</Card>
|
|
237
|
+
</div>
|
|
238
|
+
) : (
|
|
239
|
+
<Alert
|
|
240
|
+
tone="info"
|
|
241
|
+
title="Human Sign-Off Required"
|
|
242
|
+
message="Proposals enter in Draft status and promote to Approved only after WCAG AA verification and design steward review."
|
|
243
|
+
/>
|
|
244
|
+
)}
|
|
245
|
+
</AppShell>
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export function AnalyticsDashboardTemplate({ embedded = false }: TemplatePreviewProps = {}) {
|
|
250
|
+
const [activeNav, setActiveNav] = useState<"home" | "audit">("home");
|
|
251
|
+
const [auditRuns, setAuditRuns] = useState(1);
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<AppShell
|
|
255
|
+
embedded={embedded}
|
|
256
|
+
brand={<HahlexLockup size={24} />}
|
|
257
|
+
onNavigate={(id) => setActiveNav(id as "home" | "audit")}
|
|
258
|
+
navItems={[
|
|
259
|
+
{ id: "home", label: "Overview", href: "#home", icon: <IconHome size="md" />, active: activeNav === "home" },
|
|
260
|
+
{ id: "audit", label: "Compliance", href: "#audit", icon: <IconShield size="md" />, active: activeNav === "audit" },
|
|
261
|
+
]}
|
|
262
|
+
>
|
|
263
|
+
<PageHeader
|
|
264
|
+
embedded={embedded}
|
|
265
|
+
title={activeNav === "home" ? "Design System Health" : "Automated Compliance Gates"}
|
|
266
|
+
meta={<Badge tone="success">All gates passing (Run #{auditRuns})</Badge>}
|
|
267
|
+
primaryAction={
|
|
268
|
+
<Button variant="white" size="sm" icon={<IconRefresh size="sm" />} onClick={() => setAuditRuns((n) => n + 1)}>
|
|
269
|
+
Re-run audit
|
|
270
|
+
</Button>
|
|
271
|
+
}
|
|
272
|
+
/>
|
|
273
|
+
{activeNav === "home" ? (
|
|
274
|
+
<>
|
|
275
|
+
<div style={{ display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))", gap: 14 }}>
|
|
276
|
+
<Stat label="WCAG AA Pairs" value="97 / 97" delta="0 failures" tone="success" icon={<IconShield size="md" />} progressPercent={100} />
|
|
277
|
+
<Stat label="CVD Min Delta-E" value="11.13" delta="Protan & Deutan" tone="brand" icon={<IconLayers size="md" />} progressPercent={88} />
|
|
278
|
+
<Stat label="Em-Dash Violations" value="0" delta="Hahlex-controlled files" tone="sage" icon={<IconUsers size="md" />} progressPercent={100} />
|
|
279
|
+
</div>
|
|
280
|
+
<Alert
|
|
281
|
+
tone="info"
|
|
282
|
+
title="Draft Governance Reminder"
|
|
283
|
+
message="All v0.1.0 entries remain in Draft until promoted via human sign-off."
|
|
284
|
+
/>
|
|
285
|
+
</>
|
|
286
|
+
) : (
|
|
287
|
+
<DataTable
|
|
288
|
+
caption="Automated compliance gate checks"
|
|
289
|
+
columns={[
|
|
290
|
+
{ key: "gate", header: "Gate" },
|
|
291
|
+
{ key: "result", header: "Result" },
|
|
292
|
+
{ key: "status", header: "Status", render: (r) => <Badge tone="success">{String(r.status)}</Badge> },
|
|
293
|
+
]}
|
|
294
|
+
rows={[
|
|
295
|
+
{ id: "g1", gate: "WCAG 2.1 AA Contrast Matrix", result: "97 / 97 pairs passing", status: "Pass" },
|
|
296
|
+
{ id: "g2", gate: "Zero Em-Dash Guard", result: "0 violations", status: "Pass" },
|
|
297
|
+
{ id: "g3", gate: "Product Zero-Gradient Rule", result: "Enforced across @hahlex/millar-ui", status: "Pass" },
|
|
298
|
+
]}
|
|
299
|
+
rowKey={(r) => r.id}
|
|
300
|
+
/>
|
|
301
|
+
)}
|
|
302
|
+
</AppShell>
|
|
303
|
+
);
|
|
304
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import React, { useCallback, useState } from "react";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
|
|
4
|
+
export type ButtonVariant = "primary" | "secondary" | "white" | "ghost" | "danger" | "success" | "row";
|
|
5
|
+
export type ButtonSize = "sm" | "md" | "lg";
|
|
6
|
+
|
|
7
|
+
export interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onClick"> {
|
|
8
|
+
variant?: ButtonVariant;
|
|
9
|
+
size?: ButtonSize;
|
|
10
|
+
pill?: boolean;
|
|
11
|
+
iconOnly?: boolean;
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
icon?: React.ReactNode;
|
|
14
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void | Promise<unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const VARIANT_STYLES: Record<ButtonVariant, React.CSSProperties> = {
|
|
18
|
+
primary: {
|
|
19
|
+
backgroundColor: "var(--accent)",
|
|
20
|
+
color: "var(--fg-on-accent)",
|
|
21
|
+
borderColor: "var(--accent)",
|
|
22
|
+
fontWeight: 500,
|
|
23
|
+
},
|
|
24
|
+
secondary: {
|
|
25
|
+
backgroundColor: "var(--bg-elevated-hover)",
|
|
26
|
+
color: "var(--fg-default)",
|
|
27
|
+
borderColor: "var(--border-default)",
|
|
28
|
+
fontWeight: 500,
|
|
29
|
+
},
|
|
30
|
+
white: {
|
|
31
|
+
backgroundColor: "var(--bg-surface)",
|
|
32
|
+
color: "var(--fg-default)",
|
|
33
|
+
borderColor: "var(--border-default)",
|
|
34
|
+
fontWeight: 500,
|
|
35
|
+
},
|
|
36
|
+
ghost: {
|
|
37
|
+
backgroundColor: "transparent",
|
|
38
|
+
color: "var(--fg-muted)",
|
|
39
|
+
borderColor: "transparent",
|
|
40
|
+
fontWeight: 500,
|
|
41
|
+
},
|
|
42
|
+
danger: {
|
|
43
|
+
// Outlined AA in both light (6.96:1) and dark (6.97:1) themes; never solid crimson with white in dark mode
|
|
44
|
+
backgroundColor: "var(--bg-surface)",
|
|
45
|
+
color: "var(--status-error)",
|
|
46
|
+
borderColor: "var(--status-error)",
|
|
47
|
+
fontWeight: 500,
|
|
48
|
+
},
|
|
49
|
+
success: {
|
|
50
|
+
backgroundColor: "var(--status-success-solid)",
|
|
51
|
+
color: "var(--status-success-on-solid)",
|
|
52
|
+
borderColor: "var(--status-success-solid)",
|
|
53
|
+
fontWeight: 500,
|
|
54
|
+
},
|
|
55
|
+
row: {
|
|
56
|
+
backgroundColor: "transparent",
|
|
57
|
+
color: "var(--fg-default)",
|
|
58
|
+
borderColor: "transparent",
|
|
59
|
+
fontWeight: 400,
|
|
60
|
+
justifyContent: "flex-start",
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const SIZE_STYLES: Record<ButtonSize, React.CSSProperties> = {
|
|
65
|
+
sm: { height: 32, padding: "0 10px", fontSize: "var(--text-meta, 0.8125rem)", borderRadius: "var(--radius-sm, 8px)" },
|
|
66
|
+
md: { height: 40, padding: "0 14px", fontSize: "var(--text-body-sm, 0.875rem)", borderRadius: "var(--radius-control, 10px)" },
|
|
67
|
+
lg: { height: 44, padding: "0 18px", fontSize: "var(--text-body, 0.9375rem)", borderRadius: "var(--radius-control, 10px)" },
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function Button(
|
|
71
|
+
{
|
|
72
|
+
variant = "white",
|
|
73
|
+
size = "md",
|
|
74
|
+
pill = false,
|
|
75
|
+
iconOnly = false,
|
|
76
|
+
loading = false,
|
|
77
|
+
disabled = false,
|
|
78
|
+
icon,
|
|
79
|
+
type = "button",
|
|
80
|
+
onClick,
|
|
81
|
+
className,
|
|
82
|
+
style,
|
|
83
|
+
children,
|
|
84
|
+
...rest
|
|
85
|
+
},
|
|
86
|
+
ref,
|
|
87
|
+
) {
|
|
88
|
+
const [pending, setPending] = useState(false);
|
|
89
|
+
const isBusy = loading || pending;
|
|
90
|
+
|
|
91
|
+
const handleClick = useCallback(
|
|
92
|
+
(e: React.MouseEvent<HTMLButtonElement>) => {
|
|
93
|
+
if (disabled || isBusy || !onClick) return;
|
|
94
|
+
const result = onClick(e);
|
|
95
|
+
if (result && typeof (result as Promise<unknown>).then === "function") {
|
|
96
|
+
setPending(true);
|
|
97
|
+
(result as Promise<unknown>).finally(() => setPending(false));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
[disabled, isBusy, onClick],
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
const sizeStyle = SIZE_STYLES[size];
|
|
104
|
+
const iconOnlyStyle: React.CSSProperties = iconOnly
|
|
105
|
+
? {
|
|
106
|
+
width: Math.max(32, Number(sizeStyle.height)),
|
|
107
|
+
padding: 0,
|
|
108
|
+
}
|
|
109
|
+
: {};
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<button
|
|
113
|
+
ref={ref}
|
|
114
|
+
type={type}
|
|
115
|
+
disabled={disabled}
|
|
116
|
+
aria-busy={isBusy || undefined}
|
|
117
|
+
aria-disabled={disabled || isBusy || undefined}
|
|
118
|
+
onClick={handleClick}
|
|
119
|
+
className={clsx("millar-focus", className)}
|
|
120
|
+
style={{
|
|
121
|
+
display: "inline-flex",
|
|
122
|
+
alignItems: "center",
|
|
123
|
+
justifyContent: "center",
|
|
124
|
+
gap: 8,
|
|
125
|
+
fontFamily: "var(--font-sans)",
|
|
126
|
+
lineHeight: 1.4,
|
|
127
|
+
letterSpacing: 0,
|
|
128
|
+
borderWidth: 1,
|
|
129
|
+
borderStyle: "solid",
|
|
130
|
+
boxShadow: "none",
|
|
131
|
+
whiteSpace: "nowrap",
|
|
132
|
+
cursor: disabled ? "not-allowed" : isBusy ? "wait" : "pointer",
|
|
133
|
+
opacity: disabled ? 0.48 : 1,
|
|
134
|
+
transition:
|
|
135
|
+
"background-color var(--motion-productive-fast, 140ms) var(--ease-productive-standard, cubic-bezier(0.2, 0, 0, 1)), border-color var(--motion-productive-fast, 140ms) var(--ease-productive-standard, cubic-bezier(0.2, 0, 0, 1)), color var(--motion-productive-fast, 140ms) var(--ease-productive-standard, cubic-bezier(0.2, 0, 0, 1))",
|
|
136
|
+
...VARIANT_STYLES[variant],
|
|
137
|
+
...sizeStyle,
|
|
138
|
+
...iconOnlyStyle,
|
|
139
|
+
...(pill ? { borderRadius: "var(--radius-pill, 9999px)" } : {}),
|
|
140
|
+
...style,
|
|
141
|
+
}}
|
|
142
|
+
{...rest}
|
|
143
|
+
>
|
|
144
|
+
{isBusy ? (
|
|
145
|
+
<span
|
|
146
|
+
aria-hidden="true"
|
|
147
|
+
style={{
|
|
148
|
+
width: 14,
|
|
149
|
+
height: 14,
|
|
150
|
+
borderRadius: 9999,
|
|
151
|
+
border: "2px solid currentColor",
|
|
152
|
+
borderTopColor: "transparent",
|
|
153
|
+
display: "inline-block",
|
|
154
|
+
}}
|
|
155
|
+
/>
|
|
156
|
+
) : (
|
|
157
|
+
icon
|
|
158
|
+
)}
|
|
159
|
+
{children}
|
|
160
|
+
</button>
|
|
161
|
+
);
|
|
162
|
+
});
|