basalt-ui 1.4.1 → 1.5.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 +9 -0
- package/README.md +27 -2
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-tokens.md +2 -2
- package/agent/skills/basalt-design/SKILL.md +1 -1
- package/dist/charts/kinds/Donut.js +1 -0
- package/dist/charts/theme.js +6 -6
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +8 -3
- package/dist/content/article-card.module.css +1 -1
- package/dist/content/callout.module.css +3 -3
- package/dist/content/prose.module.css +1 -1
- package/dist/content/reading-progress.module.css +2 -2
- package/dist/guard/guard-hook.js +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +22 -4
- package/dist/guard/types.d.ts +6 -0
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/theme/index.js +4 -4
- package/dist/theme/timeline.module.css +3 -3
- package/dist/theme-lab/index.js +1 -1
- package/dist/tokens/index.d.ts +25 -16
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +84 -46
- package/dist/tokens.css +102 -51
- package/llms.txt +2 -2
- package/package.json +71 -17
- package/src/agent-chat/composer.tsx +1 -1
- package/src/charts/kinds/Donut.tsx +1 -1
- package/src/charts/theme.tsx +6 -6
- package/src/cli/index.ts +10 -2
- package/src/cli/tokens-css.test.ts +17 -0
- package/src/content/article-card.module.css +1 -1
- package/src/content/callout.module.css +3 -3
- package/src/content/prose.module.css +1 -1
- package/src/content/reading-progress.module.css +2 -2
- package/src/guard/check-source.test.ts +77 -0
- package/src/guard/guard-hook.ts +1 -1
- package/src/guard/index.ts +45 -7
- package/src/guard/types.ts +6 -0
- package/src/theme/contrast.test.ts +23 -5
- package/src/theme/index.ts +5 -5
- package/src/theme/timeline.module.css +3 -3
- package/src/theme-lab/index.tsx +2 -2
- package/src/tokens/index.ts +106 -46
- package/src/tokens/palette.ts +2 -2
|
@@ -194,7 +194,7 @@ function DonutPlot<K extends string = SeriesKey>(props: DonutPlotProps<K>) {
|
|
|
194
194
|
style={{
|
|
195
195
|
position: 'absolute',
|
|
196
196
|
inset: 0,
|
|
197
|
-
display: 'flex',
|
|
197
|
+
display: 'flex', // theme-allow: centering over the donut hole — charts/ is Mantine-free, so Center is unavailable here
|
|
198
198
|
alignItems: 'center',
|
|
199
199
|
justifyContent: 'center',
|
|
200
200
|
pointerEvents: 'none',
|
package/src/charts/theme.tsx
CHANGED
|
@@ -25,12 +25,12 @@ const REFS = {
|
|
|
25
25
|
line: 'var(--vx-line)',
|
|
26
26
|
line2: 'var(--vx-line2)',
|
|
27
27
|
axis: 'var(--vx-axis)',
|
|
28
|
-
axisStroke: 'var(--vx-
|
|
29
|
-
tooltipBg: 'var(--vx-
|
|
30
|
-
tooltipText: 'var(--vx-
|
|
31
|
-
tooltipMuted: 'var(--vx-
|
|
32
|
-
tooltipBorder: 'var(--vx-
|
|
33
|
-
tooltipShadow: 'var(--vx-
|
|
28
|
+
axisStroke: 'var(--vx-axis-stroke)',
|
|
29
|
+
tooltipBg: 'var(--vx-tooltip-bg)',
|
|
30
|
+
tooltipText: 'var(--vx-tooltip-text)',
|
|
31
|
+
tooltipMuted: 'var(--vx-tooltip-muted)',
|
|
32
|
+
tooltipBorder: 'var(--vx-tooltip-border)',
|
|
33
|
+
tooltipShadow: 'var(--vx-tooltip-shadow)',
|
|
34
34
|
} as const
|
|
35
35
|
|
|
36
36
|
const VxThemeContext = createContext<VxTheme | null>(null)
|
package/src/cli/index.ts
CHANGED
|
@@ -419,7 +419,7 @@ export function checkTheme(cwd: string = process.cwd()): number {
|
|
|
419
419
|
for (const [file, vs] of [...byFile].toSorted()) {
|
|
420
420
|
console.error(file)
|
|
421
421
|
for (const v of vs.toSorted((a, b) => a.line - b.line)) {
|
|
422
|
-
console.error(` ${String(v.line).padStart(4)} ${v.kind.padEnd(22)} ${v.
|
|
422
|
+
console.error(` ${String(v.line).padStart(4)} ${v.kind.padEnd(22)} ${v.text}`)
|
|
423
423
|
}
|
|
424
424
|
console.error('')
|
|
425
425
|
}
|
|
@@ -1765,6 +1765,11 @@ export function tokensCss(flags: string[], cwd: string = process.cwd()): number
|
|
|
1765
1765
|
: { defaultScheme: defaultScheme as 'dark' | 'light' | 'none' }),
|
|
1766
1766
|
...(flags.includes('--media-fallback') ? { mediaFallback: true } : {}),
|
|
1767
1767
|
...(only === undefined ? {} : { only: only as 'core' | 'all' }),
|
|
1768
|
+
// The tokens-only consumer is exactly the one who writes these names by hand, so they are also
|
|
1769
|
+
// the one who wants the deprecated camelCase aliases gone — and this command is their only
|
|
1770
|
+
// entry point. Without the flag the CLI and the API could disagree about what basalt's tokens
|
|
1771
|
+
// are, which is the one thing this command is documented never to allow.
|
|
1772
|
+
...(flags.includes('--no-legacy-aliases') ? { legacyAliases: false } : {}),
|
|
1768
1773
|
})
|
|
1769
1774
|
|
|
1770
1775
|
const out = flagValue(flags, '--out')
|
|
@@ -1880,7 +1885,10 @@ const USAGE =
|
|
|
1880
1885
|
'check-theme | check-coverage | info [--json] | doctor | guard-hook | tokens:css | help>\n\n' +
|
|
1881
1886
|
'tokens:css [--out <path>] [--selector-attribute <attr>] [--dark-value <v>] [--light-value <v>]\n' +
|
|
1882
1887
|
' [--default-scheme <dark|light|none>] [--media-fallback] [--only <core|all>]\n' +
|
|
1883
|
-
'
|
|
1888
|
+
' [--no-legacy-aliases]\n' +
|
|
1889
|
+
' Emit the --vx-* stylesheet (stdout unless --out). Defaults reproduce basalt-ui/tokens.css.\n' +
|
|
1890
|
+
' --no-legacy-aliases drops the deprecated camelCase spellings (--vx-accentFill and friends),\n' +
|
|
1891
|
+
' which are emitted by default as aliases of the canonical kebab-case names.\n\n' +
|
|
1884
1892
|
'Every subcommand accepts --help / -h to print this message and exit without running.'
|
|
1885
1893
|
|
|
1886
1894
|
/**
|
|
@@ -73,6 +73,23 @@ describe('tokens:css', () => {
|
|
|
73
73
|
expect(existsSync(resolve(dir, 'out.css'))).toBe(false)
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
+
it('--no-legacy-aliases drops every deprecated camelCase spelling while the canonical kebab names still resolve', () => {
|
|
77
|
+
const css = emit(['--no-legacy-aliases'])
|
|
78
|
+
expect(css).not.toContain('--vx-accentFill')
|
|
79
|
+
expect(css).not.toContain('--vx-tooltipBg')
|
|
80
|
+
expect(css).not.toContain('--vx-fillHover-')
|
|
81
|
+
expect(css).not.toContain('--vx-goodSoft')
|
|
82
|
+
expect(css).not.toContain('Deprecated camelCase aliases')
|
|
83
|
+
expect(css).toContain('--vx-accent-fill:')
|
|
84
|
+
expect(css).toContain('--vx-tooltip-bg:')
|
|
85
|
+
expect(css).toContain('--vx-fill-hover-')
|
|
86
|
+
expect(css).toContain('--vx-good-soft:')
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
it('--no-legacy-aliases output is byte-identical to buildPaletteCss({ legacyAliases: false }) — the CLI holds no emission logic of its own', () => {
|
|
90
|
+
expect(emit(['--no-legacy-aliases'])).toBe(buildPaletteCss({ legacyAliases: false }))
|
|
91
|
+
})
|
|
92
|
+
|
|
76
93
|
it('`--help` short-circuits before the command runs — no file written', () => {
|
|
77
94
|
const originalLog = console.log
|
|
78
95
|
let log = ''
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
.good {
|
|
27
|
-
--callout-ink: var(--vx-
|
|
27
|
+
--callout-ink: var(--vx-good-solid);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.warn {
|
|
31
|
-
--callout-ink: var(--vx-
|
|
31
|
+
--callout-ink: var(--vx-warn-solid);
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
.bad {
|
|
35
|
-
--callout-ink: var(--vx-
|
|
35
|
+
--callout-ink: var(--vx-bad-solid);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
.titleRow {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* ReadingProgress — a fixed 2px top bar. The outer bar stays transparent; `.fill` carries the
|
|
3
|
-
* `--vx-
|
|
3
|
+
* `--vx-accent-fill` band token (the FILL surface, never the ink `--vx-accent` — docs/DESIGN-SPEC.md
|
|
4
4
|
* §7's fill-band rule) and is scaled via `transform: scaleX()` from JS.
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
.fill {
|
|
19
19
|
height: 100%;
|
|
20
20
|
width: 100%;
|
|
21
|
-
background: var(--vx-
|
|
21
|
+
background: var(--vx-accent-fill);
|
|
22
22
|
transform-origin: left;
|
|
23
23
|
will-change: transform;
|
|
24
24
|
}
|
|
@@ -385,6 +385,50 @@ describe('inline-spacing', () => {
|
|
|
385
385
|
})
|
|
386
386
|
})
|
|
387
387
|
|
|
388
|
+
// ── 10b. Finding.text ─────────────────────────────────────────────────────────
|
|
389
|
+
//
|
|
390
|
+
// `token` stays the regex match (e.g. the unit-less numeric part of a spacing declaration);
|
|
391
|
+
// `text` is the full trimmed source line, so a human reading the report sees `padding: 0.75rem;`
|
|
392
|
+
// rather than the confusing partial match `padding: 0.75`.
|
|
393
|
+
|
|
394
|
+
describe('Finding.text', () => {
|
|
395
|
+
it('reports text as the full trimmed source line while token stays the truncated match', () => {
|
|
396
|
+
const f = checkSource(
|
|
397
|
+
'.foo {\n padding: 0.75rem;\n}\n',
|
|
398
|
+
'src/Card.module.css',
|
|
399
|
+
DEFAULT_GUARD_CONFIG,
|
|
400
|
+
)
|
|
401
|
+
const hit = f.find((x) => x.kind === 'inline-spacing')
|
|
402
|
+
expect(hit?.token).toBe('padding: 0.75')
|
|
403
|
+
expect(hit?.text).toBe('padding: 0.75rem;')
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
it('reports the whole declaration including the unit for a CSS padding-left finding', () => {
|
|
407
|
+
const f = checkSource('padding-left: 1.25rem;', 'src/Card.module.css', DEFAULT_GUARD_CONFIG)
|
|
408
|
+
const hit = f.find((x) => x.kind === 'inline-spacing')
|
|
409
|
+
expect(hit?.token).toBe('padding-left: 1.25')
|
|
410
|
+
expect(hit?.text).toBe('padding-left: 1.25rem;')
|
|
411
|
+
})
|
|
412
|
+
|
|
413
|
+
it('truncates a line over 100 characters with a trailing …', () => {
|
|
414
|
+
const filler = 'x'.repeat(200)
|
|
415
|
+
const f = checkSource(
|
|
416
|
+
`padding: 16px; /* ${filler} */`,
|
|
417
|
+
'src/Card.module.css',
|
|
418
|
+
DEFAULT_GUARD_CONFIG,
|
|
419
|
+
)
|
|
420
|
+
const hit = f.find((x) => x.kind === 'inline-spacing')
|
|
421
|
+
expect(hit?.text.length).toBe(101)
|
|
422
|
+
expect(hit?.text.endsWith('…')).toBe(true)
|
|
423
|
+
})
|
|
424
|
+
|
|
425
|
+
it('trims a leading-indented line', () => {
|
|
426
|
+
const f = checkSource(' padding: 16px;', 'src/Card.module.css', DEFAULT_GUARD_CONFIG)
|
|
427
|
+
const hit = f.find((x) => x.kind === 'inline-spacing')
|
|
428
|
+
expect(hit?.text).toBe('padding: 16px;')
|
|
429
|
+
})
|
|
430
|
+
})
|
|
431
|
+
|
|
388
432
|
// ── 11. inline-display ───────────────────────────────────────────────────────
|
|
389
433
|
|
|
390
434
|
describe('inline-display', () => {
|
|
@@ -623,6 +667,39 @@ describe('chart-missing-aria-label', () => {
|
|
|
623
667
|
})
|
|
624
668
|
expect(kinds(f)).not.toContain('chart-missing-aria-label')
|
|
625
669
|
})
|
|
670
|
+
|
|
671
|
+
// ── reported line: the tag's OPENING line, not the end of the match ─────────
|
|
672
|
+
//
|
|
673
|
+
// The scan used to compute its line from the END of the matched tag, so on a multi-line-
|
|
674
|
+
// formatted chart element the reported line was the closing `/>` rather than the `<Bars` line
|
|
675
|
+
// that is actually missing the prop. Invisible while the report only printed `token`; visible
|
|
676
|
+
// the moment `Finding.text` started quoting the reported source line back.
|
|
677
|
+
|
|
678
|
+
it('reports the OPENING tag line (and quotes it in text) for a multi-line-formatted chart element', () => {
|
|
679
|
+
const text = ['<Bars', ' data={points}', ' height={240}', '/>'].join('\n')
|
|
680
|
+
const f = find(text)
|
|
681
|
+
const hit = f.find((x) => x.kind === 'chart-missing-aria-label')
|
|
682
|
+
expect(hit?.line).toBe(1)
|
|
683
|
+
expect(hit?.text).toBe('<Bars')
|
|
684
|
+
})
|
|
685
|
+
|
|
686
|
+
it('reports the same line as before for a single-line chart element (no regression)', () => {
|
|
687
|
+
const f = find(`<ZonedLine data={points} height={240} chartId="x" />`)
|
|
688
|
+
const hit = f.find((x) => x.kind === 'chart-missing-aria-label')
|
|
689
|
+
expect(hit?.line).toBe(1)
|
|
690
|
+
})
|
|
691
|
+
|
|
692
|
+
it('a theme-allow comment on the CLOSING line of a multi-line tag still suppresses the finding (back-compat)', () => {
|
|
693
|
+
const text = ['<Bars', ' data={points}', ' height={240}', '/> // theme-allow'].join('\n')
|
|
694
|
+
const f = find(text)
|
|
695
|
+
expect(kinds(f)).not.toContain('chart-missing-aria-label')
|
|
696
|
+
})
|
|
697
|
+
|
|
698
|
+
it('a theme-allow comment on the OPENING line of a multi-line tag also suppresses the finding', () => {
|
|
699
|
+
const text = ['<Bars // theme-allow', ' data={points}', ' height={240}', '/>'].join('\n')
|
|
700
|
+
const f = find(text)
|
|
701
|
+
expect(kinds(f)).not.toContain('chart-missing-aria-label')
|
|
702
|
+
})
|
|
626
703
|
})
|
|
627
704
|
|
|
628
705
|
// ── 16. card-with-border ─────────────────────────────────────────────────────
|
package/src/guard/guard-hook.ts
CHANGED
|
@@ -115,7 +115,7 @@ export function evaluateGuardHook(
|
|
|
115
115
|
if (findings.length === 0) return { permissionDecision: 'allow' }
|
|
116
116
|
|
|
117
117
|
const shown = findings.slice(0, 10)
|
|
118
|
-
const lines = shown.map((f) => `${f.kind} @ ${f.line}: ${f.
|
|
118
|
+
const lines = shown.map((f) => `${f.kind} @ ${f.line}: ${f.text}`)
|
|
119
119
|
const extra = findings.length > 10 ? ` (+${findings.length - 10} more)` : ''
|
|
120
120
|
const reason =
|
|
121
121
|
`basalt theme-guard: ${findings.length} off-palette/off-system violation(s) in ${target.relPath}\n` +
|
package/src/guard/index.ts
CHANGED
|
@@ -280,6 +280,22 @@ function severityOf(kind: GuardKind, cfg: GuardConfig): GuardSeverity {
|
|
|
280
280
|
return cfg.severity?.[kind] ?? (kind in GRACE_PERIOD_KINDS ? 'warn' : 'error')
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
+
/** The `Finding.text` cap, in characters — a minified CSS line must not blow up the report. */
|
|
284
|
+
const FINDING_TEXT_MAX_LENGTH = 100
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* A finding's `text`: the trimmed source line it sits on, capped at {@link FINDING_TEXT_MAX_LENGTH}
|
|
288
|
+
* with a trailing `…`. Falls back to `fallbackToken` when `line` is out of range for the source
|
|
289
|
+
* (should not happen in practice, but a Finding's own `line` must never crash the render).
|
|
290
|
+
*/
|
|
291
|
+
function textForFinding(sourceLine: string | undefined, fallbackToken: string): string {
|
|
292
|
+
if (sourceLine === undefined) return fallbackToken
|
|
293
|
+
const trimmed = sourceLine.trim()
|
|
294
|
+
return trimmed.length > FINDING_TEXT_MAX_LENGTH
|
|
295
|
+
? `${trimmed.slice(0, FINDING_TEXT_MAX_LENGTH)}…`
|
|
296
|
+
: trimmed
|
|
297
|
+
}
|
|
298
|
+
|
|
283
299
|
// ── Path predicate ────────────────────────────────────────────────────────────────────────────────
|
|
284
300
|
|
|
285
301
|
function isChartFile(relPath: string): boolean {
|
|
@@ -742,9 +758,10 @@ function ruleApplies(kind: GuardKind, relPath: string): boolean {
|
|
|
742
758
|
* if (findings.some((f) => f.kind === 'raw-hex')) { ... }
|
|
743
759
|
*/
|
|
744
760
|
export function checkSource(text: string, relPath: string, cfg: GuardConfig): Finding[] {
|
|
745
|
-
// Severity
|
|
746
|
-
//
|
|
747
|
-
|
|
761
|
+
// Severity and text are stamped once at the end rather than at each of the ~20 push sites — both
|
|
762
|
+
// are derived from state the push sites don't need: severity from the KIND and the config, text
|
|
763
|
+
// from the finding's own `line` against the source split below.
|
|
764
|
+
const findings: Omit<Finding, 'severity' | 'text'>[] = []
|
|
748
765
|
|
|
749
766
|
// Derive the 3 dynamic regexes via GUARD_RULES pattern builders.
|
|
750
767
|
const forbiddenAccentRe = (
|
|
@@ -894,6 +911,11 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
|
|
|
894
911
|
|
|
895
912
|
// chart-missing-aria-label — full-text tag-scoped scan (same shape as unframed-chart above).
|
|
896
913
|
// A tag is a violation only when its own (possibly multi-line) prop list has no `ariaLabel=`.
|
|
914
|
+
// Reports at the tag's OPENING line, like card-with-border below and unlike the end-of-match
|
|
915
|
+
// arithmetic this used to do: on a multi-line-formatted chart the end lands on the closing `/>`,
|
|
916
|
+
// which is what `Finding.text` would then quote back — the closing bracket rather than the tag
|
|
917
|
+
// that is missing the prop. The allow-comment is honored anywhere in the tag's span, so a
|
|
918
|
+
// `theme-allow` that used to sit on the closing line keeps working.
|
|
897
919
|
if (
|
|
898
920
|
GUARD_RULES['chart-missing-aria-label'].enabled!(cfg) &&
|
|
899
921
|
ruleApplies('chart-missing-aria-label', relPath)
|
|
@@ -901,11 +923,19 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
|
|
|
901
923
|
for (const m of codeText.matchAll(CHART_ENTRY_POINT_TAG)) {
|
|
902
924
|
const tagText = m[0]
|
|
903
925
|
if (HAS_ARIA_LABEL_PROP.test(tagText)) continue
|
|
904
|
-
const
|
|
905
|
-
|
|
926
|
+
const startLine = codeText.slice(0, m.index ?? 0).split('\n').length
|
|
927
|
+
const endLine = startLine + (tagText.split('\n').length - 1)
|
|
928
|
+
let skipped = false
|
|
929
|
+
for (let n = startLine; n <= endLine; n++) {
|
|
930
|
+
if (isSkippedLine(lines[n - 1] ?? '', cfg)) {
|
|
931
|
+
skipped = true
|
|
932
|
+
break
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
if (skipped) continue
|
|
906
936
|
findings.push({
|
|
907
937
|
relPath,
|
|
908
|
-
line:
|
|
938
|
+
line: startLine,
|
|
909
939
|
token: tagText.slice(0, 40),
|
|
910
940
|
kind: 'chart-missing-aria-label',
|
|
911
941
|
})
|
|
@@ -957,7 +987,15 @@ export function checkSource(text: string, relPath: string, cfg: GuardConfig): Fi
|
|
|
957
987
|
// Per-rule, per-path exemption post-filter (§exemptRules) — applied once here so it uniformly
|
|
958
988
|
// covers every kind regardless of whether it was emitted via the GUARD_RULES registry loop above
|
|
959
989
|
// or one of the inline-handled kinds (raw-surface, raw-html-layout, sub-16-input-font, …).
|
|
990
|
+
//
|
|
991
|
+
// `text` is stamped here too, in the same single post-pass, off the ORIGINAL (unstripped) `lines`
|
|
992
|
+
// split — never `codeLines` — so a finding on a line whose comment was stripped still reports the
|
|
993
|
+
// real source text a human would read.
|
|
960
994
|
return findings
|
|
961
995
|
.filter((f) => !isRuleExempt(f.kind, f.relPath, cfg.exemptRules))
|
|
962
|
-
.map((f) => ({
|
|
996
|
+
.map((f) => ({
|
|
997
|
+
...f,
|
|
998
|
+
text: textForFinding(lines[f.line - 1], f.token),
|
|
999
|
+
severity: severityOf(f.kind, cfg),
|
|
1000
|
+
}))
|
|
963
1001
|
}
|
package/src/guard/types.ts
CHANGED
|
@@ -56,6 +56,12 @@ export type Finding = {
|
|
|
56
56
|
readonly relPath: string
|
|
57
57
|
readonly line: number
|
|
58
58
|
readonly token: string
|
|
59
|
+
/**
|
|
60
|
+
* The trimmed source line the finding sits on — what a human should read; `token` stays the
|
|
61
|
+
* matched substring for programmatic use. Truncated to 100 characters (with a trailing `…`) so
|
|
62
|
+
* a minified line can't blow up the report.
|
|
63
|
+
*/
|
|
64
|
+
readonly text: string
|
|
59
65
|
readonly kind: GuardKind
|
|
60
66
|
/** Resolved per kind from {@link GuardConfig.severity} over the shipped default. */
|
|
61
67
|
readonly severity: GuardSeverity
|
|
@@ -80,12 +80,30 @@ describe('the accent delegates to the palette, not to a computed guess', () => {
|
|
|
80
80
|
for (const scheme of SCHEMES) {
|
|
81
81
|
test(scheme, () => {
|
|
82
82
|
expect(onColorVar(theme.primaryColor, scheme)).toBe(
|
|
83
|
-
`var(--vx-
|
|
83
|
+
`var(--vx-on-accent, ${ACCENT.onAccent[scheme]})`,
|
|
84
84
|
)
|
|
85
85
|
})
|
|
86
86
|
}
|
|
87
87
|
})
|
|
88
88
|
|
|
89
|
+
describe('--vx-on-accent has no collision with the per-color --vx-on-* family', () => {
|
|
90
|
+
// The 1.4.0 kebab-case rename moved the token layer's `--vx-onAccent` to `--vx-on-accent`.
|
|
91
|
+
// `onColorVars` (above) ALSO emits a `--vx-on-{name}` per Mantine color name — but `theme.colors`
|
|
92
|
+
// never registers a color literally named `'accent'` (the primary color is `'blue'`), so that
|
|
93
|
+
// family can never itself produce a `--vx-on-accent` key. The two stay distinct sources, not a
|
|
94
|
+
// merge: `--vx-on-accent` is exclusively the token layer's `ACCENT.onAccent` alias target.
|
|
95
|
+
test('theme.colors has no color named "accent"', () => {
|
|
96
|
+
expect(COLORS).not.toContain('accent')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
for (const scheme of SCHEMES) {
|
|
100
|
+
test(`the resolver's own --vx-on-* map carries no accent key (${scheme})`, () => {
|
|
101
|
+
const vars = cssVariablesResolver(theme)[scheme]
|
|
102
|
+
expect(vars['--vx-on-accent']).toBeUndefined()
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
|
|
89
107
|
describe('every filled surface is legible against its on-color', () => {
|
|
90
108
|
// The floor is structural, not tuned: contrast(bg, white) * contrast(bg, black) is a constant
|
|
91
109
|
// (~17.9 for this black), so always taking the larger of the two cannot drop below ~4.23.
|
|
@@ -211,7 +229,7 @@ describe('the accent is single-sourced: Mantine chrome is bridged to --vx-*', ()
|
|
|
211
229
|
for (const [name, hex] of Object.entries(FILL)) {
|
|
212
230
|
expect(vars[`--mantine-color-${name}-filled`]).toBe(`var(--vx-fill-${name}, ${hex})`)
|
|
213
231
|
expect(vars[`--mantine-color-${name}-filled-hover`]).toContain(
|
|
214
|
-
`var(--vx-
|
|
232
|
+
`var(--vx-fill-hover-${name},`,
|
|
215
233
|
)
|
|
216
234
|
}
|
|
217
235
|
})
|
|
@@ -221,15 +239,15 @@ describe('the accent is single-sourced: Mantine chrome is bridged to --vx-*', ()
|
|
|
221
239
|
// and links; Mantine's chrome drove buttons off a JS hex ramp that pointed at nothing. Overriding
|
|
222
240
|
// `--vx-accent` restyled the charts and left every button untouched. These lock the bridge.
|
|
223
241
|
for (const scheme of SCHEMES) {
|
|
224
|
-
test(`the filled surface resolves through --vx-
|
|
242
|
+
test(`the filled surface resolves through --vx-accent-fill (${scheme})`, () => {
|
|
225
243
|
const vars = cssVariablesResolver(theme)[scheme]
|
|
226
244
|
// `getThemeColor()` resolves any plain theme color to `-filled`, so this ONE var reaches the
|
|
227
245
|
// variant resolver AND every component that fills from its own varsResolver.
|
|
228
246
|
expect(vars[`--mantine-color-${theme.primaryColor}-filled`]).toBe(
|
|
229
|
-
`var(--vx-
|
|
247
|
+
`var(--vx-accent-fill, ${ACCENT.accentFill[scheme]})`,
|
|
230
248
|
)
|
|
231
249
|
expect(vars[`--mantine-color-${theme.primaryColor}-filled-hover`]).toBe(
|
|
232
|
-
`var(--vx-
|
|
250
|
+
`var(--vx-accent-fill-hover, ${ACCENT.accentFillHover[scheme]})`,
|
|
233
251
|
)
|
|
234
252
|
})
|
|
235
253
|
|
package/src/theme/index.ts
CHANGED
|
@@ -226,7 +226,7 @@ function buildDarkTuple(data: PaletteData): MantineColorsTuple {
|
|
|
226
226
|
* consumer that retunes a family outside the band still gets the legible foreground.
|
|
227
227
|
*
|
|
228
228
|
* The palette already KNEW the answer: `ACCENT.onAccent` ("text on an accent fill") existed, and
|
|
229
|
-
* `Composer`'s send button hand-wired `color: var(--vx-
|
|
229
|
+
* `Composer`'s send button hand-wired `color: var(--vx-on-accent)` — which was the ONLY reason that
|
|
230
230
|
* one control stayed legible while every generic Mantine control did not. The token was right;
|
|
231
231
|
* nothing bound the chrome to it. It is bound now (see `accentBridge` / `familyBridge`), and the
|
|
232
232
|
* Composer no longer needs the override.
|
|
@@ -304,7 +304,7 @@ function onColorVars(
|
|
|
304
304
|
// chrome with it. Everything else is a generic surface with no declared foreground: measure it.
|
|
305
305
|
vars[`--vx-on-${name}`] =
|
|
306
306
|
name === theme.primaryColor
|
|
307
|
-
? `var(--vx-
|
|
307
|
+
? `var(--vx-on-accent, ${data.ACCENT.onAccent[colorScheme]})`
|
|
308
308
|
: legibleOn(filled, theme)
|
|
309
309
|
}
|
|
310
310
|
return vars
|
|
@@ -1044,8 +1044,8 @@ function accentBridge(
|
|
|
1044
1044
|
const c = theme.primaryColor
|
|
1045
1045
|
const { ACCENT } = data
|
|
1046
1046
|
return {
|
|
1047
|
-
[`--mantine-color-${c}-filled`]: `var(--vx-
|
|
1048
|
-
[`--mantine-color-${c}-filled-hover`]: `var(--vx-
|
|
1047
|
+
[`--mantine-color-${c}-filled`]: `var(--vx-accent-fill, ${ACCENT.accentFill[side]})`,
|
|
1048
|
+
[`--mantine-color-${c}-filled-hover`]: `var(--vx-accent-fill-hover, ${ACCENT.accentFillHover[side]})`,
|
|
1049
1049
|
[`--mantine-color-${c}-text`]: `var(--vx-accent, ${ACCENT.accent[side]})`,
|
|
1050
1050
|
[`--mantine-color-${c}-outline`]: `var(--vx-accent, ${ACCENT.accent[side]})`,
|
|
1051
1051
|
[`--mantine-color-${c}-light-color`]: `var(--vx-accent, ${ACCENT.accent[side]})`,
|
|
@@ -1068,7 +1068,7 @@ function familyBridge(data: PaletteData): Record<string, string> {
|
|
|
1068
1068
|
for (const [name, hex] of Object.entries(data.FILL)) {
|
|
1069
1069
|
vars[`--mantine-color-${name}-filled`] = `var(--vx-fill-${name}, ${hex})`
|
|
1070
1070
|
vars[`--mantine-color-${name}-filled-hover`] =
|
|
1071
|
-
`var(--vx-
|
|
1071
|
+
`var(--vx-fill-hover-${name}, color-mix(in srgb, ${hex} 88%, #000))`
|
|
1072
1072
|
}
|
|
1073
1073
|
return vars
|
|
1074
1074
|
}
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* whether the bullet carries child content (Mantine's own `[data-active]` rule only fills solid
|
|
24
24
|
* when a bullet child is present; a plain dot would otherwise render a white fill). */
|
|
25
25
|
.itemBullet[data-active] {
|
|
26
|
-
background-color: var(--vx-
|
|
27
|
-
border-color: var(--vx-
|
|
28
|
-
color: var(--vx-
|
|
26
|
+
background-color: var(--vx-accent-fill);
|
|
27
|
+
border-color: var(--vx-accent-fill);
|
|
28
|
+
color: var(--vx-on-accent);
|
|
29
29
|
}
|
package/src/theme-lab/index.tsx
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* a refresh.
|
|
9
9
|
*
|
|
10
10
|
* The chrome follows because `theme/index.ts` bridges Mantine's surface vars AND its primary-color
|
|
11
|
-
* vars onto these same tokens — retuning `--vx-
|
|
11
|
+
* vars onto these same tokens — retuning `--vx-accent-fill` restyles every Button/Switch/Checkbox
|
|
12
12
|
* live. (It did NOT before: the accent was dual-sourced, so the lab moved the charts and left the
|
|
13
13
|
* chrome alone.) Known limit: only the PRIMARY Mantine color is bridged. A `color="red"` filled
|
|
14
14
|
* badge still reads Mantine's JS ramp and will not follow a lab override.
|
|
@@ -87,7 +87,7 @@ export const COLOR_GROUPS: ColorGroup[] = [
|
|
|
87
87
|
items: [
|
|
88
88
|
{ var: '--vx-line', label: 'Line' },
|
|
89
89
|
{ var: '--vx-line2', label: 'Line 2' },
|
|
90
|
-
{ var: '--vx-
|
|
90
|
+
{ var: '--vx-dot-stroke', label: 'Dot stroke' },
|
|
91
91
|
],
|
|
92
92
|
},
|
|
93
93
|
{
|