# @mapcairn/theme

MapCairn's typed design tokens, light and dark themes, and contrast checks; plain CSS, no plugin needed.

Checked against version 0.2.0. Install it with `npm install @mapcairn/theme`; import from `@mapcairn/theme`.

## Tokens

- [`focusRing`](https://docs.mapcairn.com/api/theme/focusRing.md): Two-tone focus ring for every interactive element and the focused map.
- [`mapOverlayTokens`](https://docs.mapcairn.com/api/theme/mapOverlayTokens.md): The CSS variable references for everything drawn over the map: pin, measure line and fill, accuracy circle, halo, loading indicator and tile-error banner.
- [`surfaceBlurStyle`](https://docs.mapcairn.com/api/theme/surfaceBlurStyle.md): Surface styling for floating chrome: the translucent surface colour with its backdrop blur, with the -webkit- spelling Safari needs.
- [`surfaceBlurSupported`](https://docs.mapcairn.com/api/theme/surfaceBlurSupported.md): The support test for backdrop-filter in both spellings.
- [`tokens`](https://docs.mapcairn.com/api/theme/tokens.md): The whole token contract: every custom property that components may read.
- [`tokenValues`](https://docs.mapcairn.com/api/theme/tokenValues.md): Every design-token value as plain typed data: the oklch colours, spacing, sizes and type scale that tokens turns into CSS custom properties.

## Functions

- [`checkThemeContrast`](https://docs.mapcairn.com/api/theme/checkThemeContrast.md): 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.
- [`compositeOver`](https://docs.mapcairn.com/api/theme/compositeOver.md): Composites foreground over backdrop in gamma-encoded sRGB, which is what browsers do for rgba() and oklch(...
- [`contrastRatio`](https://docs.mapcairn.com/api/theme/contrastRatio.md): WCAG contrast ratio, from 1 to 21, between two opaque colours.
- [`createThemeStylesheet`](https://docs.mapcairn.com/api/theme/createThemeStylesheet.md): Generates the stylesheet that applies a colour override to the SDK's interface inside options.scope, or refuses.
- [`parseColour`](https://docs.mapcairn.com/api/theme/parseColour.md): Parses a hex, rgb()/rgba() or oklch() colour to gamma-encoded sRGB.
- [`toHex`](https://docs.mapcairn.com/api/theme/toHex.md): Formats a colour as #rrggbb, or #rrggbbaa when it is translucent.
- [`zLayer`](https://docs.mapcairn.com/api/theme/zLayer.md): The z-index variable for a named layer, bottom to top: map, mapOverlay, chrome, chromeRaised, sheet, toolbar, popover, toast.

## Constants

- [`blur_2`](https://docs.mapcairn.com/api/theme/blur_2.md): The backdrop blur applied behind translucent surfaces, or none when they are opaque.

## Types

- [`BackdropName`](https://docs.mapcairn.com/api/theme/BackdropName.md): Name of one of the representative map backdrops: white, black, a light map and the land colours of the light and dark default basemaps.
- [`ColourInput`](https://docs.mapcairn.com/api/theme/ColourInput.md): A colour as the token files write it, or one already parsed.
- [`ContrastBackground`](https://docs.mapcairn.com/api/theme/ContrastBackground.md): The colour a pair's foreground sits on.
- [`ContrastFinding`](https://docs.mapcairn.com/api/theme/ContrastFinding.md): The measured contrast of one pair, in one theme, over one backdrop.
- [`InvalidColour`](https://docs.mapcairn.com/api/theme/InvalidColour.md): A proposed colour that was not checked, so its pairs are missing from the findings.
- [`InvalidColourReason`](https://docs.mapcairn.com/api/theme/InvalidColourReason.md): Why a proposed colour could not be checked.
- [`PairKind`](https://docs.mapcairn.com/api/theme/PairKind.md): What a pair's foreground is: text, or a non-text mark such as an edge or ring.
- [`Rgba`](https://docs.mapcairn.com/api/theme/Rgba.md): A colour in gamma-encoded sRGB.
- [`ThemeColourRole`](https://docs.mapcairn.com/api/theme/ThemeColourRole.md): The interface colour roles a host may override, and so the roles a finding's foreground can name.
- [`ThemeColours`](https://docs.mapcairn.com/api/theme/ThemeColours.md): The interface colour roles a host may override.
- [`ThemeContrastCheck`](https://docs.mapcairn.com/api/theme/ThemeContrastCheck.md): The result of checkThemeContrast.
- [`ThemeName`](https://docs.mapcairn.com/api/theme/ThemeName.md): The two themes.
- [`ThemeOverride`](https://docs.mapcairn.com/api/theme/ThemeOverride.md): A proposed theme: some colour roles, per theme.
- [`ThemeStylesheet`](https://docs.mapcairn.com/api/theme/ThemeStylesheet.md): The result of createThemeStylesheet.
- [`ThemeStylesheetCreated`](https://docs.mapcairn.com/api/theme/ThemeStylesheetCreated.md): A theme override that was accepted: the stylesheet and what was measured.
- [`ThemeStylesheetOptions`](https://docs.mapcairn.com/api/theme/ThemeStylesheetOptions.md): Where a theme override applies.
- [`ThemeStylesheetRefused`](https://docs.mapcairn.com/api/theme/ThemeStylesheetRefused.md): A theme override that was refused, with the reasons and no stylesheet.
- [`ZLayerName`](https://docs.mapcairn.com/api/theme/ZLayerName.md): Name of a z layer.
