|
|
|
@ -4,6 +4,7 @@ import {
|
|
|
|
BORDER_STYLE_KEYS,
|
|
|
|
BORDER_STYLE_KEYS,
|
|
|
|
BORDER_WIDTH_KEYS,
|
|
|
|
BORDER_WIDTH_KEYS,
|
|
|
|
COLOR_ROLES,
|
|
|
|
COLOR_ROLES,
|
|
|
|
|
|
|
|
COLOR_ROLE_SLOTS,
|
|
|
|
COLOR_SCALE_STEPS,
|
|
|
|
COLOR_SCALE_STEPS,
|
|
|
|
CONTAINER_WIDTH_KEYS,
|
|
|
|
CONTAINER_WIDTH_KEYS,
|
|
|
|
CONTENT_COLOR_KEYS,
|
|
|
|
CONTENT_COLOR_KEYS,
|
|
|
|
@ -55,6 +56,8 @@ const BORDER_WIDTH_KEY_SET = new Set<string>(BORDER_WIDTH_KEYS)
|
|
|
|
const BORDER_STYLE_KEY_SET = new Set<string>(BORDER_STYLE_KEYS)
|
|
|
|
const BORDER_STYLE_KEY_SET = new Set<string>(BORDER_STYLE_KEYS)
|
|
|
|
const BORDER_COLOR_KEY_SET = new Set<string>(BORDER_COLOR_KEYS)
|
|
|
|
const BORDER_COLOR_KEY_SET = new Set<string>(BORDER_COLOR_KEYS)
|
|
|
|
const CONTENT_COLOR_KEY_SET = new Set<string>(CONTENT_COLOR_KEYS)
|
|
|
|
const CONTENT_COLOR_KEY_SET = new Set<string>(CONTENT_COLOR_KEYS)
|
|
|
|
|
|
|
|
const COLOR_ROLE_SLOT_SET = new Set<string>(COLOR_ROLE_SLOTS)
|
|
|
|
|
|
|
|
const COLOR_SCALE_STEP_SET = new Set<string>(COLOR_SCALE_STEPS)
|
|
|
|
const CONTAINER_WIDTH_KEY_SET = new Set<string>(CONTAINER_WIDTH_KEYS)
|
|
|
|
const CONTAINER_WIDTH_KEY_SET = new Set<string>(CONTAINER_WIDTH_KEYS)
|
|
|
|
const CONTENT_WIDTH_KEY_SET = new Set<string>(CONTENT_WIDTH_KEYS)
|
|
|
|
const CONTENT_WIDTH_KEY_SET = new Set<string>(CONTENT_WIDTH_KEYS)
|
|
|
|
const DENSITY_KEY_SET = new Set<string>(DENSITY_KEYS)
|
|
|
|
const DENSITY_KEY_SET = new Set<string>(DENSITY_KEYS)
|
|
|
|
@ -454,6 +457,14 @@ function validateColorRole(
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (roleDef !== undefined && typeof roleDef !== 'string' && !isPlainRecord(roleDef)) {
|
|
|
|
|
|
|
|
issues.push({
|
|
|
|
|
|
|
|
path,
|
|
|
|
|
|
|
|
message: 'color role definition must be a scale name or plain object'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const scaleName = resolveRoleScaleName(roleDef)
|
|
|
|
const scaleName = resolveRoleScaleName(roleDef)
|
|
|
|
if (!scaleName) {
|
|
|
|
if (!scaleName) {
|
|
|
|
issues.push({
|
|
|
|
issues.push({
|
|
|
|
@ -463,6 +474,10 @@ function validateColorRole(
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (typeof roleDef !== 'string' && roleDef?.slots !== undefined) {
|
|
|
|
|
|
|
|
validateColorRoleSlots(`${path}.slots`, roleDef.slots, issues)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const themeEntries = Object.entries(themes)
|
|
|
|
const themeEntries = Object.entries(themes)
|
|
|
|
if (themeEntries.length === 0) {
|
|
|
|
if (themeEntries.length === 0) {
|
|
|
|
if (!hasOwn(globalScales, scaleName)) {
|
|
|
|
if (!hasOwn(globalScales, scaleName)) {
|
|
|
|
@ -484,6 +499,36 @@ function validateColorRole(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function validateColorRoleSlots(
|
|
|
|
|
|
|
|
path: string,
|
|
|
|
|
|
|
|
slots: unknown,
|
|
|
|
|
|
|
|
issues: EidosValidationIssue[]
|
|
|
|
|
|
|
|
): void {
|
|
|
|
|
|
|
|
if (!isPlainRecord(slots)) {
|
|
|
|
|
|
|
|
issues.push({
|
|
|
|
|
|
|
|
path,
|
|
|
|
|
|
|
|
message: 'color role slots must be a plain object'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const [slot, step] of Object.entries(slots)) {
|
|
|
|
|
|
|
|
if (!COLOR_ROLE_SLOT_SET.has(slot)) {
|
|
|
|
|
|
|
|
issues.push({
|
|
|
|
|
|
|
|
path: `${path}.${slot}`,
|
|
|
|
|
|
|
|
message: 'unknown color role slot'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof step !== 'string' || !COLOR_SCALE_STEP_SET.has(step)) {
|
|
|
|
|
|
|
|
issues.push({
|
|
|
|
|
|
|
|
path: `${path}.${slot}`,
|
|
|
|
|
|
|
|
message: 'color role slot must point to a scale step from 1 to 12'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function validateTypography(options: EidosConfig, issues: EidosValidationIssue[]): void {
|
|
|
|
function validateTypography(options: EidosConfig, issues: EidosValidationIssue[]): void {
|
|
|
|
const typography = options.primitives.typography
|
|
|
|
const typography = options.primitives.typography
|
|
|
|
if (!typography) return
|
|
|
|
if (!typography) return
|
|
|
|
|