Skip to main content

checkThemeContrast

Checks a proposed theme against WCAG 2.2 AA: 4.5:1 for text, 3:1 for icons, control edges, selection and the focus ring. A role left out is checked at its default, so a changed accent is also checked against the default accentTint. Translucent surfaces are flattened over each representative map backdrop (white, black, a light map and the default basemap), so the worst case is reported.

This is a function exported by @mapcairn/theme, checked against version 0.2.0.

Signature​

import { checkThemeContrast } from "@mapcairn/theme";

function checkThemeContrast(override: ThemeOverride): ThemeContrastCheck;

Description​

Pure and total: it never throws and never decides whether a theme is accepted. A colour it cannot check is reported in invalid, and the pairs that depend on it are left out of findings; the host decides what a failure means. Only the default colour set is checked: the opaque and prefers-contrast: more sets are not overridable.

Parameters​

  • override (ThemeOverride): The proposed colours for light and dark.

Returns​

ThemeContrastCheck: A finding for every checked pair and backdrop, in both themes.

See also​

Source: packages/theme/src/checkThemeContrast.ts:302