Theme Builder: structured color/type controls, scheme catalog, diverging preview

This commit is contained in:
2026-06-14 01:25:44 +03:00
parent 0470389b41
commit e4d1466ab0
17 changed files with 1607 additions and 52 deletions
+16
View File
@@ -88,4 +88,20 @@ describe('THEME_PREVIEW_SPECS', () => {
const ids = THEME_PREVIEW_SPECS.map((c) => c.id);
expect(new Set(ids).size).toBe(ids.length);
});
it('exercises every color family the builder controls', () => {
type ColorDef = { type?: string; scale?: { domainMid?: unknown } };
const colorOf = (spec: (typeof THEME_PREVIEW_SPECS)[number]['spec']): ColorDef | undefined =>
(spec.encoding as { color?: ColorDef } | undefined)?.color;
const colors = THEME_PREVIEW_SPECS.map((c) => colorOf(c.spec));
// mark.color (a card with no color encoding), categorical, sequential
// (quantitative, no midpoint), and diverging (quantitative with a midpoint).
expect(colors.some((c) => c === undefined)).toBe(true);
expect(colors.some((c) => c?.type === 'nominal')).toBe(true);
expect(colors.some((c) => c?.type === 'quantitative' && c.scale?.domainMid === undefined)).toBe(
true,
);
expect(colors.some((c) => c?.scale?.domainMid !== undefined)).toBe(true);
});
});