basalt-ui 2.19.0 → 2.21.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 +89 -0
- package/MIGRATING.md +291 -12
- package/agent/agents/basalt-design-reviewer.md +22 -5
- package/agent/rules/basalt-charts.md +1 -1
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +10 -23
- package/agent/skills/basalt-design/references/anti-defaults.md +24 -0
- package/agent/skills/basalt-design/references/catalogue.md +48 -0
- package/agent/skills/basalt-design/references/concept.md +36 -0
- package/agent/skills/basalt-design/references/encoding-rules.md +45 -0
- package/agent/skills/basalt-design/references/stat-tile.md +24 -0
- package/agent/templates/AGENTS-block.md.tpl +3 -3
- package/agent/templates/DESIGN.md.tpl +1 -1
- package/configs/oxlint-plugin.js +34 -19
- package/configs/oxlint-plugin.test.ts +32 -2
- package/dist/charts/ChartCard.d.ts +33 -4
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +37 -11
- package/dist/charts/Donut.d.ts.map +1 -1
- package/dist/charts/Donut.js +13 -1
- package/dist/charts/Heatmap.js +1 -1
- package/dist/charts/Sparkline.d.ts +7 -1
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +137 -18
- package/dist/charts/box.d.ts +2 -0
- package/dist/charts/box.d.ts.map +1 -1
- package/dist/charts/box.js +2 -0
- package/dist/charts/chart-box.module.css +30 -0
- package/dist/charts/chart-box.module.css.d.ts +1 -0
- package/dist/charts/chart-card.module.css +47 -0
- package/dist/charts/chart-card.module.css.d.ts +7 -0
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +35 -8
- package/dist/charts/host.d.ts.map +1 -1
- package/dist/charts/host.js +2 -1
- package/dist/charts/index.d.ts +1 -1
- package/dist/charts/index.d.ts.map +1 -1
- package/dist/charts/sparkline.module.css +59 -0
- package/dist/charts/sparkline.module.css.d.ts +13 -0
- package/dist/charts/state.d.ts +5 -0
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +34 -4
- package/dist/charts/types.d.ts +6 -0
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/check-theme.d.ts.map +1 -1
- package/dist/cli/check-theme.js +3 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +3 -2
- package/dist/cli/index.d.ts +4 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +27 -15
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +3 -2
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +6 -1
- package/dist/cli/shot/detect.d.ts +51 -0
- package/dist/cli/shot/detect.d.ts.map +1 -0
- package/dist/cli/shot/detect.js +396 -0
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +7 -4
- package/dist/cli/shot/measure.d.ts +2 -0
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +2 -0
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/shot/types.js +2 -0
- package/dist/cli/sync.d.ts +2 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -2
- package/dist/common/retry-button.d.ts +12 -0
- package/dist/common/retry-button.d.ts.map +1 -0
- package/dist/common/retry-button.js +22 -0
- package/dist/common/retry-button.module.css +58 -0
- package/dist/common/retry-button.module.css.d.ts +8 -0
- package/dist/controls/sync-button.d.ts +3 -0
- package/dist/controls/sync-button.d.ts.map +1 -1
- package/dist/dashboard/bar-list.d.ts +18 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +39 -15
- package/dist/dashboard/bar-list.module.css +77 -2
- package/dist/dashboard/bar-list.module.css.d.ts +1 -0
- package/dist/dashboard/delta-badge.d.ts +8 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +9 -2
- package/dist/dashboard/index.d.ts +2 -0
- package/dist/dashboard/index.d.ts.map +1 -1
- package/dist/dashboard/meter-model.d.ts +53 -6
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +62 -14
- package/dist/dashboard/meter-parts.d.ts +5 -1
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +140 -68
- package/dist/dashboard/meter.d.ts +29 -4
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +8 -1
- package/dist/dashboard/meter.module.css +74 -43
- package/dist/dashboard/meter.module.css.d.ts +4 -4
- package/dist/dashboard/query-state.d.ts +1 -1
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +16 -10
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +14 -25
- package/dist/dashboard/stat-card-parts.js +1 -1
- package/dist/dashboard/stat-card.d.ts +1 -1
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +5 -7
- package/dist/dashboard/stat-card.module.css +15 -7
- package/dist/dashboard/stat-group.d.ts +11 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +9 -7
- package/dist/dashboard/stat-strip.d.ts +67 -0
- package/dist/dashboard/stat-strip.d.ts.map +1 -0
- package/dist/dashboard/stat-strip.js +115 -0
- package/dist/dashboard/stat-strip.module.css +291 -0
- package/dist/dashboard/stat-strip.module.css.d.ts +32 -0
- package/dist/dashboard/visual-slot.d.ts +2 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -0
- package/dist/dashboard/visual-slot.js +5 -0
- package/dist/dashboard/widget-header.d.ts +3 -3
- package/dist/dashboard/widget-header.module.css +10 -6
- package/dist/format/date.d.ts.map +1 -1
- package/dist/format/date.js +4 -3
- package/dist/format/shared.d.ts +6 -0
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +6 -2
- package/dist/guard/index.d.ts +16 -3
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +15 -1
- package/dist/guard/palette.d.ts +51 -0
- package/dist/guard/palette.d.ts.map +1 -0
- package/dist/guard/palette.js +190 -0
- package/dist/guard/series-file.d.ts +15 -0
- package/dist/guard/series-file.d.ts.map +1 -0
- package/dist/guard/series-file.js +29 -0
- package/dist/guard/types.d.ts +3 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/styles.css +6 -0
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +2 -0
- package/dist/theme/card-inset.module.css +76 -0
- package/dist/theme/card-inset.module.css.d.ts +9 -0
- package/dist/theme/controls.module.css +13 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +41 -0
- package/dist/theme/nav-link.module.css +8 -10
- package/dist/theme/status-dot.d.ts +3 -2
- package/dist/theme/status-dot.d.ts.map +1 -1
- package/dist/theme/status-dot.js +12 -3
- package/dist/theme/status-verdict.d.ts +3 -2
- package/dist/theme/status-verdict.d.ts.map +1 -1
- package/dist/theme/status-verdict.js +3 -2
- package/dist/theme/status-verdict.module.css +4 -2
- package/dist/tokens/oklab.d.ts +28 -0
- package/dist/tokens/oklab.d.ts.map +1 -0
- package/dist/tokens/oklab.js +73 -0
- package/llms.txt +33 -7
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +79 -5
- package/src/charts/Donut.tsx +9 -1
- package/src/charts/Heatmap.tsx +1 -1
- package/src/charts/Sparkline.tsx +180 -18
- package/src/charts/box.tsx +2 -0
- package/src/charts/chart-box.module.css +30 -0
- package/src/charts/chart-box.module.css.d.ts +1 -0
- package/src/charts/chart-card.module.css +47 -0
- package/src/charts/chart-card.module.css.d.ts +7 -0
- package/src/charts/compile.ts +42 -9
- package/src/charts/host.tsx +6 -3
- package/src/charts/index.ts +1 -1
- package/src/charts/sparkline.module.css +59 -0
- package/src/charts/sparkline.module.css.d.ts +13 -0
- package/src/charts/state.tsx +53 -4
- package/src/charts/types.ts +6 -0
- package/src/cli/check-theme.ts +3 -0
- package/src/cli/help.ts +18 -1
- package/src/cli/index.ts +48 -17
- package/src/cli/init.ts +2 -1
- package/src/cli/shot/capture.ts +15 -2
- package/src/cli/shot/detect.ts +533 -0
- package/src/cli/shot/index.ts +8 -4
- package/src/cli/shot/measure.ts +4 -0
- package/src/cli/shot/types.ts +5 -1
- package/src/cli/sync.ts +4 -2
- package/src/common/retry-button.module.css +58 -0
- package/src/common/retry-button.module.css.d.ts +8 -0
- package/src/common/retry-button.tsx +29 -0
- package/src/controls/sync-button.tsx +3 -0
- package/src/dashboard/bar-list.module.css +77 -2
- package/src/dashboard/bar-list.module.css.d.ts +1 -0
- package/src/dashboard/bar-list.tsx +89 -18
- package/src/dashboard/delta-badge.tsx +21 -5
- package/src/dashboard/index.ts +2 -0
- package/src/dashboard/meter-model.ts +126 -20
- package/src/dashboard/meter-parts.tsx +224 -88
- package/src/dashboard/meter.module.css +74 -43
- package/src/dashboard/meter.module.css.d.ts +4 -4
- package/src/dashboard/meter.tsx +39 -5
- package/src/dashboard/query-state.tsx +26 -20
- package/src/dashboard/settings-section.tsx +1 -8
- package/src/dashboard/stat-card-parts.tsx +1 -1
- package/src/dashboard/stat-card.module.css +15 -7
- package/src/dashboard/stat-card.tsx +9 -9
- package/src/dashboard/stat-group.tsx +19 -8
- package/src/dashboard/stat-strip.module.css +291 -0
- package/src/dashboard/stat-strip.module.css.d.ts +32 -0
- package/src/dashboard/stat-strip.tsx +263 -0
- package/src/dashboard/visual-slot.ts +8 -0
- package/src/dashboard/widget-header.module.css +10 -6
- package/src/dashboard/widget-header.tsx +3 -3
- package/src/format/date.ts +6 -3
- package/src/format/shared.ts +11 -2
- package/src/guard/index.ts +17 -5
- package/src/guard/palette.ts +261 -0
- package/src/guard/series-file.ts +51 -0
- package/src/guard/types.ts +3 -2
- package/src/index.ts +7 -0
- package/src/styles.css +6 -0
- package/src/surfaces.ts +2 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +202 -24
- package/src/theme/card-inset.module.css +76 -0
- package/src/theme/card-inset.module.css.d.ts +9 -0
- package/src/theme/controls.module.css +13 -0
- package/src/theme/index.ts +56 -0
- package/src/theme/nav-link.module.css +8 -10
- package/src/theme/status-dot.tsx +17 -5
- package/src/theme/status-verdict.module.css +4 -2
- package/src/theme/status-verdict.tsx +9 -4
- package/src/tokens/oklab.ts +97 -0
package/src/format/shared.ts
CHANGED
|
@@ -92,11 +92,20 @@ function memoize<T>(
|
|
|
92
92
|
return created
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
+
/**
|
|
96
|
+
* The ONE locale resolution every formatter shares: the call's own tag, else the
|
|
97
|
+
* {@link defineFormat} default, else `undefined` (the runtime's own locale). Internal — not
|
|
98
|
+
* re-exported from the public barrel.
|
|
99
|
+
*/
|
|
100
|
+
export function resolveLocale(locale?: string): string | undefined {
|
|
101
|
+
return locale ?? defaults.locale
|
|
102
|
+
}
|
|
103
|
+
|
|
95
104
|
export function numberFormat(
|
|
96
105
|
locale: string | undefined,
|
|
97
106
|
options: Intl.NumberFormatOptions,
|
|
98
107
|
): Intl.NumberFormat {
|
|
99
|
-
const resolved = locale
|
|
108
|
+
const resolved = resolveLocale(locale)
|
|
100
109
|
return memoize(numberCaches, resolved, options, () => new Intl.NumberFormat(resolved, options))
|
|
101
110
|
}
|
|
102
111
|
|
|
@@ -104,7 +113,7 @@ export function dateFormat(
|
|
|
104
113
|
locale: string | undefined,
|
|
105
114
|
options: Intl.DateTimeFormatOptions,
|
|
106
115
|
): Intl.DateTimeFormat {
|
|
107
|
-
const resolved = locale
|
|
116
|
+
const resolved = resolveLocale(locale)
|
|
108
117
|
const withZone =
|
|
109
118
|
options.timeZone === undefined && defaults.timeZone !== undefined
|
|
110
119
|
? { ...options, timeZone: defaults.timeZone }
|
package/src/guard/index.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* (`tokens/space-scale`, `common/*`), never `tokens/palette` or `derive` (colour math on every
|
|
4
4
|
* Write/Edit).
|
|
5
5
|
*
|
|
6
|
-
* GUARD_RULES: the closed registry of all
|
|
6
|
+
* GUARD_RULES: the closed registry of all 27 violation kinds.
|
|
7
7
|
* checkSource: pure (text, relPath, cfg) → Finding[]. No FS, no walk, no console.
|
|
8
8
|
*/
|
|
9
9
|
import type { Finding, GuardConfig, GuardKind, GuardSeverity } from './types'
|
|
@@ -911,10 +911,15 @@ export const GRACE_PERIOD_KINDS: Partial<Record<GuardKind, GraceEntry>> = {
|
|
|
911
911
|
promote: '2.24.0',
|
|
912
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
913
|
},
|
|
914
|
+
'series-palette': {
|
|
915
|
+
since: '2.21.0',
|
|
916
|
+
promote: '2.23.0',
|
|
917
|
+
why: 'New in 2.21.0: the series file is judged by computed lightness, chroma, colour-blind separation and contrast; a palette that was tuned by eye is newly a finding.',
|
|
918
|
+
},
|
|
914
919
|
}
|
|
915
920
|
|
|
916
921
|
/** A kind's effective severity: consumer override first, then the grace table, then `error`. */
|
|
917
|
-
function severityOf(kind: GuardKind, cfg: GuardConfig): GuardSeverity {
|
|
922
|
+
export function severityOf(kind: GuardKind, cfg: GuardConfig): GuardSeverity {
|
|
918
923
|
return cfg.severity?.[kind] ?? (Object.hasOwn(GRACE_PERIOD_KINDS, kind) ? 'warn' : 'error')
|
|
919
924
|
}
|
|
920
925
|
|
|
@@ -985,7 +990,7 @@ function exemptPatternMatches(pattern: string, relPath: string): boolean {
|
|
|
985
990
|
* Whether `kind` is exempted at `relPath` via `cfg.exemptRules` — the config-driven, per-rule
|
|
986
991
|
* counterpart to `isChartFile`'s hardcoded path scoping.
|
|
987
992
|
*/
|
|
988
|
-
function isRuleExempt(
|
|
993
|
+
export function isRuleExempt(
|
|
989
994
|
kind: GuardKind,
|
|
990
995
|
relPath: string,
|
|
991
996
|
exemptRules: GuardConfig['exemptRules'],
|
|
@@ -1982,7 +1987,7 @@ type GuardRule = {
|
|
|
1982
1987
|
}
|
|
1983
1988
|
|
|
1984
1989
|
/**
|
|
1985
|
-
* The closed registry of all
|
|
1990
|
+
* The closed registry of all 27 guard kinds. The triad test asserts
|
|
1986
1991
|
* `surface.guardKinds ⊆ keyof GUARD_RULES` at runtime.
|
|
1987
1992
|
*
|
|
1988
1993
|
* raw-surface, raw-html-layout, and sub-16-input-font are handled inline in checkSource
|
|
@@ -2072,7 +2077,7 @@ export const GUARD_RULES = {
|
|
|
2072
2077
|
// JSX-tag-shaped (`<Card withBorder>`) — never appears in CSS text.
|
|
2073
2078
|
appliesTo: (relPath) => !relPath.endsWith('.css'),
|
|
2074
2079
|
message:
|
|
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);
|
|
2080
|
+
'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); the theme owns both, so write neither.',
|
|
2076
2081
|
},
|
|
2077
2082
|
'off-system-surface-var': {
|
|
2078
2083
|
kind: 'off-system-surface-var',
|
|
@@ -2208,6 +2213,13 @@ export const GUARD_RULES = {
|
|
|
2208
2213
|
pattern: VX_VAR_REF, // handled inline (basalt-owned families); entry keeps the registry complete
|
|
2209
2214
|
message: `var() names a --vx-* token basalt does not emit, so it resolves to its fallback (or to nothing) with no error anywhere. Judged: every name inside a basalt-owned family (${[...BASALT_VX_FAMILY_SET].join(', ')}), plus any name basalt used to emit in any family — pick the token from the stylesheet basalt-ui tokens:css emits; your own series belong in a family of their own (groupTokens throws on one inside basalt's, in dev builds). A removed name is reported with its replacement on the finding line (MIGRATING.md has the table). Any other name outside a basalt family is never judged, because groupTokens may declare it in a file this scan cannot see.`,
|
|
2210
2215
|
},
|
|
2216
|
+
'series-palette': {
|
|
2217
|
+
kind: 'series-palette',
|
|
2218
|
+
pattern: /(?!)/, // never matches: judged over the whole series FILE by `series-file.ts`, not per line
|
|
2219
|
+
appliesTo: () => false,
|
|
2220
|
+
message:
|
|
2221
|
+
"The series file's palette fails a computed check (OKLCH lightness band, chroma floor, colour-blind separation of neighbours, worst-pair separation, 3:1 contrast against the surface, ≤ 8 series without a repeat) — retune the hex in the series file; it is judged per scheme, light against the light panel and dark against the dark one. A deliberately neutral series is keyed `other`.",
|
|
2222
|
+
},
|
|
2211
2223
|
} as const satisfies Record<GuardKind, GuardRule>
|
|
2212
2224
|
|
|
2213
2225
|
/**
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `series-palette` — the series file's palette is computed, never eyeballed.
|
|
3
|
+
*
|
|
4
|
+
* Pure: source text and the two scheme surfaces in, issues out. Reads every
|
|
5
|
+
* `defineSeries({ key: { light, dark } })` call as one ordered categorical group and judges each
|
|
6
|
+
* scheme against its own surface. The surfaces are the CALLER's to supply: this module is on the
|
|
7
|
+
* guard's import graph, which never loads the `derive` engine (see `guard/index.ts`'s header) —
|
|
8
|
+
* `series-file.ts` computes them. Colour math lives in `../tokens/oklab`; contrast is `hct.ts`'s
|
|
9
|
+
* WCAG ratio.
|
|
10
|
+
*/
|
|
11
|
+
import { contrastRatio } from '../tokens/hct'
|
|
12
|
+
import { deltaEOk, deltaEOkCvd, hexToOklch } from '../tokens/oklab'
|
|
13
|
+
|
|
14
|
+
export type SeriesScheme = 'light' | 'dark'
|
|
15
|
+
/** The surface each scheme's series are judged against. */
|
|
16
|
+
export type SeriesSurfaces = Record<SeriesScheme, string>
|
|
17
|
+
|
|
18
|
+
export type SeriesCheck =
|
|
19
|
+
| 'format'
|
|
20
|
+
| 'lightness'
|
|
21
|
+
| 'chroma'
|
|
22
|
+
| 'cvd'
|
|
23
|
+
| 'separation'
|
|
24
|
+
| 'contrast'
|
|
25
|
+
| 'order'
|
|
26
|
+
|
|
27
|
+
export type SeriesEntry = {
|
|
28
|
+
readonly key: string
|
|
29
|
+
readonly light: string
|
|
30
|
+
readonly dark: string
|
|
31
|
+
/** 1-based line of the entry in the scanned source. */
|
|
32
|
+
readonly line: number
|
|
33
|
+
}
|
|
34
|
+
export type SeriesGroup = { readonly line: number; readonly entries: readonly SeriesEntry[] }
|
|
35
|
+
|
|
36
|
+
export type SeriesIssue = {
|
|
37
|
+
readonly check: SeriesCheck
|
|
38
|
+
readonly scheme: SeriesScheme
|
|
39
|
+
readonly keys: readonly string[]
|
|
40
|
+
readonly measured: number
|
|
41
|
+
readonly threshold: number
|
|
42
|
+
/** Line of the first named key. */
|
|
43
|
+
readonly line: number
|
|
44
|
+
readonly message: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* OKLCH lightness bands, per scheme.
|
|
49
|
+
* - light [0.43, 0.77] — the brief's band: below 0.43 a series reads as ink, above 0.77 it washes
|
|
50
|
+
* out on the panel (3:1 bites earlier, near L 0.67, on the default light panel).
|
|
51
|
+
* - dark [0.58, 0.88] — lower bound is where a hue clears 3:1 against the default dark panel
|
|
52
|
+
* (#2b2b2e, L 0.29 → L ≈ 0.56, rounded up for margin); the upper bound keeps a clear step below
|
|
53
|
+
* white so a bright series does not glow against the dark page.
|
|
54
|
+
*/
|
|
55
|
+
export const LIGHTNESS_BAND: Record<SeriesScheme, readonly [number, number]> = {
|
|
56
|
+
light: [0.43, 0.77],
|
|
57
|
+
dark: [0.58, 0.88],
|
|
58
|
+
}
|
|
59
|
+
/** Minimum OKLCH chroma of a categorical hue. */
|
|
60
|
+
export const CHROMA_FLOOR = 0.1
|
|
61
|
+
/** Minimum OKLab ΔE×100 between ADJACENT series under protanopia and deuteranopia. */
|
|
62
|
+
export const CVD_ADJACENT_MIN = 8
|
|
63
|
+
/** Minimum OKLab ΔE×100 of the worst pair in a group, normal vision. */
|
|
64
|
+
export const SEPARATION_MIN = 15
|
|
65
|
+
/** Minimum WCAG contrast of a series against its scheme's surface. */
|
|
66
|
+
export const CONTRAST_MIN = 3
|
|
67
|
+
/** More categorical series than this and the next one folds into Other. */
|
|
68
|
+
export const MAX_SERIES = 8
|
|
69
|
+
/** The one escape: a series keyed `other` is deliberately neutral — exempt from the chroma floor only. */
|
|
70
|
+
export const NEUTRAL_KEY = 'other'
|
|
71
|
+
|
|
72
|
+
const HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i
|
|
73
|
+
|
|
74
|
+
/** The string literal after `light:` / `dark:`, in either order. */
|
|
75
|
+
const ENTRY =
|
|
76
|
+
/([A-Za-z_$][\w$]*|'[^']+'|"[^"]+")\s*:\s*\{\s*(?:light\s*:\s*(['"])(.*?)\2\s*,\s*dark\s*:\s*(['"])(.*?)\4|dark\s*:\s*(['"])(.*?)\6\s*,\s*light\s*:\s*(['"])(.*?)\8)/g
|
|
77
|
+
|
|
78
|
+
const lineOf = (text: string, at: number): number => text.slice(0, at).split('\n').length
|
|
79
|
+
|
|
80
|
+
/** Every `defineSeries(...)` call in `source`, as an ordered group of its literal `{ light, dark }` hex pairs. */
|
|
81
|
+
export function parseSeriesGroups(source: string): SeriesGroup[] {
|
|
82
|
+
const groups: SeriesGroup[] = []
|
|
83
|
+
for (const call of source.matchAll(/\bdefineSeries\s*\(/g)) {
|
|
84
|
+
const open = (call.index ?? 0) + call[0].length
|
|
85
|
+
const lineStart = source.lastIndexOf('\n', call.index ?? 0) + 1
|
|
86
|
+
if (/^\s*(?:\/\/|\*|\/\*)/.test(source.slice(lineStart, call.index))) continue
|
|
87
|
+
let depth = 1
|
|
88
|
+
let end = open
|
|
89
|
+
while (end < source.length && depth > 0) {
|
|
90
|
+
const ch = source[end]
|
|
91
|
+
if (ch === '(') depth += 1
|
|
92
|
+
else if (ch === ')') depth -= 1
|
|
93
|
+
end += 1
|
|
94
|
+
}
|
|
95
|
+
const body = source.slice(open, end)
|
|
96
|
+
const entries = [...body.matchAll(ENTRY)].map((m): SeriesEntry => {
|
|
97
|
+
const light = m[3] ?? m[9] ?? ''
|
|
98
|
+
const dark = m[5] ?? m[7] ?? ''
|
|
99
|
+
return {
|
|
100
|
+
key: (m[1] ?? '').replace(/^['"]|['"]$/g, ''),
|
|
101
|
+
light: light.trim(),
|
|
102
|
+
dark: dark.trim(),
|
|
103
|
+
line: lineOf(source, open + (m.index ?? 0)),
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
groups.push({ line: lineOf(source, call.index ?? 0), entries })
|
|
107
|
+
}
|
|
108
|
+
return groups
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const fix = (n: number, digits = 2): string => n.toFixed(digits)
|
|
112
|
+
|
|
113
|
+
/** Judge every group against the six checks. */
|
|
114
|
+
export function auditSeriesGroups(
|
|
115
|
+
groups: readonly SeriesGroup[],
|
|
116
|
+
surfaces: SeriesSurfaces,
|
|
117
|
+
): SeriesIssue[] {
|
|
118
|
+
const issues: SeriesIssue[] = []
|
|
119
|
+
for (const group of groups) {
|
|
120
|
+
const { entries: allEntries } = group
|
|
121
|
+
const lineOfKey = (key: string) => allEntries.find((e) => e.key === key)?.line ?? group.line
|
|
122
|
+
|
|
123
|
+
const categorical = allEntries.filter((e) => e.key !== NEUTRAL_KEY)
|
|
124
|
+
if (categorical.length > MAX_SERIES) {
|
|
125
|
+
const extra = categorical.slice(MAX_SERIES).map((e) => e.key)
|
|
126
|
+
issues.push({
|
|
127
|
+
check: 'order',
|
|
128
|
+
scheme: 'light',
|
|
129
|
+
keys: extra,
|
|
130
|
+
measured: categorical.length,
|
|
131
|
+
threshold: MAX_SERIES,
|
|
132
|
+
line: lineOfKey(extra[0] ?? ''),
|
|
133
|
+
message: `${categorical.length} series in one group (max ${MAX_SERIES}) — ${extra.join(', ')} should fold into \`${NEUTRAL_KEY}\``,
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const scheme of ['light', 'dark'] as const) {
|
|
138
|
+
const [lo, hi] = LIGHTNESS_BAND[scheme]
|
|
139
|
+
const value = (e: SeriesEntry) => e[scheme]
|
|
140
|
+
// A value that is not `#rgb` / `#rrggbb` (an alpha hex, a colour name, a typo) cannot be
|
|
141
|
+
// measured — it is reported, and left out of this scheme's other checks rather than guessed at.
|
|
142
|
+
const entries = allEntries.filter((e) => {
|
|
143
|
+
if (HEX.test(value(e))) return true
|
|
144
|
+
issues.push({
|
|
145
|
+
check: 'format',
|
|
146
|
+
scheme,
|
|
147
|
+
keys: [e.key],
|
|
148
|
+
measured: 0,
|
|
149
|
+
threshold: 0,
|
|
150
|
+
line: e.line,
|
|
151
|
+
message: `${e.key} (${scheme}) "${value(e)}" is not a #rgb or #rrggbb hex — it cannot be checked`,
|
|
152
|
+
})
|
|
153
|
+
return false
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
for (const e of entries) {
|
|
157
|
+
const { L, C } = hexToOklch(value(e))
|
|
158
|
+
if (L < lo || L > hi) {
|
|
159
|
+
issues.push({
|
|
160
|
+
check: 'lightness',
|
|
161
|
+
scheme,
|
|
162
|
+
keys: [e.key],
|
|
163
|
+
measured: L,
|
|
164
|
+
threshold: L < lo ? lo : hi,
|
|
165
|
+
line: e.line,
|
|
166
|
+
message: `${e.key} (${scheme}) OKLCH lightness ${fix(L)} is outside ${lo}–${hi}`,
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
if (e.key !== NEUTRAL_KEY && C < CHROMA_FLOOR) {
|
|
170
|
+
issues.push({
|
|
171
|
+
check: 'chroma',
|
|
172
|
+
scheme,
|
|
173
|
+
keys: [e.key],
|
|
174
|
+
measured: C,
|
|
175
|
+
threshold: CHROMA_FLOOR,
|
|
176
|
+
line: e.line,
|
|
177
|
+
message: `${e.key} (${scheme}) OKLCH chroma ${fix(C, 3)} is below ${CHROMA_FLOOR} — a categorical hue must read as a hue (key a deliberately neutral series \`${NEUTRAL_KEY}\`)`,
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
const ratio = contrastRatio(value(e), surfaces[scheme])
|
|
181
|
+
if (ratio < CONTRAST_MIN) {
|
|
182
|
+
issues.push({
|
|
183
|
+
check: 'contrast',
|
|
184
|
+
scheme,
|
|
185
|
+
keys: [e.key],
|
|
186
|
+
measured: ratio,
|
|
187
|
+
threshold: CONTRAST_MIN,
|
|
188
|
+
line: e.line,
|
|
189
|
+
message: `${e.key} (${scheme}) contrast ${fix(ratio)}:1 against the surface is below ${CONTRAST_MIN}:1`,
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
// Cycling: an identical colour twice in one scheme is one series standing in for two.
|
|
195
|
+
const seen = new Map<string, string>()
|
|
196
|
+
const duplicated = new Set<string>()
|
|
197
|
+
for (const e of entries) {
|
|
198
|
+
const first = seen.get(value(e).toLowerCase())
|
|
199
|
+
if (first === undefined) seen.set(value(e).toLowerCase(), e.key)
|
|
200
|
+
else {
|
|
201
|
+
duplicated.add(`${first}|${e.key}`)
|
|
202
|
+
issues.push({
|
|
203
|
+
check: 'order',
|
|
204
|
+
scheme,
|
|
205
|
+
keys: [first, e.key],
|
|
206
|
+
measured: 0,
|
|
207
|
+
threshold: SEPARATION_MIN,
|
|
208
|
+
line: e.line,
|
|
209
|
+
message: `${first} and ${e.key} (${scheme}) are the same colour ${value(e)} — a group does not cycle`,
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Adjacent pairs, worst of the two dichromacies.
|
|
215
|
+
for (let i = 1; i < entries.length; i += 1) {
|
|
216
|
+
const a = entries[i - 1] as SeriesEntry
|
|
217
|
+
const b = entries[i] as SeriesEntry
|
|
218
|
+
if (duplicated.has(`${a.key}|${b.key}`)) continue
|
|
219
|
+
const sims = (['protan', 'deutan'] as const).map(
|
|
220
|
+
(kind) => [kind, deltaEOkCvd(value(a), value(b), kind)] as const,
|
|
221
|
+
)
|
|
222
|
+
const [kind, worst] = sims.reduce((m, s) => (s[1] < m[1] ? s : m))
|
|
223
|
+
if (worst < CVD_ADJACENT_MIN) {
|
|
224
|
+
issues.push({
|
|
225
|
+
check: 'cvd',
|
|
226
|
+
scheme,
|
|
227
|
+
keys: [a.key, b.key],
|
|
228
|
+
measured: worst,
|
|
229
|
+
threshold: CVD_ADJACENT_MIN,
|
|
230
|
+
line: b.line,
|
|
231
|
+
message: `${a.key} → ${b.key} (${scheme}) are ΔE ${fix(worst, 1)} apart under ${kind === 'protan' ? 'protanopia' : 'deuteranopia'}, below ${CVD_ADJACENT_MIN}`,
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Worst pair over the whole group, normal vision (identical pairs are `order`'s).
|
|
237
|
+
let worstPair: { a: SeriesEntry; b: SeriesEntry; de: number } | null = null
|
|
238
|
+
for (let i = 0; i < entries.length; i += 1) {
|
|
239
|
+
for (let j = i + 1; j < entries.length; j += 1) {
|
|
240
|
+
const a = entries[i] as SeriesEntry
|
|
241
|
+
const b = entries[j] as SeriesEntry
|
|
242
|
+
if (duplicated.has(`${a.key}|${b.key}`)) continue
|
|
243
|
+
const de = deltaEOk(value(a), value(b))
|
|
244
|
+
if (worstPair === null || de < worstPair.de) worstPair = { a, b, de }
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (worstPair !== null && worstPair.de < SEPARATION_MIN) {
|
|
248
|
+
issues.push({
|
|
249
|
+
check: 'separation',
|
|
250
|
+
scheme,
|
|
251
|
+
keys: [worstPair.a.key, worstPair.b.key],
|
|
252
|
+
measured: worstPair.de,
|
|
253
|
+
threshold: SEPARATION_MIN,
|
|
254
|
+
line: worstPair.b.line,
|
|
255
|
+
message: `${worstPair.a.key} and ${worstPair.b.key} (${scheme}) are only ΔE ${fix(worstPair.de, 1)} apart, below ${SEPARATION_MIN}`,
|
|
256
|
+
})
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return issues
|
|
261
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `series-palette`: the series module as a FILE. Judges each `defineSeries` group, wraps the issues
|
|
3
|
+
* as findings, and reads the file with the surfaces derived from the default theme. Kept out of
|
|
4
|
+
* `guard/index.ts`'s import graph on purpose — that graph is on the PreToolUse hook path and never
|
|
5
|
+
* loads colour math or the `derive` engine; this one does. `check-theme` is the only caller.
|
|
6
|
+
*/
|
|
7
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
8
|
+
import { resolve } from 'node:path'
|
|
9
|
+
|
|
10
|
+
import { DEFAULT_DERIVE_CONFIG, deriveTokens } from '../tokens/derive'
|
|
11
|
+
import { isRuleExempt, severityOf } from './index'
|
|
12
|
+
import { auditSeriesGroups, parseSeriesGroups } from './palette'
|
|
13
|
+
import type { SeriesSurfaces } from './palette'
|
|
14
|
+
import type { Finding, GuardConfig } from './types'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Judge ONE series file's palette: one finding per failed check, naming the key(s), scheme,
|
|
18
|
+
* measured number and threshold. The series module is exempt from every line-scan kind, so it is
|
|
19
|
+
* judged here instead. Honors `severity` and `exemptRules` like any other kind.
|
|
20
|
+
*/
|
|
21
|
+
export function checkSeriesPalette(
|
|
22
|
+
source: string,
|
|
23
|
+
relPath: string,
|
|
24
|
+
cfg: GuardConfig,
|
|
25
|
+
surfaces: SeriesSurfaces,
|
|
26
|
+
): Finding[] {
|
|
27
|
+
if (isRuleExempt('series-palette', relPath, cfg.exemptRules)) return []
|
|
28
|
+
return auditSeriesGroups(parseSeriesGroups(source), surfaces).map((issue) => ({
|
|
29
|
+
relPath,
|
|
30
|
+
line: issue.line,
|
|
31
|
+
token: issue.keys.join(', '),
|
|
32
|
+
text: issue.message,
|
|
33
|
+
kind: 'series-palette' as const,
|
|
34
|
+
severity: severityOf('series-palette', cfg),
|
|
35
|
+
}))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Findings for the series module at `<cwd>/<rel>`; none if it does not exist. Surfaces are the
|
|
40
|
+
* derive engine's default `surface.panel` (a chart sits on a panel) — a consumer's `derive`
|
|
41
|
+
* overrides are not read.
|
|
42
|
+
*/
|
|
43
|
+
export function checkSeriesModule(cwd: string, rel: string, cfg: GuardConfig): Finding[] {
|
|
44
|
+
const file = resolve(cwd, rel)
|
|
45
|
+
if (!existsSync(file)) return []
|
|
46
|
+
const { panel } = deriveTokens(DEFAULT_DERIVE_CONFIG).surface
|
|
47
|
+
return checkSeriesPalette(readFileSync(file, 'utf8'), rel, cfg, {
|
|
48
|
+
light: panel.light,
|
|
49
|
+
dark: panel.dark,
|
|
50
|
+
})
|
|
51
|
+
}
|
package/src/guard/types.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Guard types — Mantine-free, dependency-free (zero imports beyond TS types).
|
|
3
3
|
*
|
|
4
|
-
* GuardKind is the closed set of
|
|
4
|
+
* GuardKind is the closed set of 27 violation kinds the theme guard can emit. Retired kinds
|
|
5
5
|
* (`unframed-chart`, `raw-visx-axis`, `chart-missing-aria-label`) stay recognized ids in
|
|
6
6
|
* `PLUGIN_RULE_IDS`/`KNOWN_RULE_IDS` so an existing `theme-allow <id>` reads as a dead waiver, not
|
|
7
7
|
* a typo.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* GuardConfig is the per-run configuration that drives checkSource.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
/** The
|
|
12
|
+
/** The 27 theme-guard violation kinds. */
|
|
13
13
|
export type GuardKind =
|
|
14
14
|
| 'raw-hex'
|
|
15
15
|
| 'raw-color-fn'
|
|
@@ -37,6 +37,7 @@ export type GuardKind =
|
|
|
37
37
|
| 'raw-selection-control'
|
|
38
38
|
| 'raw-media-query'
|
|
39
39
|
| 'unknown-vx-token'
|
|
40
|
+
| 'series-palette'
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* How hard a finding lands. `error` fails the build; `warn` reports and passes.
|
package/src/index.ts
CHANGED
|
@@ -26,6 +26,8 @@ export {
|
|
|
26
26
|
export { scrollParentOf, useCoarsePointer, type Tone } from './common'
|
|
27
27
|
export { createBasaltTheme } from './theme'
|
|
28
28
|
export { ThemeToggle } from './theme/theme-toggle'
|
|
29
|
+
export { StatusDot, type StatusDotProps } from './theme/status-dot'
|
|
30
|
+
export { StatusVerdict, type StatusVerdictProps } from './theme/status-verdict'
|
|
29
31
|
export {
|
|
30
32
|
BasaltShell,
|
|
31
33
|
PageBar,
|
|
@@ -44,12 +46,17 @@ export {
|
|
|
44
46
|
type StatCardBreakdownRow,
|
|
45
47
|
type StatCardSparklineSize,
|
|
46
48
|
StatGroup,
|
|
49
|
+
type StatStripCell,
|
|
50
|
+
type StatStripRow,
|
|
47
51
|
EmptyState,
|
|
48
52
|
SettingsSection,
|
|
49
53
|
SettingsRow,
|
|
50
54
|
DangerZone,
|
|
51
55
|
Meter,
|
|
52
56
|
type MeterProps,
|
|
57
|
+
type MeterSegment,
|
|
58
|
+
type MeterTick,
|
|
59
|
+
type MeterZone,
|
|
53
60
|
BarList,
|
|
54
61
|
type BarListProps,
|
|
55
62
|
} from './dashboard'
|
package/src/styles.css
CHANGED
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
'Hubot Sans Variable', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica,
|
|
47
47
|
Arial, sans-serif;
|
|
48
48
|
--basalt-font-mono: 'JetBrains Mono Variable', ui-monospace, 'SF Mono', Menlo, monospace;
|
|
49
|
+
/* Hero values, unit/count/delta text, bar-list and meter figures: proportional sans, lining
|
|
50
|
+
figures. Set to `var(--basalt-font-mono)` to restore the pre-Wave-35 mono numerals. */
|
|
51
|
+
--basalt-font-numeral: var(--basalt-font-sans);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
|
|
@@ -153,6 +156,9 @@
|
|
|
153
156
|
h6,
|
|
154
157
|
.mantine-Title-root {
|
|
155
158
|
font-stretch: var(--basalt-font-head-stretch, 88%);
|
|
159
|
+
/* Hubot Sans draws a slashed zero by default; a heading numeral is a figure, not code. */
|
|
160
|
+
font-feature-settings: 'zero' 0;
|
|
161
|
+
font-variant-numeric: lining-nums;
|
|
156
162
|
}
|
|
157
163
|
|
|
158
164
|
/* Scrollbars (docs/DESIGN-SPEC.md §5): 9px, ink-mix thumb (stronger on hover), radius 6,
|
package/src/surfaces.ts
CHANGED
|
@@ -347,6 +347,8 @@ export const SURFACES = {
|
|
|
347
347
|
'surface-shadow-override',
|
|
348
348
|
// A `var(--vx-*)` naming a token basalt no longer (or never) emits.
|
|
349
349
|
'unknown-vx-token',
|
|
350
|
+
// The series file's computed palette checks (lightness, chroma, CVD separation, contrast).
|
|
351
|
+
'series-palette',
|
|
350
352
|
// Not a token kind — the kind that judges the ANNOTATION rather than the code. It lands here
|
|
351
353
|
// because `agent/rules/basalt-tokens.md` is where the `theme-allow` grammar is documented
|
|
352
354
|
// (said once, on purpose), so this is the header that must name its enforcement.
|