Skip to content

contrast: Add meetsWcagAA function for WCAG 2.1 AA contrast ratio checks #705

Description

@Kingsman-99

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

  • meetsWcagAA("#000000", "#ffffff") returns true (21:1 ratio)
  • meetsWcagAA("#777777", "#ffffff") returns false for normal text (fails 4.5:1)
  • meetsWcagAA accepts hex, rgb(), or rgba() colour strings
  • Existing tests continue to pass

Context

  • Target file: src/lib/contrast.ts
  • Used by: src/lib/pdfTheme.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions