import { overrideCatalogDefinitions } from './catalogDefinitions'; import type { RuleDefinition } from './contracts'; const allowedValueRules = overrideCatalogDefinitions.selections.map( (selection) => ({ id: `${selection.id}-allowed-values`, type: 'allowed-values', phase: 'intent', description: `${selection.id} must use its package-owned source set`, severity: 'error', calibration: 'approved', selectionId: selection.id, sourceSetId: selection.sourceSetId, }) as const, ); const linkContrastRules = ['primary', 'secondary', 'tertiary', 'action.subtle'].map( (surface) => ({ id: `link-${surface.replace('.', '-')}-contrast`, type: 'contrast', phase: 'resolved', description: `Links should remain readable on ${surface} surfaces`, severity: 'warning', calibration: 'provisional', source: 'color.content.link', against: `color.surface.${surface}`, minRatio: 4.5, }) as const, ); const statusProximityRules = ['danger', 'success', 'warning', 'info'].map( (status) => ({ id: `${status}-action-proximity`, type: 'proximity', phase: 'resolved', description: `${status} should remain visually distinct from Action`, severity: 'warning', calibration: 'provisional', source: `color.surface.${status}.strong`, against: 'color.surface.action.strong', minDeltaE: 20, }) as const, ); export const overrideRuleDefinitions = [ ...allowedValueRules, { id: 'action-strong-contrast', type: 'contrast', phase: 'resolved', description: 'Action content should remain readable on the strong action surface', severity: 'warning', calibration: 'provisional', source: 'color.surface.action.strong', against: 'color.content.action-on-strong', minRatio: 4.5, }, { id: 'surface-background-content-contrast', type: 'contrast', phase: 'resolved', description: 'Primary content should remain readable on the app background', severity: 'warning', calibration: 'provisional', source: 'color.surface.background', against: 'color.content.primary', minRatio: 7, }, ...linkContrastRules, ...statusProximityRules, ] as const satisfies readonly RuleDefinition[];