basalt-ui 2.14.0 → 2.16.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 +69 -0
- package/MIGRATING.md +81 -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 +2 -3
- 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/card-inset.test.ts +57 -0
- package/configs/oxlint-basalt.json +1 -1
- package/configs/oxlint-plugin.js +81 -20
- package/configs/oxlint-plugin.test.ts +85 -6
- package/dist/agent/chat/thread-message.js +1 -1
- package/dist/agent/chat/thread-outcome-card.js +1 -1
- package/dist/charts/ChartCard.js +1 -1
- package/dist/charts/chart-card.module.css +2 -2
- 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 +47 -0
- package/dist/cli/shot/measure.d.ts.map +1 -0
- package/dist/cli/shot/measure.js +191 -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 +98 -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/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +5 -2
- package/dist/dashboard/stat-card.js +12 -12
- package/dist/dashboard/stat-card.module.css +4 -4
- package/dist/dashboard/widget-header.module.css +3 -3
- package/dist/guard/guard-hook.d.ts.map +1 -1
- package/dist/guard/index.d.ts +4 -2
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +18 -4
- package/dist/guard/vx-names.d.ts.map +1 -1
- package/dist/guard/vx-names.js +1 -0
- package/dist/shell/app-mobile-nav.module.css +2 -2
- package/dist/shell/app-sidebar-account.js +1 -1
- package/dist/shell/app-sidebar.js +2 -2
- package/dist/shell/app-sidebar.module.css +8 -8
- package/dist/shell/index.js +5 -1
- package/dist/shell/page-bar.js +1 -1
- package/dist/surfaces.d.ts +2 -0
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +3 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +31 -21
- package/dist/tokens/core.d.ts +10 -4
- package/dist/tokens/core.d.ts.map +1 -1
- package/dist/tokens/core.js +16 -10
- package/dist/tokens/ctl-vars.d.ts +15 -0
- package/dist/tokens/ctl-vars.d.ts.map +1 -0
- package/dist/tokens/ctl-vars.js +22 -0
- package/dist/tokens/palette.d.ts +37 -29
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +32 -21
- package/dist/tokens/space-scale.d.ts +14 -0
- package/dist/tokens/space-scale.d.ts.map +1 -0
- package/dist/tokens/space-scale.js +10 -0
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/src/agent/chat/thread-message.tsx +1 -1
- package/src/agent/chat/thread-outcome-card.tsx +2 -2
- package/src/charts/ChartCard.tsx +1 -1
- package/src/charts/chart-card.module.css +2 -2
- 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 +252 -0
- package/src/cli/shot/playwright.ts +152 -0
- package/src/cli/shot/serve.ts +35 -0
- package/src/cli/shot/types.ts +92 -0
- package/src/cli/sync.ts +2 -1
- package/src/dashboard/settings-section.tsx +5 -2
- package/src/dashboard/stat-card.module.css +4 -4
- package/src/dashboard/stat-card.tsx +13 -13
- package/src/dashboard/widget-header.module.css +3 -3
- package/src/guard/guard-hook.ts +3 -1
- package/src/guard/index.ts +27 -13
- package/src/guard/vx-names.ts +1 -0
- package/src/shell/app-mobile-nav.module.css +2 -2
- package/src/shell/app-sidebar-account.tsx +1 -1
- package/src/shell/app-sidebar.module.css +8 -8
- package/src/shell/app-sidebar.tsx +2 -2
- package/src/shell/index.tsx +10 -4
- package/src/shell/page-bar.tsx +1 -1
- package/src/surfaces.ts +5 -0
- package/src/table/data-table.tsx +10 -4
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +57 -45
- package/src/theme/ctl-theme.tsx +1 -1
- package/src/theme/index.ts +43 -23
- package/src/tokens/core.ts +16 -8
- package/src/tokens/ctl-vars.ts +32 -0
- package/src/tokens/palette.ts +40 -29
- package/src/tokens/space-scale.ts +13 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Playwright, resolved from the CONSUMER (it is not a basalt dependency) and typed through the
|
|
3
|
+
* minimal structural surface `shot` uses — the package never imports Playwright at build time.
|
|
4
|
+
* The real `playwright-core` types satisfy this surface, so callers keep their own types.
|
|
5
|
+
*/
|
|
6
|
+
import { createRequire } from 'node:module'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
|
|
9
|
+
import type { Scheme } from './types'
|
|
10
|
+
|
|
11
|
+
export const INSTALL_LINE =
|
|
12
|
+
'basalt-ui shot needs Playwright: bun add -d playwright && bunx playwright install chromium'
|
|
13
|
+
|
|
14
|
+
const KILL_TIMEOUT_MS = 10_000
|
|
15
|
+
|
|
16
|
+
export type Box = { x: number; y: number; width: number; height: number }
|
|
17
|
+
|
|
18
|
+
export type ShotOptions = {
|
|
19
|
+
path: string
|
|
20
|
+
animations: 'disabled'
|
|
21
|
+
caret: 'hide'
|
|
22
|
+
fullPage?: boolean
|
|
23
|
+
clip?: Box
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type PwLocator = {
|
|
27
|
+
first(): PwLocator
|
|
28
|
+
count(): Promise<number>
|
|
29
|
+
hover(options?: { timeout?: number }): Promise<void>
|
|
30
|
+
isVisible(): Promise<boolean>
|
|
31
|
+
boundingBox(): Promise<Box | null>
|
|
32
|
+
scrollIntoViewIfNeeded(): Promise<void>
|
|
33
|
+
waitFor(options: { state: 'visible'; timeout: number }): Promise<void>
|
|
34
|
+
screenshot(options: ShotOptions): Promise<unknown>
|
|
35
|
+
evaluate<R>(fn: (el: Element) => R): Promise<R>
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export type PwPage = {
|
|
39
|
+
goto(url: string, options: { waitUntil: 'load' | 'networkidle' }): Promise<unknown>
|
|
40
|
+
setDefaultTimeout(ms: number): void
|
|
41
|
+
locator(selector: string): PwLocator
|
|
42
|
+
evaluate<R>(expression: string): Promise<R>
|
|
43
|
+
evaluate<R, A>(fn: (arg: A) => R, arg: A): Promise<R>
|
|
44
|
+
setContent(html: string, options: { waitUntil: 'load' }): Promise<void>
|
|
45
|
+
keyboard: { press(key: string): Promise<void> }
|
|
46
|
+
mouse: { move(x: number, y: number): Promise<void> }
|
|
47
|
+
screenshot(options: ShotOptions): Promise<unknown>
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type PwContext = {
|
|
51
|
+
newPage(): Promise<PwPage>
|
|
52
|
+
addInitScript(script: string): Promise<unknown>
|
|
53
|
+
close(): Promise<void>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type ContextOptions = {
|
|
57
|
+
viewport: { width: number; height: number }
|
|
58
|
+
deviceScaleFactor: number
|
|
59
|
+
isMobile: boolean
|
|
60
|
+
hasTouch: boolean
|
|
61
|
+
colorScheme: Scheme
|
|
62
|
+
reducedMotion: 'reduce'
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export type PwBrowser<C extends PwContext = PwContext> = {
|
|
66
|
+
newContext(options: ContextOptions): Promise<C>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type PwServer = { wsEndpoint(): string; kill(): Promise<void> }
|
|
70
|
+
export type Playwright<B extends PwBrowser = PwBrowser> = {
|
|
71
|
+
chromium: {
|
|
72
|
+
launchServer(options: { channel?: string; chromiumSandbox: boolean }): Promise<PwServer>
|
|
73
|
+
connect(wsEndpoint: string): Promise<B>
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Thrown for failures that print one line and exit 1 (no stack). */
|
|
78
|
+
export class ShotError extends Error {}
|
|
79
|
+
|
|
80
|
+
export type PlaywrightResolver = (cwd: string) => Playwright | null
|
|
81
|
+
|
|
82
|
+
export const isPlaywright = (mod: unknown): mod is Playwright => {
|
|
83
|
+
const chromium = (mod as { chromium?: Record<string, unknown> } | null)?.chromium
|
|
84
|
+
return (
|
|
85
|
+
typeof chromium?.['launchServer'] === 'function' && typeof chromium['connect'] === 'function'
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export const resolvePlaywright: PlaywrightResolver = (cwd) => {
|
|
90
|
+
const require = createRequire(join(cwd, 'package.json'))
|
|
91
|
+
for (const name of ['playwright', 'playwright-core']) {
|
|
92
|
+
try {
|
|
93
|
+
const mod: unknown = require(name)
|
|
94
|
+
if (isPlaywright(mod)) return mod
|
|
95
|
+
} catch {
|
|
96
|
+
// not installed under this name: try the next
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return null
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const firstLine = (error: unknown): string =>
|
|
103
|
+
(error instanceof Error ? error.message : String(error)).split('\n')[0] ?? ''
|
|
104
|
+
|
|
105
|
+
/** `kill()` bounded by a hang guard: a graceful stop can wedge under Bun. */
|
|
106
|
+
function killBounded(server: PwServer): Promise<unknown> {
|
|
107
|
+
const guard = new Promise((resolve) => setTimeout(resolve, KILL_TIMEOUT_MS).unref())
|
|
108
|
+
return Promise.race([server.kill().catch(() => undefined), guard])
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export type LaunchOptions = {
|
|
112
|
+
/** Tried in order; `undefined` is the bundled chromium. Default: bundled, then `chrome`. */
|
|
113
|
+
channels?: readonly (string | undefined)[]
|
|
114
|
+
/** Receives this run's kill, so the caller's signal handler can stop it. */
|
|
115
|
+
stops?: (() => unknown)[]
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* One Chrome for `fn`, killed afterwards. `launchServer` + `connect` + `kill()` — a graceful
|
|
120
|
+
* `close()` hangs under Bun. Every failed launch keeps its first error line for the final message.
|
|
121
|
+
*/
|
|
122
|
+
export async function withBrowser<B extends PwBrowser, T>(
|
|
123
|
+
pw: Playwright<B>,
|
|
124
|
+
fn: (browser: B, channel: string) => Promise<T>,
|
|
125
|
+
{ channels = [undefined, 'chrome'], stops }: LaunchOptions = {},
|
|
126
|
+
): Promise<T> {
|
|
127
|
+
const chromiumSandbox = !process.env['CI']
|
|
128
|
+
const failures: string[] = []
|
|
129
|
+
for (const channel of channels) {
|
|
130
|
+
const label = channel ?? 'bundled chromium'
|
|
131
|
+
let server: PwServer | undefined
|
|
132
|
+
let browser: B
|
|
133
|
+
try {
|
|
134
|
+
server = await pw.chromium.launchServer(
|
|
135
|
+
channel ? { channel, chromiumSandbox } : { chromiumSandbox },
|
|
136
|
+
)
|
|
137
|
+
browser = await pw.chromium.connect(server.wsEndpoint())
|
|
138
|
+
} catch (error) {
|
|
139
|
+
failures.push(` ${label}: ${firstLine(error)}`)
|
|
140
|
+
if (server) await killBounded(server)
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
143
|
+
const live = server
|
|
144
|
+
stops?.push(() => killBounded(live))
|
|
145
|
+
try {
|
|
146
|
+
return await fn(browser, channel ?? 'chromium')
|
|
147
|
+
} finally {
|
|
148
|
+
await killBounded(live)
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
throw new ShotError([INSTALL_LINE, ...failures].join('\n'))
|
|
152
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync, statSync } from 'node:fs'
|
|
2
|
+
import { join, normalize, resolve, sep } from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { ShotError } from './playwright'
|
|
5
|
+
|
|
6
|
+
/** Static server for a built SPA dir: real files as-is, extensionless misses fall back to index.html. */
|
|
7
|
+
export function serveDist(distDir: string): { origin: string; stop: () => void } {
|
|
8
|
+
const root = resolve(distDir)
|
|
9
|
+
if (!existsSync(root) || !statSync(root).isDirectory()) {
|
|
10
|
+
throw new ShotError(`--dist ${distDir} is not a directory`)
|
|
11
|
+
}
|
|
12
|
+
const fileFor = (pathname: string): string | null => {
|
|
13
|
+
const file = normalize(join(root, decodeURIComponent(pathname)))
|
|
14
|
+
if (file !== root && !file.startsWith(root + sep)) return null
|
|
15
|
+
if (existsSync(file) && statSync(file).isFile()) return file
|
|
16
|
+
if (/\.[a-z0-9]+$/i.test(pathname)) return null
|
|
17
|
+
const index = join(root, 'index.html')
|
|
18
|
+
return existsSync(index) ? index : null
|
|
19
|
+
}
|
|
20
|
+
const server = Bun.serve({
|
|
21
|
+
port: 0,
|
|
22
|
+
hostname: '127.0.0.1',
|
|
23
|
+
fetch(req) {
|
|
24
|
+
try {
|
|
25
|
+
const file = fileFor(new URL(req.url).pathname)
|
|
26
|
+
return file
|
|
27
|
+
? new Response(Bun.file(file), { headers: { 'cache-control': 'no-store' } })
|
|
28
|
+
: new Response('not found', { status: 404 })
|
|
29
|
+
} catch {
|
|
30
|
+
return new Response('bad request', { status: 400 })
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
return { origin: `http://127.0.0.1:${server.port}`, stop: () => void server.stop(true) }
|
|
35
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export const SCHEMES = ['light', 'dark'] as const
|
|
2
|
+
export const VIEWPORTS = ['desktop', 'mobile'] as const
|
|
3
|
+
export const STATES = ['rest', 'hover', 'focus', 'tooltip', 'empty', 'loading', 'error'] as const
|
|
4
|
+
/** The states a page opts into with `data-shot-states`; reached through the `shot-state` URL param. */
|
|
5
|
+
export const URL_STATES = ['empty', 'loading', 'error'] as const
|
|
6
|
+
|
|
7
|
+
/** The `name` of a route's full-page shot: not a valid `data-shot` value. */
|
|
8
|
+
export const PAGE_ANCHOR = '_page'
|
|
9
|
+
|
|
10
|
+
export type Scheme = (typeof SCHEMES)[number]
|
|
11
|
+
export type Viewport = (typeof VIEWPORTS)[number]
|
|
12
|
+
export type ShotState = (typeof STATES)[number]
|
|
13
|
+
|
|
14
|
+
export const VIEWPORT_SPECS: Record<Viewport, { width: number; height: number; mobile: boolean }> =
|
|
15
|
+
{
|
|
16
|
+
desktop: { width: 1440, height: 900, mobile: false },
|
|
17
|
+
mobile: { width: 390, height: 844, mobile: true },
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type Sides = { top: number; right: number; bottom: number; left: number }
|
|
21
|
+
|
|
22
|
+
export type ContrastFailure = {
|
|
23
|
+
text: string
|
|
24
|
+
ratio: number
|
|
25
|
+
fg: string
|
|
26
|
+
bg: string
|
|
27
|
+
fontSize: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** What the in-page measurer returns for one anchor. */
|
|
31
|
+
export type Measurement = {
|
|
32
|
+
box: { width: number; height: number }
|
|
33
|
+
padding: Sides
|
|
34
|
+
gap: { row: number; column: number }
|
|
35
|
+
/** px, or `'full'` for a radius that rounds the box completely (`50%`, `9999px`). */
|
|
36
|
+
radius: number | 'full'
|
|
37
|
+
borderWidth: number
|
|
38
|
+
fontSizes: number[]
|
|
39
|
+
nested: { path: string; radius: number | 'full'; padding: Sides }[]
|
|
40
|
+
emptyRatio: number
|
|
41
|
+
/** `min` is null when the anchor holds no text. */
|
|
42
|
+
contrast: {
|
|
43
|
+
min: number | null
|
|
44
|
+
failures: ContrastFailure[]
|
|
45
|
+
/** Set when some text sat on no opaque ancestor background and white was assumed. */
|
|
46
|
+
backdrop?: 'assumed-white'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type AnchorMetrics = Measurement & {
|
|
51
|
+
route: string
|
|
52
|
+
name: string
|
|
53
|
+
scheme: Scheme
|
|
54
|
+
viewport: Viewport
|
|
55
|
+
/** The anchor's contact sheet (`png/…__sheet.png`): every state × scheme × viewport on one image. Absent when it could not be written. */
|
|
56
|
+
sheet?: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type ShotRecord = {
|
|
60
|
+
route: string
|
|
61
|
+
name: string
|
|
62
|
+
scheme: Scheme
|
|
63
|
+
viewport: Viewport
|
|
64
|
+
state: ShotState
|
|
65
|
+
file: string | null
|
|
66
|
+
status: 'ok' | 'not-declared' | 'skipped' | 'error'
|
|
67
|
+
note?: string
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The theme's resolved steps (px) for one scheme × viewport; a missing custom property is omitted. */
|
|
71
|
+
export type Scale = {
|
|
72
|
+
scheme: Scheme
|
|
73
|
+
viewport: Viewport
|
|
74
|
+
spacing: Record<string, number>
|
|
75
|
+
radius: Record<string, number>
|
|
76
|
+
fontSizes: Record<string, number>
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type ShotMetrics = {
|
|
80
|
+
version: 1
|
|
81
|
+
generatedAt: string
|
|
82
|
+
base: string
|
|
83
|
+
routes: string[]
|
|
84
|
+
viewports: Viewport[]
|
|
85
|
+
schemes: Scheme[]
|
|
86
|
+
states: ShotState[]
|
|
87
|
+
scale: Scale[]
|
|
88
|
+
/** Why `scale` is empty or partial; absent when it was read. */
|
|
89
|
+
scaleError?: string
|
|
90
|
+
anchors: AnchorMetrics[]
|
|
91
|
+
shots: ShotRecord[]
|
|
92
|
+
}
|
package/src/cli/sync.ts
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
readManifest,
|
|
28
28
|
readSource,
|
|
29
29
|
reconcileRoots,
|
|
30
|
+
ruleRootsFor,
|
|
30
31
|
relativePosix,
|
|
31
32
|
renderContext,
|
|
32
33
|
reportPrune,
|
|
@@ -143,7 +144,7 @@ export function sync(opts: SyncOptions = {}, invocationCwd: string = process.cwd
|
|
|
143
144
|
|
|
144
145
|
// Before renderContext, which reads `basalt.roots` for the roots-derived template variables.
|
|
145
146
|
const rootsState = reconcileRoots(cwd, { write: opts.check !== true })
|
|
146
|
-
const ctx = renderContext(cwd)
|
|
147
|
+
const ctx = renderContext(cwd, ruleRootsFor(rootsState))
|
|
147
148
|
const manifest = readManifest(cwd)
|
|
148
149
|
const placement = resolvePlacement(cwd)
|
|
149
150
|
const { skip: seedSkip, skipped } = routerSeedPlan(cwd, placement.appRel)
|
|
@@ -81,7 +81,10 @@ export function SettingsSection({
|
|
|
81
81
|
return (
|
|
82
82
|
<Card
|
|
83
83
|
className={cx(classNames?.root, className)}
|
|
84
|
-
style={{
|
|
84
|
+
style={{
|
|
85
|
+
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
86
|
+
...style,
|
|
87
|
+
}}
|
|
85
88
|
>
|
|
86
89
|
<div className={cx(classes.header, classNames?.header)}>
|
|
87
90
|
<WidgetHeader
|
|
@@ -155,7 +158,7 @@ export function DangerZone({
|
|
|
155
158
|
<Card
|
|
156
159
|
className={cx(classNames?.root, className)}
|
|
157
160
|
style={{
|
|
158
|
-
padding: 'var(--
|
|
161
|
+
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
159
162
|
boxShadow: `${VX.shadowCard}, 0 0 0 1px ${alpha(VX.status.bad, 0.25)}`,
|
|
160
163
|
...style,
|
|
161
164
|
}}
|
|
@@ -123,8 +123,8 @@
|
|
|
123
123
|
|
|
124
124
|
.sparklineBleed {
|
|
125
125
|
margin-top: auto;
|
|
126
|
-
margin-inline: calc(-1 * var(--
|
|
127
|
-
margin-bottom: calc(-1 * var(--
|
|
126
|
+
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
127
|
+
margin-bottom: calc(-1 * var(--vx-space-card-inset-y, 0.75rem));
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
/* Asks for `StatCard`'s `SPARKLINE_RIGHT_WIDTH`/`_HEIGHT` (handed down as custom properties, so this
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
flex: none;
|
|
160
160
|
align-self: stretch;
|
|
161
161
|
margin-top: auto;
|
|
162
|
-
margin-inline: calc(-1 * var(--
|
|
163
|
-
margin-bottom: calc(-1 * var(--
|
|
162
|
+
margin-inline: calc(-1 * var(--vx-space-card-inset-x, 1rem));
|
|
163
|
+
margin-bottom: calc(-1 * var(--vx-space-card-inset-y, 0.75rem));
|
|
164
164
|
}
|
|
165
165
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* StatCard — the KPI atom (docs/DESIGN-SPEC.md §5, docs/CONTROLS-SPEC.md §2.2): a panel +
|
|
3
|
-
* shadow-card + card-radius card (spacing
|
|
3
|
+
* shadow-card + card-radius card (spacing sm/md inset, no min-height — the content states the
|
|
4
4
|
* height, ~88-96px for the title/hero/trend shape). The header composes
|
|
5
5
|
* `WidgetHeader tier="widget"` — title/icon/value/delta/deltaPeriod all render through it, on the
|
|
6
6
|
* shared hero-metric row under the title. `actions` (e.g. a ghost "..." menu trigger) is wrapped in
|
|
@@ -400,24 +400,24 @@ export function StatCard({
|
|
|
400
400
|
<Card
|
|
401
401
|
className={cx(classNames?.root, className)}
|
|
402
402
|
style={{
|
|
403
|
-
// Card inset = the `cardInsetY`/`cardInsetX` role tokens (
|
|
404
|
-
//
|
|
405
|
-
//
|
|
406
|
-
//
|
|
407
|
-
//
|
|
408
|
-
//
|
|
409
|
-
// the full-bleed sparkline to the card's rounded corners
|
|
410
|
-
// renders outside its border box and is NOT clipped by its own
|
|
411
|
-
// shadow-card ring is unaffected (verified — only an ANCESTOR's overflow
|
|
412
|
-
// descendant's shadow). Mantine's Card root already sets `overflow: hidden`; this
|
|
413
|
-
// explicit for intent.
|
|
403
|
+
// Card inset = the `cardInsetY`/`cardInsetX` role tokens (12/16 at level 0, the `sm`/`md`
|
|
404
|
+
// rungs of the spacing grid), matching every other basalt card because `ChartCard` reads
|
|
405
|
+
// the SAME two vars. Below `sm` the horizontal one steps a rung down (to 12) on its own:
|
|
406
|
+
// the responsive half of the ladder lives in `spaceMobileDecls` (`tokens/index.ts`), which
|
|
407
|
+
// is the only home that can reach an inline style like this one.
|
|
408
|
+
//
|
|
409
|
+
// `overflow: hidden` clips the full-bleed sparkline to the card's rounded corners. An
|
|
410
|
+
// element's own `box-shadow` renders outside its border box and is NOT clipped by its own
|
|
411
|
+
// `overflow`, so the shadow-card ring is unaffected (verified — only an ANCESTOR's overflow
|
|
412
|
+
// clips a descendant's shadow). Mantine's Card root already sets `overflow: hidden`; this
|
|
413
|
+
// is explicit for intent.
|
|
414
414
|
//
|
|
415
415
|
// NO `minHeight`. It was 118px, which is ~25px of dead space under a card holding a title
|
|
416
416
|
// row, a hero row and a 26px trend — and it was dead space the card could not use, since the
|
|
417
417
|
// body is `height: 100%` and the sparkline is `margin-top: auto`. The content is what states
|
|
418
418
|
// the height now (~88-96px), and four cards in a `SimpleGrid` still match because a grid row
|
|
419
419
|
// stretches its items.
|
|
420
|
-
padding: 'var(--vx-space-card-inset-y, 0.
|
|
420
|
+
padding: 'var(--vx-space-card-inset-y, 0.75rem) var(--vx-space-card-inset-x, 1rem)',
|
|
421
421
|
overflow: 'hidden',
|
|
422
422
|
// Anchors the tone rail. Set unconditionally so a card's stacking context does not change
|
|
423
423
|
// depending on whether it happens to have crossed a threshold this render.
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
|
|
103
103
|
/*
|
|
104
104
|
* The icon slot PINS its glyph's box. A consumer's icon arrives at whatever size its own component
|
|
105
|
-
* chose (the playground's is 18px), and an 18px mark beside a
|
|
105
|
+
* chose (the playground's is 18px), and an 18px mark beside a 13px title is a bullet, not a label
|
|
106
106
|
* icon — so the tier states the size here rather than asking every call site to pass one.
|
|
107
107
|
*/
|
|
108
108
|
/*
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
overflow-wrap: anywhere;
|
|
175
175
|
font-family: var(--basalt-font-mono);
|
|
176
176
|
font-size: var(--vx-text-kpi);
|
|
177
|
-
font-weight:
|
|
177
|
+
font-weight: 500;
|
|
178
178
|
letter-spacing: -0.02em;
|
|
179
179
|
color: var(--vx-ink);
|
|
180
180
|
}
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
z-index: 10;
|
|
289
289
|
width: max-content;
|
|
290
290
|
max-width: 260px;
|
|
291
|
-
padding:
|
|
291
|
+
padding: var(--vx-space-stack-sm) var(--vx-space-row-inset-x);
|
|
292
292
|
border-radius: var(--vx-radius-card);
|
|
293
293
|
background-color: var(--vx-surface-panel);
|
|
294
294
|
box-shadow: var(--vx-shadow-card);
|
package/src/guard/guard-hook.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* guard-hook — pure helpers for the Claude Code PreToolUse hook adapter.
|
|
3
|
-
* Mantine-free
|
|
3
|
+
* Mantine-free and light: no non-type imports beyond guard internals and dependency-free leaves
|
|
4
|
+
* (`tokens/space-scale`), never `tokens/palette` or `derive` (their colour math would load on every
|
|
5
|
+
* Write/Edit).
|
|
4
6
|
*/
|
|
5
7
|
import { checkSource } from './index'
|
|
6
8
|
import type { GuardConfig } from './types'
|
package/src/guard/index.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ./guard — headless policy core. Mantine-free
|
|
2
|
+
* ./guard — headless policy core. Mantine-free and light: it may import dependency-free leaves
|
|
3
|
+
* (`tokens/space-scale`, `common/*`), never `tokens/palette` or `derive` (colour math on every
|
|
4
|
+
* Write/Edit).
|
|
3
5
|
*
|
|
4
6
|
* GUARD_RULES: the closed registry of all 26 violation kinds.
|
|
5
7
|
* checkSource: pure (text, relPath, cfg) → Finding[]. No FS, no walk, no console.
|
|
@@ -9,6 +11,7 @@ import { vxFamilyOf } from '../common/vx-family'
|
|
|
9
11
|
import { BASALT_VX_FAMILIES } from '../common/vx-families'
|
|
10
12
|
import { FONTS_CSS_HINT } from './fonts-hint'
|
|
11
13
|
import { BASALT_VX_NAMES } from './vx-names'
|
|
14
|
+
import { SPACE_SCALE_LEVEL0 } from '../tokens/space-scale'
|
|
12
15
|
|
|
13
16
|
export type { Finding, GuardConfig, GuardKind, GuardSeverity }
|
|
14
17
|
|
|
@@ -192,7 +195,7 @@ const DECLARED_CONTAINER_NAMES = new Set(['basalt-card', 'basalt-form', 'basalt-
|
|
|
192
195
|
|
|
193
196
|
/**
|
|
194
197
|
* `CONTAINER_CLASSES` (`src/tokens/size-classes.ts`) boundaries, duplicated per the `CTL_THEME_TAGS`
|
|
195
|
-
* convention in the oxlint plugin — this module
|
|
198
|
+
* convention in the oxlint plugin — this module keeps to the leaves its file header names and
|
|
196
199
|
* must not import `../tokens`. Pinned against the real table by `check-source.test.ts`. Judged only
|
|
197
200
|
* against `basalt-card` and unnamed queries: the other declared names have no shipped numeric table
|
|
198
201
|
* yet. `0` is the container's own floor, not a class boundary, but `(width >= 0px)` is a legitimate
|
|
@@ -494,7 +497,7 @@ const INLINE_SPACING = new RegExp(
|
|
|
494
497
|
* `exemptPatternMatches`; the escape stays because a per-file exemption is still the wrong shape
|
|
495
498
|
* for a value that has no token).
|
|
496
499
|
*/
|
|
497
|
-
const MICRO_SPACING_CEILING_PX =
|
|
500
|
+
const MICRO_SPACING_CEILING_PX = SPACE_SCALE_LEVEL0.xs - 1
|
|
498
501
|
|
|
499
502
|
/**
|
|
500
503
|
* Object-literal openers that make the properties under them CSS.
|
|
@@ -812,19 +815,19 @@ const SUB_16_FONT_SIZE = /font-?[Ss]ize\s*:\s*['"]?(-?\d+(?:\.\d+)?)(?:px)?['"]?
|
|
|
812
815
|
/** Default spacing steps (px) flagged as raw spacing props. */
|
|
813
816
|
/**
|
|
814
817
|
* The `xs…xl` spacing scale, as raw numbers — what `raw-spacing` flags, because a prop value that
|
|
815
|
-
* EQUALS a step should be written as the token (`p="md"`, not `p={
|
|
818
|
+
* EQUALS a step should be written as the token (`p="md"`, not `p={16}`).
|
|
816
819
|
*
|
|
817
|
-
*
|
|
818
|
-
* the
|
|
819
|
-
*
|
|
820
|
-
*
|
|
821
|
-
* still read `[10, 12, 16, 20, 32]` after the level-0 retune, telling consumers to replace `p={16}`
|
|
822
|
-
* with a `p="md"` that resolves to 18.
|
|
820
|
+
* Read from `tokens/space-scale` — the dependency-free module the token layer's scale is defined
|
|
821
|
+
* from — so the guard cannot drift from it (a separate copy once did: it read `[10, 12, 16, 20, 32]`
|
|
822
|
+
* after a retune and told consumers to replace `p={16}` with a `p="md"` worth 18). The palette itself
|
|
823
|
+
* stays out of the hook: it would drag `derive.ts` + `hct.ts`'s colour math along.
|
|
823
824
|
*
|
|
824
825
|
* A consumer whose theme moves the scale (`createBasaltTheme({ density })`, or its own overrides)
|
|
825
826
|
* sets `basalt.spacingSteps` in package.json rather than living with this default.
|
|
826
827
|
*/
|
|
827
|
-
const DEFAULT_SPACING_STEPS: readonly number[] =
|
|
828
|
+
const DEFAULT_SPACING_STEPS: readonly number[] = Object.values(SPACE_SCALE_LEVEL0).toSorted(
|
|
829
|
+
(a, b) => a - b,
|
|
830
|
+
)
|
|
828
831
|
/** Default off-identity Mantine accent families. */
|
|
829
832
|
const DEFAULT_FORBIDDEN_ACCENTS: readonly string[] = ['teal', 'violet', 'grape', 'indigo', 'pink']
|
|
830
833
|
|
|
@@ -897,7 +900,18 @@ export type GraceEntry = { since: string; promote: string; why: string }
|
|
|
897
900
|
* 'raw-font-family': { since: '1.4.0', promote: '1.5.0', why: 'introduced 1.4.0 — …' },
|
|
898
901
|
* }
|
|
899
902
|
*/
|
|
900
|
-
export const GRACE_PERIOD_KINDS: Partial<Record<GuardKind, GraceEntry>> = {
|
|
903
|
+
export const GRACE_PERIOD_KINDS: Partial<Record<GuardKind, GraceEntry>> = {
|
|
904
|
+
'raw-spacing': {
|
|
905
|
+
since: '2.16.0',
|
|
906
|
+
promote: '2.17.0',
|
|
907
|
+
why: 'The spacing scale moved to 8/12/16/20/24 in 2.16.0: a prop value equal to a NEW step (p={16}) is newly a finding.',
|
|
908
|
+
},
|
|
909
|
+
'inline-spacing': {
|
|
910
|
+
since: '2.16.0',
|
|
911
|
+
promote: '2.17.0',
|
|
912
|
+
why: 'The scale moved to 8/12/16/20/24 and the CSS micro ceiling dropped 10 → 7 in 2.16.0: a literal 8px/10px in CSS is newly a finding.',
|
|
913
|
+
},
|
|
914
|
+
}
|
|
901
915
|
|
|
902
916
|
/** A kind's effective severity: consumer override first, then the grace table, then `error`. */
|
|
903
917
|
function severityOf(kind: GuardKind, cfg: GuardConfig): GuardSeverity {
|
|
@@ -2058,7 +2072,7 @@ export const GUARD_RULES = {
|
|
|
2058
2072
|
// JSX-tag-shaped (`<Card withBorder>`) — never appears in CSS text.
|
|
2059
2073
|
appliesTo: (relPath) => !relPath.endsWith('.css'),
|
|
2060
2074
|
message:
|
|
2061
|
-
'withBorder on a Card/Paper double-draws the edge — card depth is --vx-shadow-card, which already bakes a 1px ring into the shadow. Drop the prop (docs/DESIGN-SPEC.md doctrine inversion #1) — and fix the inset in the same edit: an explicit p/padding or radius on that Card/Paper is the other half of the idiom, which only the oxlint lane sees (basalt/card-inset); leave both to the theme or use py="
|
|
2075
|
+
'withBorder on a Card/Paper double-draws the edge — card depth is --vx-shadow-card, which already bakes a 1px ring into the shadow. Drop the prop (docs/DESIGN-SPEC.md doctrine inversion #1) — and fix the inset in the same edit: an explicit p/padding or radius on that Card/Paper is the other half of the idiom, which only the oxlint lane sees (basalt/card-inset); leave both to the theme or use py="sm" px="md".',
|
|
2062
2076
|
},
|
|
2063
2077
|
'off-system-surface-var': {
|
|
2064
2078
|
kind: 'off-system-surface-var',
|
package/src/guard/vx-names.ts
CHANGED
|
@@ -111,6 +111,7 @@ export const BASALT_VX_NAMES: readonly string[] = [
|
|
|
111
111
|
'--vx-space-control-gap',
|
|
112
112
|
'--vx-space-control-height',
|
|
113
113
|
'--vx-space-control-height-ctl',
|
|
114
|
+
'--vx-space-control-height-dense',
|
|
114
115
|
'--vx-space-control-height-tag',
|
|
115
116
|
'--vx-space-control-height-widget',
|
|
116
117
|
'--vx-space-guide-body-gap-bottom',
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
.menuItem :global(.mantine-Menu-itemLabel) {
|
|
161
|
-
font-size: var(--mantine-font-size-
|
|
161
|
+
font-size: var(--mantine-font-size-sm) !important;
|
|
162
162
|
}
|
|
163
163
|
|
|
164
164
|
/* An active destination reads the same in the More surface as it does in the sheet. */
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
* touch target with a `min-height` floor and symmetric inset, so growing one side of it would make
|
|
246
246
|
* that row read as a different size from its siblings. */
|
|
247
247
|
.menuDropdown .menuSectionStart {
|
|
248
|
-
margin-top:
|
|
248
|
+
margin-top: var(--vx-space-stack-sm);
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
/*
|
|
@@ -113,7 +113,7 @@ export function SidebarAccount(props: BasaltAccountProps & BasaltProps) {
|
|
|
113
113
|
<span className={classes.footerIconSlot}>
|
|
114
114
|
<IconUser />
|
|
115
115
|
</span>
|
|
116
|
-
<Text className={classes.accountText} fz={VX.text.
|
|
116
|
+
<Text className={classes.accountText} fz={VX.text.sm}>
|
|
117
117
|
Sign in
|
|
118
118
|
</Text>
|
|
119
119
|
</UnstyledButton>
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
.link {
|
|
38
|
-
font-size: var(--vx-text-
|
|
38
|
+
font-size: var(--vx-text-sm);
|
|
39
39
|
border-radius: var(--vx-radius-ctrl) !important;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
.link :global(.mantine-NavLink-label) {
|
|
43
|
-
font-size: var(--vx-text-
|
|
43
|
+
font-size: var(--vx-text-sm);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.link :global(.mantine-NavLink-section[data-position='left']) {
|
|
@@ -229,8 +229,8 @@
|
|
|
229
229
|
}
|
|
230
230
|
|
|
231
231
|
/*
|
|
232
|
-
* Footer settings row — IDENTICAL geometry to a nav row (
|
|
233
|
-
*
|
|
232
|
+
* Footer settings row — IDENTICAL geometry to a nav row (the row inset tokens, control radius, nav
|
|
233
|
+
* icon gap, `sm` type): muted text + faint icon at rest, ink-6% tint + ink on hover, exactly like an inactive
|
|
234
234
|
* nav item, so the footer never reads as a separate control family.
|
|
235
235
|
*/
|
|
236
236
|
.footerBtn {
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
gap: var(--vx-space-nav-icon-gap);
|
|
242
242
|
padding: var(--vx-space-row-inset-y) var(--vx-space-row-inset-x);
|
|
243
243
|
border-radius: var(--vx-radius-ctrl);
|
|
244
|
-
font-size: var(--vx-text-
|
|
244
|
+
font-size: var(--vx-text-sm);
|
|
245
245
|
/* The nav row's line-height, so a footer row is exactly as tall as a nav row (Mantine's `Text`
|
|
246
246
|
* would otherwise bring its own 1.55 and add ~3px). */
|
|
247
247
|
line-height: var(--vx-space-row-line-height);
|
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
|
|
330
330
|
/* Identity name — weight 600, ink. */
|
|
331
331
|
.accountName {
|
|
332
|
-
font-size: var(--vx-text-
|
|
332
|
+
font-size: var(--vx-text-sm);
|
|
333
333
|
font-weight: 600;
|
|
334
334
|
color: var(--vx-ink);
|
|
335
335
|
}
|
|
@@ -644,7 +644,7 @@
|
|
|
644
644
|
}
|
|
645
645
|
|
|
646
646
|
.childList :global(.mantine-NavLink-label) {
|
|
647
|
-
font-size: var(--vx-text-
|
|
647
|
+
font-size: var(--vx-text-xs);
|
|
648
648
|
}
|
|
649
649
|
|
|
650
650
|
/*
|
|
@@ -689,7 +689,7 @@
|
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
.subnavDropdown :global(.mantine-NavLink-label) {
|
|
692
|
-
font-size: var(--vx-text-
|
|
692
|
+
font-size: var(--vx-text-sm);
|
|
693
693
|
}
|
|
694
694
|
|
|
695
695
|
/*
|
|
@@ -519,7 +519,7 @@ export function AppSidebar(props: AppSidebarProps) {
|
|
|
519
519
|
target. `SettingsMenuItem.icon` stays optional; supply one per row in the flat form
|
|
520
520
|
and the gear never appears. */}
|
|
521
521
|
<span className={classes.footerIconSlot}>{entry.icon ?? <IconGear />}</span>
|
|
522
|
-
<Text className={classes.footerText} fz={VX.text.
|
|
522
|
+
<Text className={classes.footerText} fz={VX.text.sm}>
|
|
523
523
|
{entry.label}
|
|
524
524
|
</Text>
|
|
525
525
|
{/* The rail ring rides the FIRST row only — one progress block is one mark. */}
|
|
@@ -539,7 +539,7 @@ export function AppSidebar(props: AppSidebarProps) {
|
|
|
539
539
|
<Menu.Target>
|
|
540
540
|
<UnstyledButton className={classes.footerBtn} aria-label="Settings">
|
|
541
541
|
<IconGear />
|
|
542
|
-
<Text className={classes.footerText} fz={VX.text.
|
|
542
|
+
<Text className={classes.footerText} fz={VX.text.sm}>
|
|
543
543
|
Settings
|
|
544
544
|
</Text>
|
|
545
545
|
{ringMark}
|