@eluan/theme-generator 0.2.0 → 0.3.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/dist/compile/css.js +1 -0
- package/dist/tokens/contrast.js +5 -1
- package/dist/tokens/semanticMap.js +3 -1
- package/dist/types.d.ts +12 -0
- package/package.json +1 -1
package/dist/compile/css.js
CHANGED
|
@@ -57,6 +57,7 @@ export function compileSemanticJSON(map, primitives) {
|
|
|
57
57
|
role: entry.role,
|
|
58
58
|
...(entry.contrastAgainst ? { contrastAgainst: entry.contrastAgainst } : {}),
|
|
59
59
|
...(entry.minContrast ? { minContrast: entry.minContrast } : {}),
|
|
60
|
+
...(entry.allowBelowDefault ? { allowBelowDefault: true } : {}),
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
return JSON.stringify(doc, null, 2);
|
package/dist/tokens/contrast.js
CHANGED
|
@@ -97,7 +97,11 @@ export function autoCorrect(map, primitives, mode, defaultMinContrast) {
|
|
|
97
97
|
const fgHex = resolveTokenRef(fgRef, primitives);
|
|
98
98
|
if (!bgHex || !fgHex)
|
|
99
99
|
continue;
|
|
100
|
-
|
|
100
|
+
// The config-wide minimum is a floor: per-entry values can raise it but
|
|
101
|
+
// not lower it, except for entries that opt into a lower WCAG tier.
|
|
102
|
+
const minContrast = entry.allowBelowDefault && entry.minContrast !== undefined
|
|
103
|
+
? entry.minContrast
|
|
104
|
+
: Math.max(entry.minContrast ?? 0, defaultMinContrast);
|
|
101
105
|
const ratio = checkContrast(fgHex, bgHex);
|
|
102
106
|
if (ratio >= minContrast)
|
|
103
107
|
continue;
|
|
@@ -23,7 +23,9 @@ export function buildSemanticMap() {
|
|
|
23
23
|
'interactive-border-alt': { light: 'neutral.300', dark: 'neutral.600', role: 'border' },
|
|
24
24
|
'interactive-border-disabled': { light: 'neutral.300', dark: 'neutral.600', role: 'border' },
|
|
25
25
|
'interactive-fg': { light: 'neutral.950', dark: 'neutral.50', role: 'fg', contrastAgainst: 'interactive-bg', minContrast: 4.5 },
|
|
26
|
-
|
|
26
|
+
// Secondary text targets the WCAG 3:1 large-text/UI tier; allowBelowDefault
|
|
27
|
+
// keeps it there even when the config asks for a stricter floor (e.g. AAA).
|
|
28
|
+
'interactive-fg-alt': { light: 'neutral.600', dark: 'neutral.300', role: 'fg', contrastAgainst: 'interactive-bg', minContrast: 3.0, allowBelowDefault: true },
|
|
27
29
|
'interactive-fg-readonly': { light: 'neutral.800', dark: 'neutral.100', role: 'fg', contrastAgainst: 'interactive-bg', minContrast: 4.5 },
|
|
28
30
|
'interactive-fg-disabled': { light: 'neutral.400', dark: 'neutral.500', role: 'fg' },
|
|
29
31
|
'interactive-fg-active': { light: 'primary.100', dark: 'primary.900', role: 'fg', contrastAgainst: 'interactive-bg-active', minContrast: 4.5 },
|
package/dist/types.d.ts
CHANGED
|
@@ -27,12 +27,24 @@ export type SemanticEntry = {
|
|
|
27
27
|
dark: TokenRef;
|
|
28
28
|
contrastAgainst?: string;
|
|
29
29
|
minContrast?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Honor `minContrast` as-is even when it is below the config-wide minimum.
|
|
32
|
+
* For entries that deliberately target a lower WCAG tier (e.g. the 3:1
|
|
33
|
+
* large-text/UI tier for secondary text) and must not be raised by a
|
|
34
|
+
* stricter `GeneratorConfig.minContrast`.
|
|
35
|
+
*/
|
|
36
|
+
allowBelowDefault?: boolean;
|
|
30
37
|
role: SemanticRole;
|
|
31
38
|
};
|
|
32
39
|
export type SemanticMap = Record<string, SemanticEntry>;
|
|
33
40
|
export type GeneratorConfig = {
|
|
34
41
|
accents: string[];
|
|
35
42
|
themeName: string;
|
|
43
|
+
/**
|
|
44
|
+
* Contrast floor for every checked fg/border pairing (4.5 = WCAG AA,
|
|
45
|
+
* 7 = AAA). Per-entry `minContrast` values can raise the floor for a token
|
|
46
|
+
* but never lower it, unless the entry sets `allowBelowDefault`.
|
|
47
|
+
*/
|
|
36
48
|
minContrast: number;
|
|
37
49
|
neutralTintRatio: number;
|
|
38
50
|
curve?: ScaleStep[];
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eluan/theme-generator",
|
|
3
3
|
"description": "CLI and browser-safe library that generates accessible, light + dark mode Eluan theme token sets from accent colors",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frolda",
|
|
7
7
|
"homepage": "https://github.com/vasfio/eluan#readme",
|