|
|
|
|
@ -12,6 +12,7 @@ import {
|
|
|
|
|
EidosThemeNotFoundError,
|
|
|
|
|
EidosConfigValidationError,
|
|
|
|
|
extendEidosConfig,
|
|
|
|
|
parseEidosConfigFromJson,
|
|
|
|
|
parseEidosConfigDocument,
|
|
|
|
|
STATIC_CONTROL_HEIGHT,
|
|
|
|
|
STATIC_DENSITY,
|
|
|
|
|
@ -58,6 +59,10 @@ function createEidosFromJson(json: string) {
|
|
|
|
|
return createEidosFromDocument(parseEidosConfigDocument(json))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function cssVariableDeclarations(css: string): Set<string> {
|
|
|
|
|
return new Set([...css.matchAll(/--[a-z0-9_-]+(?=\s*:)/g)].map(([name]) => name))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function colorScale(seed: string): ColorScale {
|
|
|
|
|
return Object.fromEntries(
|
|
|
|
|
COLOR_SCALE_STEPS.map((step) => [step, `${seed}-${step}`])
|
|
|
|
|
@ -299,6 +304,18 @@ describe('ActiveEidos config', () => {
|
|
|
|
|
expect(() => parseEidosConfigDocument('{')).toThrow(EidosConfigDocumentError)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('rejects persisted documents with invalid Eidos config options', () => {
|
|
|
|
|
const invalid = structuredClone(createThemeBaseEidos().toDocument()) as EidosConfigDocument
|
|
|
|
|
|
|
|
|
|
;(invalid.options.semantics.color.roles as Record<string, unknown>).primary =
|
|
|
|
|
'missing-scale'
|
|
|
|
|
|
|
|
|
|
expect(() => createEidosFromDocument(invalid)).toThrow(EidosConfigValidationError)
|
|
|
|
|
expect(() => parseEidosConfigFromJson(JSON.stringify(invalid))).toThrow(
|
|
|
|
|
EidosConfigValidationError
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('ships typography families separately from typography styles', () => {
|
|
|
|
|
const typography = createThemeBaseEidos().snapshot().primitives.typography!
|
|
|
|
|
|
|
|
|
|
@ -620,6 +637,20 @@ describe('ActiveEidos config', () => {
|
|
|
|
|
expect(css).not.toContain('--size-full-control-height')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('keeps the generated CSS renderers aligned with the CSS contract', () => {
|
|
|
|
|
const eidos = createThemeBaseEidos()
|
|
|
|
|
const contract = eidos.getCssContract()
|
|
|
|
|
const staticDeclarations = cssVariableDeclarations(eidos.renderStaticCss())
|
|
|
|
|
const themeDeclarations = cssVariableDeclarations(eidos.renderThemeCss('base-light'))
|
|
|
|
|
|
|
|
|
|
for (const token of contract.static) {
|
|
|
|
|
expect(staticDeclarations.has(token.cssVar), token.cssVar).toBe(true)
|
|
|
|
|
}
|
|
|
|
|
for (const token of contract.theme) {
|
|
|
|
|
expect(themeDeclarations.has(token.cssVar), token.cssVar).toBe(true)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('renders contract-aware runtime CSS variables', () => {
|
|
|
|
|
const eidos = createThemeBaseEidos()
|
|
|
|
|
const css = eidos.renderCssVariables(
|
|
|
|
|
|