@eluan/theme-generator 0.2.0 → 0.3.1

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.
@@ -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);
@@ -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
- const minContrast = entry.minContrast ?? defaultMinContrast;
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;
@@ -10,6 +10,9 @@ export function buildSemanticMap() {
10
10
  'container-fg': { light: 'neutral.950', dark: 'neutral.50', role: 'fg', contrastAgainst: 'container-bg', minContrast: 4.5 },
11
11
  'container-fg-alt': { light: 'neutral.800', dark: 'neutral.100', role: 'fg', contrastAgainst: 'container-bg', minContrast: 4.5 },
12
12
  'container-fg-inverse': { light: 'neutral.50', dark: 'neutral.950', role: 'fg', contrastAgainst: 'container-bg-inverse', minContrast: 4.5 },
13
+ // Tooltip surface — matches container-bg in light and container-border in
14
+ // dark, so the tooltip's border disappears against its own background.
15
+ 'tooltip-bg': { light: 'neutral.50', dark: 'neutral.700', role: 'bg' },
13
16
  // ── Interactive ────────────────────────────────────────────
14
17
  'interactive-bg': { light: 'neutral.50', dark: 'neutral.800', role: 'bg' },
15
18
  'interactive-bg-alt': { light: 'neutral.100', dark: 'neutral.900', role: 'bg' },
@@ -23,7 +26,9 @@ export function buildSemanticMap() {
23
26
  'interactive-border-alt': { light: 'neutral.300', dark: 'neutral.600', role: 'border' },
24
27
  'interactive-border-disabled': { light: 'neutral.300', dark: 'neutral.600', role: 'border' },
25
28
  'interactive-fg': { light: 'neutral.950', dark: 'neutral.50', role: 'fg', contrastAgainst: 'interactive-bg', minContrast: 4.5 },
26
- 'interactive-fg-alt': { light: 'neutral.600', dark: 'neutral.300', role: 'fg', contrastAgainst: 'interactive-bg', minContrast: 3.0 },
29
+ // Secondary text targets the WCAG 3:1 large-text/UI tier; allowBelowDefault
30
+ // keeps it there even when the config asks for a stricter floor (e.g. AAA).
31
+ 'interactive-fg-alt': { light: 'neutral.600', dark: 'neutral.300', role: 'fg', contrastAgainst: 'interactive-bg', minContrast: 3.0, allowBelowDefault: true },
27
32
  'interactive-fg-readonly': { light: 'neutral.800', dark: 'neutral.100', role: 'fg', contrastAgainst: 'interactive-bg', minContrast: 4.5 },
28
33
  'interactive-fg-disabled': { light: 'neutral.400', dark: 'neutral.500', role: 'fg' },
29
34
  '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.2.0",
4
+ "version": "0.3.1",
5
5
  "license": "MIT",
6
6
  "author": "Frolda",
7
7
  "homepage": "https://github.com/vasfio/eluan#readme",
@@ -53,9 +53,9 @@
53
53
  },
54
54
  "devDependencies": {
55
55
  "@types/prompts": "^2.4.9",
56
- "esbuild": "^0.27.7",
56
+ "esbuild": "^0.28.1",
57
57
  "typescript": "^5.4.5",
58
- "vitest": "^2.0.0"
58
+ "vitest": "^3.2.6"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "rm -rf dist && tsc -p tsconfig.build.json",