|
|
|
@ -386,7 +386,23 @@ function validateTypography(options: EidosConfig, issues: EidosValidationIssue[]
|
|
|
|
validateTextMetric(`primitives.typography.sizes.${size}`, metric, issues)
|
|
|
|
validateTextMetric(`primitives.typography.sizes.${size}`, metric, issues)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const name of Object.keys(typography.sizes)) {
|
|
|
|
|
|
|
|
validateCssTokenSuffix(`primitives.typography.sizes.${name}`, name, 'typography size', issues)
|
|
|
|
|
|
|
|
if (!TEXT_SIZE_SET.has(name)) {
|
|
|
|
|
|
|
|
issues.push({
|
|
|
|
|
|
|
|
path: `primitives.typography.sizes.${name}`,
|
|
|
|
|
|
|
|
message: 'unknown typography size key'
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (const [name, family] of Object.entries(typography.families)) {
|
|
|
|
for (const [name, family] of Object.entries(typography.families)) {
|
|
|
|
|
|
|
|
validateCssTokenSuffix(
|
|
|
|
|
|
|
|
`primitives.typography.families.${name}`,
|
|
|
|
|
|
|
|
name,
|
|
|
|
|
|
|
|
'typography family',
|
|
|
|
|
|
|
|
issues
|
|
|
|
|
|
|
|
)
|
|
|
|
if (family.family.trim() === '') {
|
|
|
|
if (family.family.trim() === '') {
|
|
|
|
issues.push({
|
|
|
|
issues.push({
|
|
|
|
path: `primitives.typography.families.${name}.family`,
|
|
|
|
path: `primitives.typography.families.${name}.family`,
|
|
|
|
@ -395,8 +411,18 @@ function validateTypography(options: EidosConfig, issues: EidosValidationIssue[]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const name of Object.keys(typography.weights)) {
|
|
|
|
|
|
|
|
validateCssTokenSuffix(
|
|
|
|
|
|
|
|
`primitives.typography.weights.${name}`,
|
|
|
|
|
|
|
|
name,
|
|
|
|
|
|
|
|
'typography weight',
|
|
|
|
|
|
|
|
issues
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (const [name, style] of Object.entries(typography.styles)) {
|
|
|
|
for (const [name, style] of Object.entries(typography.styles)) {
|
|
|
|
const path = `primitives.typography.styles.${name}`
|
|
|
|
const path = `primitives.typography.styles.${name}`
|
|
|
|
|
|
|
|
validateCssTokenSuffix(path, name, 'typography style', issues)
|
|
|
|
|
|
|
|
|
|
|
|
if (style.family !== undefined && !hasOwn(typography.families, style.family)) {
|
|
|
|
if (style.family !== undefined && !hasOwn(typography.families, style.family)) {
|
|
|
|
issues.push({
|
|
|
|
issues.push({
|
|
|
|
@ -769,6 +795,19 @@ function validateCssTokenKey(
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function validateCssTokenSuffix(
|
|
|
|
|
|
|
|
path: string,
|
|
|
|
|
|
|
|
value: string,
|
|
|
|
|
|
|
|
label: string,
|
|
|
|
|
|
|
|
issues: EidosValidationIssue[]
|
|
|
|
|
|
|
|
): void {
|
|
|
|
|
|
|
|
if (isCssTokenSuffix(value)) return
|
|
|
|
|
|
|
|
issues.push({
|
|
|
|
|
|
|
|
path,
|
|
|
|
|
|
|
|
message: `${label} must be a kebab-case CSS token suffix`
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function resolveRoleScaleName(
|
|
|
|
function resolveRoleScaleName(
|
|
|
|
roleDef: string | ColorRoleDefinition | undefined
|
|
|
|
roleDef: string | ColorRoleDefinition | undefined
|
|
|
|
): string | undefined {
|
|
|
|
): string | undefined {
|
|
|
|
@ -779,3 +818,7 @@ function resolveRoleScaleName(
|
|
|
|
function isCssTokenSegment(value: string): boolean {
|
|
|
|
function isCssTokenSegment(value: string): boolean {
|
|
|
|
return /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value)
|
|
|
|
return /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isCssTokenSuffix(value: string): boolean {
|
|
|
|
|
|
|
|
return /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(value)
|
|
|
|
|
|
|
|
}
|
|
|
|
|