@multiplatform.one/theme 9.1.0 → 9.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/README.md +23 -0
- package/dist/cjs/index.gnome.cjs +9 -0
- package/dist/cjs/index.gnome.native.js +9 -0
- package/dist/cjs/index.gnome.native.js.map +1 -1
- package/dist/cjs/menuRow.cjs +4 -0
- package/dist/cjs/menuRow.native.js +4 -0
- package/dist/cjs/menuRow.native.js.map +1 -1
- package/dist/cjs/theme/accentHue.cjs +71 -0
- package/dist/cjs/theme/accentHue.native.js +82 -0
- package/dist/cjs/theme/accentHue.native.js.map +1 -0
- package/dist/cjs/theme/chartPalette.cjs +50 -29
- package/dist/cjs/theme/chartPalette.native.js +60 -33
- package/dist/cjs/theme/chartPalette.native.js.map +1 -1
- package/dist/cjs/theme/createDefaultThemeConfig.cjs +14 -1
- package/dist/cjs/theme/createDefaultThemeConfig.native.js +14 -1
- package/dist/cjs/theme/createDefaultThemeConfig.native.js.map +1 -1
- package/dist/cjs/theme/createThemes.cjs +84 -40
- package/dist/cjs/theme/createThemes.native.js +112 -39
- package/dist/cjs/theme/createThemes.native.js.map +1 -1
- package/dist/cjs/theme/defaults/builderOptions.cjs +30 -5
- package/dist/cjs/theme/defaults/builderOptions.native.js +34 -6
- package/dist/cjs/theme/defaults/builderOptions.native.js.map +1 -1
- package/dist/cjs/theme/index.cjs +1 -0
- package/dist/cjs/theme/index.native.js +1 -0
- package/dist/cjs/theme/index.native.js.map +1 -1
- package/dist/cjs/theme/overlaySurfaces.cjs +53 -4
- package/dist/cjs/theme/overlaySurfaces.native.js +53 -4
- package/dist/cjs/theme/overlaySurfaces.native.js.map +1 -1
- package/dist/cjs/theme/pageGutter.cjs +27 -2
- package/dist/cjs/theme/pageGutter.native.js +52 -2
- package/dist/cjs/theme/pageGutter.native.js.map +1 -1
- package/dist/cjs/theme/resolveKnobs.cjs +12 -0
- package/dist/cjs/theme/resolveKnobs.native.js +12 -0
- package/dist/cjs/theme/resolveKnobs.native.js.map +1 -1
- package/dist/cjs/theme/tintHues.cjs +8 -2
- package/dist/cjs/theme/tintHues.native.js +7 -1
- package/dist/cjs/theme/tintHues.native.js.map +1 -1
- package/dist/cjs/theme/v3TokenRoles.cjs +2 -2
- package/dist/cjs/theme/v3TokenRoles.native.js +2 -2
- package/dist/cjs/theme/v3TokenRoles.native.js.map +1 -1
- package/dist/esm/index.gnome.mjs +4 -4
- package/dist/esm/index.gnome.mjs.map +1 -1
- package/dist/esm/index.gnome.native.js +4 -4
- package/dist/esm/index.gnome.native.js.map +1 -1
- package/dist/esm/menuRow.mjs +4 -1
- package/dist/esm/menuRow.mjs.map +1 -1
- package/dist/esm/menuRow.native.js +4 -1
- package/dist/esm/menuRow.native.js.map +1 -1
- package/dist/esm/theme/accentHue.mjs +42 -0
- package/dist/esm/theme/accentHue.mjs.map +1 -0
- package/dist/esm/theme/accentHue.native.js +50 -0
- package/dist/esm/theme/accentHue.native.js.map +1 -0
- package/dist/esm/theme/chartPalette.mjs +51 -30
- package/dist/esm/theme/chartPalette.mjs.map +1 -1
- package/dist/esm/theme/chartPalette.native.js +61 -34
- package/dist/esm/theme/chartPalette.native.js.map +1 -1
- package/dist/esm/theme/createDefaultThemeConfig.mjs +14 -1
- package/dist/esm/theme/createDefaultThemeConfig.mjs.map +1 -1
- package/dist/esm/theme/createDefaultThemeConfig.native.js +14 -1
- package/dist/esm/theme/createDefaultThemeConfig.native.js.map +1 -1
- package/dist/esm/theme/createThemes.mjs +85 -42
- package/dist/esm/theme/createThemes.mjs.map +1 -1
- package/dist/esm/theme/createThemes.native.js +113 -41
- package/dist/esm/theme/createThemes.native.js.map +1 -1
- package/dist/esm/theme/defaults/builderOptions.mjs +31 -6
- package/dist/esm/theme/defaults/builderOptions.mjs.map +1 -1
- package/dist/esm/theme/defaults/builderOptions.native.js +35 -7
- package/dist/esm/theme/defaults/builderOptions.native.js.map +1 -1
- package/dist/esm/theme/index.mjs +1 -0
- package/dist/esm/theme/index.mjs.map +1 -1
- package/dist/esm/theme/index.native.js +1 -0
- package/dist/esm/theme/index.native.js.map +1 -1
- package/dist/esm/theme/overlaySurfaces.mjs +47 -4
- package/dist/esm/theme/overlaySurfaces.mjs.map +1 -1
- package/dist/esm/theme/overlaySurfaces.native.js +47 -4
- package/dist/esm/theme/overlaySurfaces.native.js.map +1 -1
- package/dist/esm/theme/pageGutter.mjs +27 -4
- package/dist/esm/theme/pageGutter.mjs.map +1 -1
- package/dist/esm/theme/pageGutter.native.js +52 -4
- package/dist/esm/theme/pageGutter.native.js.map +1 -1
- package/dist/esm/theme/resolveKnobs.mjs +12 -0
- package/dist/esm/theme/resolveKnobs.mjs.map +1 -1
- package/dist/esm/theme/resolveKnobs.native.js +12 -0
- package/dist/esm/theme/resolveKnobs.native.js.map +1 -1
- package/dist/esm/theme/tintHues.mjs +6 -1
- package/dist/esm/theme/tintHues.mjs.map +1 -1
- package/dist/esm/theme/tintHues.native.js +6 -1
- package/dist/esm/theme/tintHues.native.js.map +1 -1
- package/dist/esm/theme/v3TokenRoles.mjs +2 -2
- package/dist/esm/theme/v3TokenRoles.native.js +2 -2
- package/package.json +5 -5
- package/src/figma/figmaTokens.spec.ts +2 -2
- package/src/index.gnome.ts +9 -0
- package/src/menuRow.palette.spec.ts +26 -1
- package/src/menuRow.spec.ts +17 -1
- package/src/menuRow.ts +12 -0
- package/src/theme/accentHue.spec.ts +252 -0
- package/src/theme/accentHue.ts +73 -0
- package/src/theme/chartCategoricalSeverity.spec.ts +190 -0
- package/src/theme/chartPalette.spec.ts +37 -34
- package/src/theme/chartPalette.ts +90 -39
- package/src/theme/colorRules.spec.ts +3 -3
- package/src/theme/createDefaultThemeConfig.spec.ts +71 -2
- package/src/theme/createDefaultThemeConfig.ts +47 -5
- package/src/theme/createThemes.ts +167 -59
- package/src/theme/defaults/builderOptions.ts +41 -9
- package/src/theme/defaults/secondaryInk.spec.ts +71 -0
- package/src/theme/index.ts +1 -0
- package/src/theme/intentFill.spec.ts +8 -3
- package/src/theme/overlaySurfaces.tsx +75 -6
- package/src/theme/pageGutter.spec.tsx +2 -2
- package/src/theme/pageGutter.tsx +55 -2
- package/src/theme/rampRoles.spec.ts +60 -0
- package/src/theme/recipes.ts +2 -0
- package/src/theme/resolveKnobs.spec.ts +17 -0
- package/src/theme/resolveKnobs.ts +12 -0
- package/src/theme/severityChannel.spec.ts +202 -0
- package/src/theme/sheetHandle.spec.ts +54 -0
- package/src/theme/tintHues.ts +10 -0
- package/src/theme/v3TokenRoles.ts +2 -2
- package/types/index.gnome.d.ts +3 -3
- package/types/index.gnome.d.ts.map +1 -1
- package/types/menuRow.d.ts +9 -0
- package/types/menuRow.d.ts.map +1 -1
- package/types/theme/accentHue.d.ts +20 -0
- package/types/theme/accentHue.d.ts.map +1 -0
- package/types/theme/chartPalette.d.ts +2 -2
- package/types/theme/chartPalette.d.ts.map +1 -1
- package/types/theme/createDefaultThemeConfig.d.ts +12 -10
- package/types/theme/createDefaultThemeConfig.d.ts.map +1 -1
- package/types/theme/createThemes.d.ts +17 -2
- package/types/theme/createThemes.d.ts.map +1 -1
- package/types/theme/defaults/builderOptions.d.ts.map +1 -1
- package/types/theme/index.d.ts +1 -0
- package/types/theme/index.d.ts.map +1 -1
- package/types/theme/overlaySurfaces.d.ts +61 -3
- package/types/theme/overlaySurfaces.d.ts.map +1 -1
- package/types/theme/pageGutter.d.ts +26 -1
- package/types/theme/pageGutter.d.ts.map +1 -1
- package/types/theme/recipes.d.ts +4 -0
- package/types/theme/recipes.d.ts.map +1 -1
- package/types/theme/resolveKnobs.d.ts.map +1 -1
- package/types/theme/tintHues.d.ts +5 -0
- package/types/theme/tintHues.d.ts.map +1 -1
- package/types/theme/v3TokenRoles.d.ts +2 -2
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FZ-11155, LC-172 accent-hue amendment. `accentHue` names the colour theme
|
|
3
|
+
* the scheme root's accent comes from, the way macOS's accent colour setting
|
|
4
|
+
* tints controls and selection over grey window chrome. The root keeps the
|
|
5
|
+
* app's own base palette and getTheme tokens; only the accent, fill, selected
|
|
6
|
+
* pair, identity ink, focus ring and the `theme="accent"` solid move. The hue
|
|
7
|
+
* must clear LC-288's 30° from every severity.
|
|
8
|
+
*/
|
|
9
|
+
import { describe, expect, it, vi } from "vitest";
|
|
10
|
+
|
|
11
|
+
vi.mock("tamagui", () => ({
|
|
12
|
+
createTamagui: vi.fn((config: Record<string, unknown>) => config),
|
|
13
|
+
}));
|
|
14
|
+
vi.mock("./animations/index", () => ({ animations: {} }));
|
|
15
|
+
|
|
16
|
+
import { accentHues, assertAccentHueClearsSeverities, severityHueDistances } from "./accentHue";
|
|
17
|
+
import {
|
|
18
|
+
aaTextContrastRatio,
|
|
19
|
+
contrastRatio,
|
|
20
|
+
normalizeToHex,
|
|
21
|
+
relativeLuminance,
|
|
22
|
+
} from "./colorRules";
|
|
23
|
+
import { createDefaultThemeConfig } from "./createDefaultThemeConfig";
|
|
24
|
+
import { resolveAllThemes } from "./dedupeInherited";
|
|
25
|
+
import { defaultBaseTheme } from "./defaults/base";
|
|
26
|
+
import { apcaContrast, fillLabelLcFloor } from "./fillContrast";
|
|
27
|
+
import {
|
|
28
|
+
boldPreset,
|
|
29
|
+
consolePreset,
|
|
30
|
+
defaultPreset,
|
|
31
|
+
densePreset,
|
|
32
|
+
heroPreset,
|
|
33
|
+
roomyPreset,
|
|
34
|
+
storefrontPreset,
|
|
35
|
+
} from "./presets";
|
|
36
|
+
import { themeRampColor } from "./ramps";
|
|
37
|
+
|
|
38
|
+
type Resolved = Record<string, Record<string, unknown> | undefined>;
|
|
39
|
+
|
|
40
|
+
const schemes = ["light", "dark"] as const;
|
|
41
|
+
|
|
42
|
+
const appInk = { light: "#6e6e73", dark: "#8e8e93" } as const;
|
|
43
|
+
|
|
44
|
+
const appBase = {
|
|
45
|
+
lightPalette: [...defaultBaseTheme.lightPalette],
|
|
46
|
+
darkPalette: [...defaultBaseTheme.darkPalette],
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
function appGetTheme({ name, scheme }: { name: string; scheme?: "light" | "dark" }) {
|
|
50
|
+
return name === "light" || name === "dark" ? { textMuted: appInk[scheme ?? "light"] } : {};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function build(accentHue?: (typeof accentHues)[number]): Resolved {
|
|
54
|
+
const config = createDefaultThemeConfig({
|
|
55
|
+
base: appBase,
|
|
56
|
+
builderOptions: { getTheme: appGetTheme },
|
|
57
|
+
...(accentHue ? { accentHue } : {}),
|
|
58
|
+
} as Parameters<typeof createDefaultThemeConfig>[0]);
|
|
59
|
+
return resolveAllThemes(
|
|
60
|
+
config.tamagui.themes as unknown as Record<string, Record<string, unknown>>,
|
|
61
|
+
) as Resolved;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function hex(resolved: Resolved, theme: string, key: string): string {
|
|
65
|
+
const raw = resolved[theme]?.[key];
|
|
66
|
+
const value = typeof raw === "object" && raw !== null ? (raw as { val?: unknown }).val : raw;
|
|
67
|
+
const parsed = typeof value === "string" ? normalizeToHex(value) : null;
|
|
68
|
+
if (!parsed) throw new Error(`${theme} has no opaque ${key}: ${String(value)}`);
|
|
69
|
+
return parsed;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function rampSteps(hue: string, scheme: "light" | "dark"): string[] {
|
|
73
|
+
return Array.from({ length: 12 }, (_, index) =>
|
|
74
|
+
normalizeToHex(themeRampColor(hue as "blue", (index + 1) as 1, scheme)),
|
|
75
|
+
) as string[];
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function inHue(color: string, hue: string, scheme: "light" | "dark"): boolean {
|
|
79
|
+
const nine = themeRampColor(hue as "blue", 9, scheme);
|
|
80
|
+
const [distance] = severityHueDistances(color, [nine]);
|
|
81
|
+
return (distance as number) <= 20;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function ratio(a: string, b: string): number {
|
|
85
|
+
return contrastRatio(relativeLuminance(a), relativeLuminance(b));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const presets = {
|
|
89
|
+
default: defaultPreset,
|
|
90
|
+
hero: heroPreset,
|
|
91
|
+
bold: boldPreset,
|
|
92
|
+
dense: densePreset,
|
|
93
|
+
roomy: roomyPreset,
|
|
94
|
+
console: consolePreset,
|
|
95
|
+
storefront: storefrontPreset,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const stock = build();
|
|
99
|
+
|
|
100
|
+
describe("FZ-11155: accentHue moves the root's accent and keeps the app's ground", () => {
|
|
101
|
+
it("offers the colour themes that clear LC-288 and refuses the rest", () => {
|
|
102
|
+
expect([...accentHues]).toEqual(["blue", "purple", "pink"]);
|
|
103
|
+
for (const hue of ["red", "orange", "yellow", "green"]) {
|
|
104
|
+
expect(() =>
|
|
105
|
+
createDefaultThemeConfig({ accentHue: hue } as unknown as Parameters<
|
|
106
|
+
typeof createDefaultThemeConfig
|
|
107
|
+
>[0]),
|
|
108
|
+
).toThrow(/LC-288/);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("lists exactly the colour themes whose step 9 clears every severity by 30°", () => {
|
|
113
|
+
for (const hue of ["blue", "red", "green", "yellow", "orange", "pink", "purple"]) {
|
|
114
|
+
const clears = schemes.every((scheme) =>
|
|
115
|
+
severityHueDistances(
|
|
116
|
+
hex(stock, `${scheme}_${hue}`, "accentBackground"),
|
|
117
|
+
["error", "warning", "success"].map((severity) =>
|
|
118
|
+
hex(stock, `${scheme}_${severity}`, "color9"),
|
|
119
|
+
),
|
|
120
|
+
).every((distance) => distance >= 30),
|
|
121
|
+
);
|
|
122
|
+
expect(clears, hue).toBe((accentHues as readonly string[]).includes(hue));
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("re-measures the built root against the severities and throws under 30°", () => {
|
|
127
|
+
const themes = createDefaultThemeConfig({ accentHue: "purple" }).tamagui
|
|
128
|
+
.themes as unknown as Record<string, Record<string, unknown>>;
|
|
129
|
+
expect(() => assertAccentHueClearsSeverities(themes, "purple")).not.toThrow();
|
|
130
|
+
const red = { ...themes, dark: { ...themes.dark, accent9: themeRampColor("red", 9, "dark") } };
|
|
131
|
+
expect(() => assertAccentHueClearsSeverities(red, "purple")).toThrow(/LC-288.*dark error/);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("refuses an accent palette beside accentHue, since one overrides the other", () => {
|
|
135
|
+
expect(() =>
|
|
136
|
+
createDefaultThemeConfig({
|
|
137
|
+
accentHue: "purple",
|
|
138
|
+
accent: appBase,
|
|
139
|
+
} as Parameters<typeof createDefaultThemeConfig>[0]),
|
|
140
|
+
).toThrow(/accentHue/);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
for (const accentHue of accentHues) {
|
|
144
|
+
const resolved = build(accentHue);
|
|
145
|
+
|
|
146
|
+
describe(accentHue, () => {
|
|
147
|
+
for (const scheme of schemes) {
|
|
148
|
+
it(`${scheme}: the selected pair comes from the ${accentHue} ramp`, () => {
|
|
149
|
+
const ramp = rampSteps(accentHue, scheme);
|
|
150
|
+
expect(ramp).toContain(hex(resolved, scheme, "selectedBackground"));
|
|
151
|
+
const selectedInk = hex(resolved, scheme, "selectedColor");
|
|
152
|
+
expect(inHue(selectedInk, accentHue, scheme), `selectedColor ${selectedInk}`).toBe(true);
|
|
153
|
+
expect(ramp).toContain(hex(resolved, scheme, "accent9"));
|
|
154
|
+
for (const key of ["accentBackground", "accentColor"]) {
|
|
155
|
+
const value = hex(resolved, scheme, key);
|
|
156
|
+
expect(inHue(value, accentHue, scheme), `${key} ${value}`).toBe(true);
|
|
157
|
+
}
|
|
158
|
+
expect(hex(resolved, `${scheme}_accent`, "background")).toBe(
|
|
159
|
+
hex(resolved, `${scheme}_${accentHue}_accent`, "background"),
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it(`${scheme}: $color1 through $color6 and the page stay the app's own greys`, () => {
|
|
164
|
+
for (const key of [
|
|
165
|
+
"background",
|
|
166
|
+
"color1",
|
|
167
|
+
"color2",
|
|
168
|
+
"color3",
|
|
169
|
+
"color4",
|
|
170
|
+
"color5",
|
|
171
|
+
"color6",
|
|
172
|
+
]) {
|
|
173
|
+
expect(hex(resolved, scheme, key), key).toBe(hex(stock, scheme, key));
|
|
174
|
+
}
|
|
175
|
+
for (const component of ["Card", "ListItem", "Input", "Button"]) {
|
|
176
|
+
const theme = `${scheme}_${component}`;
|
|
177
|
+
for (const key of ["background", "borderColor"]) {
|
|
178
|
+
if (resolved[theme]?.[key] === undefined) continue;
|
|
179
|
+
expect(hex(resolved, theme, key), `${theme} ${key}`).toBe(hex(stock, theme, key));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it(`${scheme}: the app's getTheme textMuted survives`, () => {
|
|
185
|
+
expect(hex(resolved, scheme, "textMuted")).toBe(appInk[scheme]);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it(`${scheme}: the selected tint stands off the page and card as the house blue does, its ink reads on it`, () => {
|
|
189
|
+
const tint = hex(resolved, scheme, "selectedBackground");
|
|
190
|
+
const houseTint = hex(stock, scheme, "selectedBackground");
|
|
191
|
+
for (const ground of ["color1", "color4"]) {
|
|
192
|
+
expect(ratio(tint, hex(resolved, scheme, ground)), ground).toBeGreaterThanOrEqual(
|
|
193
|
+
Math.min(1.1, ratio(houseTint, hex(stock, scheme, ground))),
|
|
194
|
+
);
|
|
195
|
+
}
|
|
196
|
+
expect(ratio(hex(resolved, scheme, "selectedColor"), tint)).toBeGreaterThanOrEqual(
|
|
197
|
+
aaTextContrastRatio,
|
|
198
|
+
);
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it(`${scheme}: identity ink and the focus ring follow the hue`, () => {
|
|
202
|
+
for (const key of ["identityInk", "outlineColor", "accentOnSurface"]) {
|
|
203
|
+
const value = hex(resolved, scheme, key);
|
|
204
|
+
expect(inHue(value, accentHue, scheme), `${key} ${value}`).toBe(true);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
for (const [name, preset] of Object.entries(presets)) {
|
|
209
|
+
const scope = preset.theme ? `${scheme}_${preset.theme}` : scheme;
|
|
210
|
+
|
|
211
|
+
it(`${scheme} ${name}: the accent Button's label clears WCAG 4.5 and APCA Lc 60`, () => {
|
|
212
|
+
for (const theme of [`${scheme}_accent_Button`, `${scheme}_accent`]) {
|
|
213
|
+
const named = preset.theme ? theme.replace(scheme, scope) : theme;
|
|
214
|
+
const target = named in resolved ? named : theme;
|
|
215
|
+
const fill = hex(resolved, target, "background");
|
|
216
|
+
const label = hex(resolved, target, "color");
|
|
217
|
+
expect(ratio(label, fill), `${target}`).toBeGreaterThanOrEqual(aaTextContrastRatio);
|
|
218
|
+
expect(Math.abs(apcaContrast(label, fill)), `${target}`).toBeGreaterThanOrEqual(
|
|
219
|
+
Math.max(60, fillLabelLcFloor),
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it(`${scheme} ${name}: the accent sits 30° or more from every severity (LC-288)`, () => {
|
|
225
|
+
const accent = hex(resolved, scope, "accentBackground");
|
|
226
|
+
const distances = severityHueDistances(
|
|
227
|
+
accent,
|
|
228
|
+
["error", "warning", "success"].map((severity) =>
|
|
229
|
+
hex(resolved, `${scheme}_${severity}`, "color9"),
|
|
230
|
+
),
|
|
231
|
+
);
|
|
232
|
+
for (const distance of distances) expect(distance).toBeGreaterThanOrEqual(30);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
it("leaves the default build blue when accentHue is unset or blue", () => {
|
|
240
|
+
const blue = build("blue");
|
|
241
|
+
for (const scheme of schemes) {
|
|
242
|
+
for (const key of [
|
|
243
|
+
"accentBackground",
|
|
244
|
+
"accentColor",
|
|
245
|
+
"selectedBackground",
|
|
246
|
+
"selectedColor",
|
|
247
|
+
]) {
|
|
248
|
+
expect(hex(blue, scheme, key), `${scheme} ${key}`).toBe(hex(stock, scheme, key));
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { oklab } from "./fillContrast";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* FZ-11155, LC-172. The colour themes an app may name as its accent with
|
|
5
|
+
* `createDefaultThemeConfig({ accentHue })`: every hue with a colour-theme
|
|
6
|
+
* scope whose step 9 clears LC-288 SEVERITY-CHANNEL's 30° of OKLCH hue from
|
|
7
|
+
* error, warning and success in both schemes. Red, orange, yellow and green
|
|
8
|
+
* are a severity's own scale or its neighbour, so they never qualify.
|
|
9
|
+
*/
|
|
10
|
+
export const accentHues = ["blue", "purple", "pink"] as const;
|
|
11
|
+
|
|
12
|
+
export type AccentHue = (typeof accentHues)[number];
|
|
13
|
+
|
|
14
|
+
export const severityMinHueDistance = 30;
|
|
15
|
+
|
|
16
|
+
export function isAccentHue(value: unknown): value is AccentHue {
|
|
17
|
+
return typeof value === "string" && (accentHues as readonly string[]).includes(value);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function oklchHue(color: string): number | null {
|
|
21
|
+
const lab = oklab(color);
|
|
22
|
+
if (!lab) return null;
|
|
23
|
+
return ((Math.atan2(lab[2], lab[1]) * 180) / Math.PI + 360) % 360;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** OKLCH hue distance, in degrees, from `accent` to each of `severities`. */
|
|
27
|
+
export function severityHueDistances(accent: string, severities: string[]): number[] {
|
|
28
|
+
const from = oklchHue(accent);
|
|
29
|
+
return severities.map((severity) => {
|
|
30
|
+
const to = oklchHue(severity);
|
|
31
|
+
if (from === null || to === null) return Number.NaN;
|
|
32
|
+
const d = Math.abs(from - to) % 360;
|
|
33
|
+
return d > 180 ? 360 - d : d;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const severityScopes = ["error", "warning", "success"] as const;
|
|
38
|
+
|
|
39
|
+
function stringValue(value: unknown): string | undefined {
|
|
40
|
+
if (typeof value === "string") return value;
|
|
41
|
+
const val = (value as { val?: unknown } | undefined)?.val;
|
|
42
|
+
return typeof val === "string" ? val : undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* LC-288 at build time for `accentHue`: the built root's `$accent9` must sit
|
|
47
|
+
* 30° or more from each severity's step 9 in both schemes, or the build
|
|
48
|
+
* throws with the measured distances.
|
|
49
|
+
*/
|
|
50
|
+
export function assertAccentHueClearsSeverities(
|
|
51
|
+
themes: Record<string, Record<string, unknown>>,
|
|
52
|
+
hue: string,
|
|
53
|
+
): void {
|
|
54
|
+
const misses: string[] = [];
|
|
55
|
+
for (const scheme of ["light", "dark"] as const) {
|
|
56
|
+
const accent = stringValue(themes[scheme]?.accent9);
|
|
57
|
+
const severities = severityScopes.map((severity) =>
|
|
58
|
+
stringValue(themes[`${scheme}_${severity}`]?.color9),
|
|
59
|
+
);
|
|
60
|
+
if (!accent || severities.some((color) => !color)) continue;
|
|
61
|
+
severityHueDistances(accent, severities as string[]).forEach((distance, index) => {
|
|
62
|
+
if (!(distance >= severityMinHueDistance))
|
|
63
|
+
misses.push(`${scheme} ${severityScopes[index]} ${Math.round(distance)}°`);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (misses.length > 0) {
|
|
67
|
+
throw new Error(
|
|
68
|
+
`createDefaultThemeConfig: accentHue "${hue}" sits under ${severityMinHueDistance}° of OKLCH hue ` +
|
|
69
|
+
`from a severity (LC-288 SEVERITY-CHANNEL): ${misses.join(", ")}. ` +
|
|
70
|
+
`Name one of ${accentHues.join(", ")}.`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LC-27 CHART-PALETTE, round 88 amendment: every categorical series sits at
|
|
3
|
+
* least 0.08 OKLab from each LC-288 severity mark and ink step, under every
|
|
4
|
+
* preset and both schemes, and the first six stay apart for deuteranopia and
|
|
5
|
+
* protanopia.
|
|
6
|
+
*/
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { dirname, join } from "node:path";
|
|
9
|
+
import { fileURLToPath } from "node:url";
|
|
10
|
+
import { describe, expect, it, vi } from "vitest";
|
|
11
|
+
|
|
12
|
+
vi.mock("tamagui", () => ({
|
|
13
|
+
createTamagui: vi.fn((config: Record<string, unknown>) => config),
|
|
14
|
+
}));
|
|
15
|
+
vi.mock("./animations/index", () => ({ animations: {} }));
|
|
16
|
+
|
|
17
|
+
import { normalizeToHex } from "./colorRules";
|
|
18
|
+
import { accentIdentityCandidates, resolveChartPalette, type ChartPalette } from "./chartPalette";
|
|
19
|
+
import { createDefaultThemeConfig } from "./createDefaultThemeConfig";
|
|
20
|
+
import { tintHueNames } from "./createThemes";
|
|
21
|
+
import { resolveAllThemes } from "./dedupeInherited";
|
|
22
|
+
import { oklab } from "./fillContrast";
|
|
23
|
+
import {
|
|
24
|
+
boldPreset,
|
|
25
|
+
consolePreset,
|
|
26
|
+
defaultPreset,
|
|
27
|
+
densePreset,
|
|
28
|
+
heroPreset,
|
|
29
|
+
roomyPreset,
|
|
30
|
+
storefrontPreset,
|
|
31
|
+
} from "./presets";
|
|
32
|
+
|
|
33
|
+
const minSeverityDistance = 0.08;
|
|
34
|
+
const minSimulatedDistance = 0.06;
|
|
35
|
+
const schemes = ["light", "dark"] as const;
|
|
36
|
+
const severities = ["error", "warning", "success"] as const;
|
|
37
|
+
|
|
38
|
+
/** Presets whose accent leads the series in a severity hue (LC-288's baseline). */
|
|
39
|
+
const baseline: Record<string, string> = { ocean: "FZ-9260", paper: "FZ-9260" };
|
|
40
|
+
|
|
41
|
+
const repoRoot = join(dirname(fileURLToPath(import.meta.url)), "../../../..");
|
|
42
|
+
|
|
43
|
+
function appPresetThemes(): Record<string, string> {
|
|
44
|
+
const source = readFileSync(join(repoRoot, "packages/themes/presets.ts"), "utf8");
|
|
45
|
+
const out: Record<string, string> = {};
|
|
46
|
+
for (const block of source.split(/export const /).slice(1)) {
|
|
47
|
+
const name = block.match(/^(\w+)Preset\b/)?.[1];
|
|
48
|
+
if (!name) continue;
|
|
49
|
+
out[name] = block.match(/\btheme:\s*"([^"]*)"/)?.[1] ?? "";
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const presetThemes: Record<string, string> = {
|
|
55
|
+
default: defaultPreset.theme,
|
|
56
|
+
hero: heroPreset.theme,
|
|
57
|
+
bold: boldPreset.theme,
|
|
58
|
+
dense: densePreset.theme,
|
|
59
|
+
roomy: roomyPreset.theme,
|
|
60
|
+
console: consolePreset.theme,
|
|
61
|
+
storefront: storefrontPreset.theme,
|
|
62
|
+
...appPresetThemes(),
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const resolved = resolveAllThemes(
|
|
66
|
+
createDefaultThemeConfig().tamagui.themes as unknown as Record<string, Record<string, unknown>>,
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
function text(value: unknown): string | undefined {
|
|
70
|
+
if (typeof value === "string") return value;
|
|
71
|
+
const val = (value as { val?: unknown } | undefined)?.val;
|
|
72
|
+
return typeof val === "string" ? val : undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function paletteFor(scheme: "light" | "dark", theme: string): ChartPalette {
|
|
76
|
+
const scope = resolved[theme ? `${scheme}_${theme}` : scheme] ?? {};
|
|
77
|
+
const isTint = tintHueNames.has(theme);
|
|
78
|
+
const color9 = text(scope.color9);
|
|
79
|
+
const accent = text(scope.accentBackground);
|
|
80
|
+
const identitySolid = isTint ? (color9 ?? accent) : (accent ?? color9);
|
|
81
|
+
const accents = Array.from({ length: 10 }, (_, i) => text(scope[`accent${i + 1}`]));
|
|
82
|
+
return resolveChartPalette({
|
|
83
|
+
scheme,
|
|
84
|
+
identitySolid,
|
|
85
|
+
identityCandidates: [
|
|
86
|
+
...(isTint ? [] : accentIdentityCandidates(identitySolid, accents)),
|
|
87
|
+
text(scope.color10),
|
|
88
|
+
text(scope.color11),
|
|
89
|
+
],
|
|
90
|
+
surfaces: [
|
|
91
|
+
text(scope.color2),
|
|
92
|
+
text((scheme === "light" ? scope.color1 : scope.color3) as unknown),
|
|
93
|
+
],
|
|
94
|
+
tint: isTint,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function severitySteps(palette: ChartPalette, scheme: "light" | "dark"): string[] {
|
|
99
|
+
const steps = severities.map((s) => palette.semantic[s]);
|
|
100
|
+
for (const severity of severities) {
|
|
101
|
+
const scope = resolved[`${scheme}_${severity}`] ?? {};
|
|
102
|
+
for (const step of [9, 11]) {
|
|
103
|
+
const value = text(scope[`color${step}`]);
|
|
104
|
+
if (value) steps.push(value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return steps;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function oklabDistance(a: string, b: string): number {
|
|
111
|
+
const x = oklab(a) as number[];
|
|
112
|
+
const y = oklab(b) as number[];
|
|
113
|
+
return Math.hypot(x[0] - y[0], x[1] - y[1], x[2] - y[2]);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function wearsSeverity(color: string, steps: string[]): boolean {
|
|
117
|
+
return steps.some((step) => oklabDistance(color, step) < minSeverityDistance);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const deuteranopia = [
|
|
121
|
+
[0.367322, 0.860646, -0.227968],
|
|
122
|
+
[0.280085, 0.672501, 0.047413],
|
|
123
|
+
[-0.01182, 0.04294, 0.968881],
|
|
124
|
+
];
|
|
125
|
+
const protanopia = [
|
|
126
|
+
[0.152286, 1.052583, -0.204868],
|
|
127
|
+
[0.114503, 0.786281, 0.099216],
|
|
128
|
+
[-0.003882, -0.048116, 1.051998],
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
function simulate(color: string, matrix: number[][]): string {
|
|
132
|
+
const hex = normalizeToHex(color) as string;
|
|
133
|
+
const lin = [1, 3, 5].map((i) => {
|
|
134
|
+
const c = Number.parseInt(hex.slice(i, i + 2), 16) / 255;
|
|
135
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
136
|
+
});
|
|
137
|
+
const out = matrix.map((row) => {
|
|
138
|
+
const v = Math.min(1, Math.max(0, row[0] * lin[0] + row[1] * lin[1] + row[2] * lin[2]));
|
|
139
|
+
const s = v <= 0.0031308 ? v * 12.92 : 1.055 * v ** (1 / 2.4) - 0.055;
|
|
140
|
+
return Math.round(s * 255)
|
|
141
|
+
.toString(16)
|
|
142
|
+
.padStart(2, "0");
|
|
143
|
+
});
|
|
144
|
+
return `#${out.join("")}`;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function closestPair(colors: string[], matrix: number[][]): number {
|
|
148
|
+
let worst = Infinity;
|
|
149
|
+
for (let i = 0; i < colors.length; i++)
|
|
150
|
+
for (let j = i + 1; j < colors.length; j++) {
|
|
151
|
+
const a = oklab(simulate(colors[i] as string, matrix)) as number[];
|
|
152
|
+
const b = oklab(simulate(colors[j] as string, matrix)) as number[];
|
|
153
|
+
worst = Math.min(worst, Math.hypot(a[0] - b[0], a[1] - b[1], a[2] - b[2]));
|
|
154
|
+
}
|
|
155
|
+
return worst;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
describe("LC-27 categorical cycle clear of the LC-288 severity colours", () => {
|
|
159
|
+
for (const preset of Object.keys(baseline)) {
|
|
160
|
+
it(`${preset} is baselined (${baseline[preset]}) and its lead still sits on a severity colour`, () => {
|
|
161
|
+
const leads = schemes.filter((scheme) => {
|
|
162
|
+
const palette = paletteFor(scheme, presetThemes[preset] as string);
|
|
163
|
+
return wearsSeverity(palette.categorical[0] as string, severitySteps(palette, scheme));
|
|
164
|
+
});
|
|
165
|
+
expect(leads).not.toEqual([]);
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
for (const preset of Object.keys(presetThemes)) {
|
|
170
|
+
for (const scheme of schemes) {
|
|
171
|
+
it(`${preset} ${scheme}: no series after the lead sits on a severity colour`, () => {
|
|
172
|
+
const palette = paletteFor(scheme, presetThemes[preset] as string);
|
|
173
|
+
const hues = severitySteps(palette, scheme);
|
|
174
|
+
const offenders = palette.categorical
|
|
175
|
+
.slice(1)
|
|
176
|
+
.filter((color) => wearsSeverity(color, hues));
|
|
177
|
+
expect(offenders).toEqual([]);
|
|
178
|
+
if (!baseline[preset])
|
|
179
|
+
expect(wearsSeverity(palette.categorical[0] as string, hues)).toBe(false);
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it(`${preset} ${scheme}: six series stay apart for deuteranopia and protanopia`, () => {
|
|
183
|
+
const six = paletteFor(scheme, presetThemes[preset] as string).categorical.slice(0, 6);
|
|
184
|
+
expect(six).toHaveLength(6);
|
|
185
|
+
expect(closestPair(six, deuteranopia)).toBeGreaterThanOrEqual(minSimulatedDistance);
|
|
186
|
+
expect(closestPair(six, protanopia)).toBeGreaterThanOrEqual(minSimulatedDistance);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
});
|
|
@@ -113,32 +113,31 @@ describe("resolveChartPalette", () => {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
|
|
116
|
-
it("
|
|
116
|
+
it("keeps the dark cycle order behind an ink identity", () => {
|
|
117
117
|
const palette = resolveChartPalette({ scheme: "dark", identitySolid: "#aaaaaa" });
|
|
118
118
|
expect(palette.categorical).toEqual([
|
|
119
119
|
Colors.blueDark.blue9,
|
|
120
|
-
Colors.
|
|
121
|
-
Colors.greenDark.green9,
|
|
122
|
-
Colors.amberDark.amber9,
|
|
120
|
+
Colors.yellowDark.yellow10,
|
|
123
121
|
Colors.pinkDark.pink9,
|
|
124
|
-
Colors.
|
|
122
|
+
Colors.skyDark.sky9,
|
|
125
123
|
Colors.violetDark.violet11,
|
|
126
|
-
Colors.
|
|
124
|
+
Colors.brownDark.brown11,
|
|
125
|
+
Colors.goldDark.gold10,
|
|
126
|
+
Colors.indigoDark.indigo11,
|
|
127
127
|
]);
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
it("keeps the valid default light order and
|
|
130
|
+
it("keeps the valid default light order, and grass drops only the brown protanopia confuses", () => {
|
|
131
131
|
expect(
|
|
132
132
|
resolveChartPalette({ scheme: "light", identitySolid: lightAccent }).categorical,
|
|
133
133
|
).toEqual([
|
|
134
134
|
lightAccent,
|
|
135
|
-
Colors.blue.
|
|
136
|
-
Colors.
|
|
137
|
-
Colors.
|
|
138
|
-
Colors.
|
|
139
|
-
Colors.
|
|
140
|
-
Colors.
|
|
141
|
-
Colors.red.red9,
|
|
135
|
+
Colors.blue.blue9,
|
|
136
|
+
Colors.yellow.yellow12,
|
|
137
|
+
Colors.pink.pink11,
|
|
138
|
+
Colors.sky.sky12,
|
|
139
|
+
Colors.brown.brown9,
|
|
140
|
+
Colors.gold.gold12,
|
|
142
141
|
]);
|
|
143
142
|
const grass = resolveChartPalette({
|
|
144
143
|
scheme: "light",
|
|
@@ -149,13 +148,13 @@ describe("resolveChartPalette", () => {
|
|
|
149
148
|
expect([...grass.categorical].sort()).toEqual(
|
|
150
149
|
[
|
|
151
150
|
Colors.grass.grass10,
|
|
152
|
-
Colors.blue.
|
|
153
|
-
Colors.
|
|
154
|
-
Colors.
|
|
155
|
-
Colors.
|
|
156
|
-
Colors.teal.teal11,
|
|
151
|
+
Colors.blue.blue9,
|
|
152
|
+
Colors.yellow.yellow12,
|
|
153
|
+
Colors.pink.pink11,
|
|
154
|
+
Colors.sky.sky12,
|
|
157
155
|
Colors.violet.violet9,
|
|
158
|
-
Colors.
|
|
156
|
+
Colors.gold.gold12,
|
|
157
|
+
Colors.indigo.indigo10,
|
|
159
158
|
].sort(),
|
|
160
159
|
);
|
|
161
160
|
});
|
|
@@ -207,8 +206,8 @@ describe("resolveChartPalette", () => {
|
|
|
207
206
|
|
|
208
207
|
it("leads with the series cycle when the identity is an ink (LC-172)", () => {
|
|
209
208
|
const light = resolveChartPalette({ scheme: "light", identitySolid: "#111111" });
|
|
210
|
-
expect(light.single).toBe(Colors.blue.
|
|
211
|
-
expect(light.categorical[0]).toBe(Colors.blue.
|
|
209
|
+
expect(light.single).toBe(Colors.blue.blue9);
|
|
210
|
+
expect(light.categorical[0]).toBe(Colors.blue.blue9);
|
|
212
211
|
expect(light.categorical).not.toContain("#111111");
|
|
213
212
|
const dark = resolveChartPalette({ scheme: "dark", identitySolid: "#eeeeee" });
|
|
214
213
|
expect(dark.single).toBe(Colors.blueDark.blue9);
|
|
@@ -225,7 +224,7 @@ describe("resolveChartPalette", () => {
|
|
|
225
224
|
expect(dark.single).toBe(Colors.blueDark.blue9);
|
|
226
225
|
expect(dark.categorical).not.toContain(midGrey);
|
|
227
226
|
const light = resolveChartPalette({ scheme: "light", identitySolid: "#111111", tint: false });
|
|
228
|
-
expect(light.single).toBe(Colors.blue.
|
|
227
|
+
expect(light.single).toBe(Colors.blue.blue9);
|
|
229
228
|
// A gray tint chose gray; a hued accent keeps its hue.
|
|
230
229
|
expect(
|
|
231
230
|
resolveChartPalette({ scheme: "light", identitySolid: grayTintSolid, tint: true }).single,
|
|
@@ -249,33 +248,37 @@ describe("resolveChartPalette", () => {
|
|
|
249
248
|
expect(palette.categorical[0]).toBe(lightAccent);
|
|
250
249
|
});
|
|
251
250
|
|
|
252
|
-
it("drops the cycle
|
|
251
|
+
it("drops the cycle entries confusable with the accent identity (violet)", () => {
|
|
253
252
|
const palette = resolveChartPalette({ scheme: "light", identitySolid: lightAccent });
|
|
254
253
|
expect(palette.categorical).not.toContain(Colors.violet.violet9);
|
|
255
|
-
expect(palette.categorical).toContain(Colors.
|
|
256
|
-
expect(palette.categorical).
|
|
254
|
+
expect(palette.categorical).not.toContain(Colors.indigo.indigo10);
|
|
255
|
+
expect(palette.categorical).toContain(Colors.blue.blue9);
|
|
256
|
+
expect(palette.categorical).toHaveLength(7);
|
|
257
257
|
});
|
|
258
258
|
|
|
259
|
-
it("re-anchors under a red tint and drops the
|
|
259
|
+
it("re-anchors under a red tint and drops the brown its lightness can't tell apart", () => {
|
|
260
260
|
const palette = resolveChartPalette({ scheme: "light", identitySolid: redTintSolid });
|
|
261
261
|
expect(palette.categorical[0]).toBe(redTintSolid);
|
|
262
262
|
expect(palette.categorical).not.toContain(Colors.red.red9);
|
|
263
|
-
expect(palette.categorical).toContain(Colors.
|
|
263
|
+
expect(palette.categorical).not.toContain(Colors.brown.brown9);
|
|
264
|
+
expect(palette.categorical).toHaveLength(8);
|
|
264
265
|
});
|
|
265
266
|
|
|
266
|
-
it("re-anchors under a purple tint and drops the
|
|
267
|
+
it("re-anchors under a purple tint and drops violet, and the indigo protanopia confuses", () => {
|
|
267
268
|
const palette = resolveChartPalette({ scheme: "light", identitySolid: purpleTintSolid });
|
|
268
269
|
expect(palette.categorical[0]).toBe(purpleTintSolid);
|
|
269
270
|
expect(palette.categorical).not.toContain(Colors.violet.violet9);
|
|
270
|
-
expect(palette.categorical).toContain(Colors.
|
|
271
|
+
expect(palette.categorical).not.toContain(Colors.indigo.indigo10);
|
|
272
|
+
expect(palette.categorical).toContain(Colors.blue.blue9);
|
|
271
273
|
});
|
|
272
274
|
|
|
273
|
-
it("
|
|
275
|
+
it("under a tomato tint drops only the brown beside it, and carries no red, orange or amber", () => {
|
|
274
276
|
const palette = resolveChartPalette({ scheme: "light", identitySolid: tomatoTintSolid });
|
|
275
277
|
expect(palette.categorical).not.toContain(Colors.red.red9);
|
|
276
278
|
expect(palette.categorical).not.toContain(Colors.orange.orange11);
|
|
277
279
|
expect(palette.categorical).not.toContain(Colors.amber.amber11);
|
|
278
|
-
expect(palette.categorical).
|
|
280
|
+
expect(palette.categorical).not.toContain(Colors.brown.brown9);
|
|
281
|
+
expect(palette.categorical).toHaveLength(8);
|
|
279
282
|
});
|
|
280
283
|
|
|
281
284
|
it("keeps the full cycle behind a neutral identity (gray tint)", () => {
|
|
@@ -301,10 +304,10 @@ describe("resolveChartPalette", () => {
|
|
|
301
304
|
const dark = resolveChartPalette({ scheme: "dark", identitySolid: darkAccent });
|
|
302
305
|
expect(light.semantic.error).toBe(Colors.red.red9);
|
|
303
306
|
expect(light.semantic.success).toBe(Colors.green.green10);
|
|
304
|
-
expect(light.semantic.warning).toBe(
|
|
307
|
+
expect(light.semantic.warning).toBe("#a25f02");
|
|
305
308
|
expect(dark.semantic.error).toBe(Colors.redDark.red9);
|
|
306
309
|
expect(dark.semantic.success).toBe(Colors.greenDark.green9);
|
|
307
|
-
expect(dark.semantic.warning).toBe(Colors.
|
|
310
|
+
expect(dark.semantic.warning).toBe(Colors.amberDark.amber9);
|
|
308
311
|
// Warning adapts per scheme (yellow9 is ~1.3:1 against light surfaces).
|
|
309
312
|
expect(light.semantic.warning).not.toBe(dark.semantic.warning);
|
|
310
313
|
});
|