basalt-ui 2.14.0 → 2.15.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/CHANGELOG.md +40 -0
- package/MIGRATING.md +19 -13
- package/agent/agents/basalt-design-reviewer.md +83 -0
- package/agent/rules/basalt-batteries.md +1 -2
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-controls.md +3 -3
- package/agent/rules/basalt-mantine.md +1 -2
- package/agent/rules/basalt-state.md +1 -2
- package/agent/rules/basalt-tokens.md +1 -3
- package/agent/skills/basalt-design/SKILL.md +26 -8
- package/agent/templates/AGENTS-block.md.tpl +7 -0
- package/configs/oxlint-plugin.js +39 -2
- package/configs/oxlint-plugin.test.ts +48 -0
- package/dist/charts/legend.d.ts +4 -4
- package/dist/cli/board-freshness.d.ts +25 -0
- package/dist/cli/board-freshness.d.ts.map +1 -0
- package/dist/cli/board-freshness.js +88 -0
- package/dist/cli/doctor.d.ts +2 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +3 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +9 -3
- package/dist/cli/index.d.ts +15 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +57 -7
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +6 -1
- package/dist/cli/shot/board.d.ts +5 -0
- package/dist/cli/shot/board.d.ts.map +1 -0
- package/dist/cli/shot/board.js +96 -0
- package/dist/cli/shot/capture.d.ts +59 -0
- package/dist/cli/shot/capture.d.ts.map +1 -0
- package/dist/cli/shot/capture.js +473 -0
- package/dist/cli/shot/index.d.ts +45 -0
- package/dist/cli/shot/index.d.ts.map +1 -0
- package/dist/cli/shot/index.js +289 -0
- package/dist/cli/shot/measure.d.ts +28 -0
- package/dist/cli/shot/measure.d.ts.map +1 -0
- package/dist/cli/shot/measure.js +176 -0
- package/dist/cli/shot/playwright.d.ts +101 -0
- package/dist/cli/shot/playwright.d.ts.map +1 -0
- package/dist/cli/shot/playwright.js +60 -0
- package/dist/cli/shot/serve.d.ts +6 -0
- package/dist/cli/shot/serve.d.ts.map +1 -0
- package/dist/cli/shot/serve.js +33 -0
- package/dist/cli/shot/types.d.ts +97 -0
- package/dist/cli/shot/types.d.ts.map +1 -0
- package/dist/cli/shot/types.js +17 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -1
- package/dist/surfaces.d.ts +2 -0
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/src/charts/legend.tsx +4 -4
- package/src/cli/board-freshness.ts +132 -0
- package/src/cli/doctor.ts +10 -1
- package/src/cli/help.ts +14 -2
- package/src/cli/index.ts +80 -10
- package/src/cli/init.ts +8 -1
- package/src/cli/shot/board.ts +154 -0
- package/src/cli/shot/capture.ts +650 -0
- package/src/cli/shot/index.ts +362 -0
- package/src/cli/shot/measure.ts +225 -0
- package/src/cli/shot/playwright.ts +152 -0
- package/src/cli/shot/serve.ts +35 -0
- package/src/cli/shot/types.ts +91 -0
- package/src/cli/sync.ts +2 -1
- package/src/surfaces.ts +5 -0
package/src/cli/init.ts
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
pruneRetiredManagedFiles,
|
|
25
25
|
readManifest,
|
|
26
26
|
reconcileRoots,
|
|
27
|
+
ruleRootsFor,
|
|
27
28
|
renderContext,
|
|
28
29
|
reportPrune,
|
|
29
30
|
resolvePlacement,
|
|
@@ -99,7 +100,13 @@ export function init(cwd: string = process.cwd(), scaffoldFlags: ScaffoldFlags =
|
|
|
99
100
|
const rootsState = reconcileRoots(cwd, { write: true })
|
|
100
101
|
|
|
101
102
|
// Built AFTER the roots patch — every roots-derived template variable reads the key just written.
|
|
102
|
-
|
|
103
|
+
// Nothing inferable yet: init's own seeds create the app's `src/`, which a later sync will infer.
|
|
104
|
+
const appSrc = resolvePlacement(cwd).appRel
|
|
105
|
+
const ctx = renderContext(
|
|
106
|
+
cwd,
|
|
107
|
+
ruleRootsFor(rootsState) ??
|
|
108
|
+
(rootsState.kind === 'undetectable' ? [`${appSrc ? `${appSrc}/` : ''}src`] : undefined),
|
|
109
|
+
)
|
|
103
110
|
|
|
104
111
|
// `basalt-tokens.md` tells the consumer to wire `oxlint . && basalt-ui check-theme` into their
|
|
105
112
|
// lint, and init's own closing message says to run check-theme next — but nothing ever added a
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
// theme-allow-file raw-hex — board.html is a standalone artefact: no basalt tokens exist in it
|
|
2
|
+
// theme-allow-file inline-spacing — board.html is a standalone artefact: no Mantine spacing props
|
|
3
|
+
/** `board.html`: one self-contained page (inline CSS, relative image paths) over a metrics.json. */
|
|
4
|
+
import { PAGE_ANCHOR, SCHEMES, VIEWPORTS } from './types'
|
|
5
|
+
import type { AnchorMetrics, Scale, ShotMetrics, ShotRecord, ShotState, Sides } from './types'
|
|
6
|
+
|
|
7
|
+
const esc = (s: string): string => s.replace(/[&<>"']/g, (c) => `&#${c.charCodeAt(0)};`)
|
|
8
|
+
|
|
9
|
+
const CSS = `
|
|
10
|
+
:root{color-scheme:light dark;--bg:#fff;--fg:#18181b;--mut:#71717a;--line:#d4d4d8;--bad:#b91c1c}
|
|
11
|
+
@media(prefers-color-scheme:dark){:root{--bg:#09090b;--fg:#fafafa;--mut:#a1a1aa;--line:#3f3f46;--bad:#f87171}}
|
|
12
|
+
body{margin:0;padding:24px;background:var(--bg);color:var(--fg);font:13px/1.45 system-ui,sans-serif}
|
|
13
|
+
h1,h2,h3,h4{margin:0 0 8px}h2{margin-top:40px;border-bottom:1px solid var(--line);padding-bottom:4px}
|
|
14
|
+
section{margin:24px 0}.row{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:24px;align-items:start}
|
|
15
|
+
.grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:16px}
|
|
16
|
+
figure{margin:0;border:1px solid var(--line);padding:6px;min-width:0}
|
|
17
|
+
figcaption,.mut{color:var(--mut);font-size:11px}img{max-width:100%;height:auto;display:block}
|
|
18
|
+
.empty{display:flex;align-items:center;justify-content:center;min-height:60px;color:var(--mut);border:1px dashed var(--line);text-align:center;padding:6px}
|
|
19
|
+
.empty.error{color:var(--bad);border-color:var(--bad)}
|
|
20
|
+
table{border-collapse:collapse;width:100%;font-size:12px}th,td{border:1px solid var(--line);padding:3px 6px;text-align:left;vertical-align:top}
|
|
21
|
+
.bad{color:var(--bad)}aside{position:sticky;top:12px}
|
|
22
|
+
`
|
|
23
|
+
|
|
24
|
+
const sides = (s: Sides): string => `${s.top} ${s.right} ${s.bottom} ${s.left}`
|
|
25
|
+
|
|
26
|
+
const cell = (shot: ShotRecord | undefined, label: string): string => {
|
|
27
|
+
const caption = `<figcaption>${esc(label)}</figcaption>`
|
|
28
|
+
if (!shot) return `<figure><div class="empty">not captured</div>${caption}</figure>`
|
|
29
|
+
if (shot.status === 'ok' && shot.file) {
|
|
30
|
+
const note = shot.note ? ` · ${esc(shot.note)}` : ''
|
|
31
|
+
return `<figure><img src="${esc(shot.file)}" loading="lazy" alt="${esc(`${shot.name} ${label}`)}"><figcaption>${esc(label)}${note}</figcaption></figure>`
|
|
32
|
+
}
|
|
33
|
+
const note = shot.note ? `: ${esc(shot.note)}` : ''
|
|
34
|
+
return `<figure><div class="empty ${shot.status}">${shot.status}${note}</div>${caption}</figure>`
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const metricsRow = (a: AnchorMetrics): string => {
|
|
38
|
+
const fails = a.contrast.failures.length
|
|
39
|
+
return (
|
|
40
|
+
`<tr><td>${a.scheme}/${a.viewport}</td><td>${a.box.width}×${a.box.height}</td>` +
|
|
41
|
+
`<td>${sides(a.padding)}</td><td>${a.gap.row}/${a.gap.column}</td><td>${a.radius}</td>` +
|
|
42
|
+
`<td>${a.borderWidth}</td><td>${a.fontSizes.join(', ')}</td><td>${a.emptyRatio}</td>` +
|
|
43
|
+
`<td class="${fails ? 'bad' : ''}">${a.contrast.min ?? '–'} (${fails} fail)</td></tr>`
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const metricsTable = (rows: AnchorMetrics[]): string => {
|
|
48
|
+
if (rows.length === 0) return '<p class="mut">no metrics (the anchor never rendered)</p>'
|
|
49
|
+
const failures = rows.flatMap((a) =>
|
|
50
|
+
a.contrast.failures.map(
|
|
51
|
+
(f) =>
|
|
52
|
+
`<li>${a.scheme}/${a.viewport} “${esc(f.text)}” ${f.ratio} (${esc(f.fg)} on ${esc(f.bg)}, ${f.fontSize}px)</li>`,
|
|
53
|
+
),
|
|
54
|
+
)
|
|
55
|
+
const assumed = rows
|
|
56
|
+
.filter((a) => a.contrast.backdrop === 'assumed-white')
|
|
57
|
+
.map((a) => `${a.scheme}/${a.viewport}`)
|
|
58
|
+
const nested = rows
|
|
59
|
+
.filter((a) => a.nested.length > 0)
|
|
60
|
+
.map(
|
|
61
|
+
(a) =>
|
|
62
|
+
`<li>${a.scheme}/${a.viewport}<ul>${a.nested.map((n) => `<li>${esc(n.path)} r${n.radius} p ${sides(n.padding)}</li>`).join('')}</ul></li>`,
|
|
63
|
+
)
|
|
64
|
+
return (
|
|
65
|
+
`<table><tr><th></th><th>box</th><th>padding</th><th>gap r/c</th><th>radius</th><th>border</th>` +
|
|
66
|
+
`<th>font px</th><th>empty</th><th>contrast min</th></tr>${rows.map(metricsRow).join('')}</table>` +
|
|
67
|
+
(assumed.length
|
|
68
|
+
? `<p class="bad">backdrop assumed white (no opaque ancestor background): ${assumed.join(', ')}</p>`
|
|
69
|
+
: '') +
|
|
70
|
+
(failures.length ? `<h4>Contrast failures</h4><ul class="bad">${failures.join('')}</ul>` : '') +
|
|
71
|
+
(nested.length ? `<h4>Nested surfaces</h4><ul>${nested.join('')}</ul>` : '')
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const grid = (shots: ShotRecord[], route: string, name: string, state: ShotState): string => {
|
|
76
|
+
const cells = VIEWPORTS.flatMap((viewport) =>
|
|
77
|
+
SCHEMES.map((scheme) =>
|
|
78
|
+
cell(
|
|
79
|
+
shots.find(
|
|
80
|
+
(s) =>
|
|
81
|
+
s.route === route &&
|
|
82
|
+
s.name === name &&
|
|
83
|
+
s.state === state &&
|
|
84
|
+
s.scheme === scheme &&
|
|
85
|
+
s.viewport === viewport,
|
|
86
|
+
),
|
|
87
|
+
`${scheme} · ${viewport}`,
|
|
88
|
+
),
|
|
89
|
+
),
|
|
90
|
+
)
|
|
91
|
+
return `<h4>${state}</h4><div class="grid">${cells.join('')}</div>`
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const anchorSection = (m: ShotMetrics, route: string, name: string): string =>
|
|
95
|
+
`<section><h3>${esc(name)}</h3><div class="row"><div>${m.states
|
|
96
|
+
.map((state) => grid(m.shots, route, name, state))
|
|
97
|
+
.join('')}</div><aside>${metricsTable(
|
|
98
|
+
m.anchors.filter((a) => a.route === route && a.name === name),
|
|
99
|
+
)}</aside></div></section>`
|
|
100
|
+
|
|
101
|
+
const stepList = (steps: Record<string, number>): string =>
|
|
102
|
+
Object.entries(steps)
|
|
103
|
+
.map(([k, v]) => `${esc(k)} ${v}`)
|
|
104
|
+
.join(' · ') || '–'
|
|
105
|
+
|
|
106
|
+
/** The resolved theme steps, shown once per distinct scale (usually one for every scheme × viewport). */
|
|
107
|
+
const scaleBlock = (scale: Scale[]): string => {
|
|
108
|
+
if (scale.length === 0) return ''
|
|
109
|
+
const groups = new Map<string, { scale: Scale; where: string[] }>()
|
|
110
|
+
for (const s of scale) {
|
|
111
|
+
const key = JSON.stringify([s.spacing, s.radius, s.fontSizes])
|
|
112
|
+
const group = groups.get(key) ?? { scale: s, where: [] }
|
|
113
|
+
group.where.push(`${s.scheme}/${s.viewport}`)
|
|
114
|
+
groups.set(key, group)
|
|
115
|
+
}
|
|
116
|
+
const rows = [...groups.values()].map(
|
|
117
|
+
({ scale: s, where }) =>
|
|
118
|
+
`<tr><td>${where.join(', ')}</td><td>${stepList(s.spacing)}</td><td>${stepList(s.radius)}</td><td>${stepList(s.fontSizes)}</td></tr>`,
|
|
119
|
+
)
|
|
120
|
+
return `<details open><summary>Theme scale (px)</summary><table><tr><th></th><th>spacing</th><th>radius</th><th>font size</th></tr>${rows.join('')}</table></details>`
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** An anchor's contact sheet: every state × scheme × viewport, labelled, on one standalone page. */
|
|
124
|
+
export function buildSheet(
|
|
125
|
+
route: string,
|
|
126
|
+
name: string,
|
|
127
|
+
states: readonly ShotState[],
|
|
128
|
+
shots: ShotRecord[],
|
|
129
|
+
): string {
|
|
130
|
+
const body = states.map((state) => grid(shots, route, name, state)).join('')
|
|
131
|
+
// Lazy images never load in a screenshot taken straight after `load`.
|
|
132
|
+
return (
|
|
133
|
+
`<!doctype html><html lang="en"><head><meta charset="utf-8"><style>${CSS}</style></head><body>` +
|
|
134
|
+
`<h3>${esc(name)} <span class="mut">${esc(route)}</span></h3>${body}</body></html>`
|
|
135
|
+
).replaceAll(' loading="lazy"', '')
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function buildBoard(m: ShotMetrics): string {
|
|
139
|
+
const sections = m.routes.map((route) => {
|
|
140
|
+
const names = [
|
|
141
|
+
...new Set(
|
|
142
|
+
m.shots.filter((s) => s.route === route && s.name !== PAGE_ANCHOR).map((s) => s.name),
|
|
143
|
+
),
|
|
144
|
+
]
|
|
145
|
+
const anchors = names.length
|
|
146
|
+
? names.map((name) => anchorSection(m, route, name)).join('')
|
|
147
|
+
: '<p class="mut">no data-shot anchors on this route</p>'
|
|
148
|
+
return `<h2>${esc(route)}</h2><h3>full page</h3>${grid(m.shots, route, PAGE_ANCHOR, 'rest')}${anchors}`
|
|
149
|
+
})
|
|
150
|
+
return (
|
|
151
|
+
`<!doctype html><html lang="en"><head><meta charset="utf-8"><title>basalt-ui shot</title><style>${CSS}</style></head><body>` +
|
|
152
|
+
`<h1>basalt-ui shot</h1><p class="mut">${esc(m.base)} · ${esc(m.generatedAt)} · states: ${m.states.join(', ')}</p>${m.scaleError ? `<p class="bad">scale unavailable: ${esc(m.scaleError)}</p>` : ''}${scaleBlock(m.scale)}${sections.join('')}</body></html>\n`
|
|
153
|
+
)
|
|
154
|
+
}
|