Description
contrast.ts contains colour utilities but lacks a standardised WCAG contrast-ratio checker. Contributors should add a meetsWcagAA(foreground: string, background: string, largeText?: boolean): boolean function that calculates the relative luminance of each colour and returns whether the pair meets the WCAG 2.1 AA ratio (4.5:1 for normal text, 3:1 for large text).
Acceptance Criteria
Context
- Target file:
src/lib/contrast.ts
- Used by:
src/lib/pdfTheme.ts
Description
contrast.tscontains colour utilities but lacks a standardised WCAG contrast-ratio checker. Contributors should add ameetsWcagAA(foreground: string, background: string, largeText?: boolean): booleanfunction that calculates the relative luminance of each colour and returns whether the pair meets the WCAG 2.1 AA ratio (4.5:1 for normal text, 3:1 for large text).Acceptance Criteria
meetsWcagAA("#000000", "#ffffff")returnstrue(21:1 ratio)meetsWcagAA("#777777", "#ffffff")returnsfalsefor normal text (fails 4.5:1)meetsWcagAAaccepts hex,rgb(), orrgba()colour stringsContext
src/lib/contrast.tssrc/lib/pdfTheme.ts