roundel/theme
Every export of roundel/theme, with its signature and doc comment: rgb256, toOklab, audit, fly, plus 3 types.
The theme (R4, R5): one map from token to style, flown once for the whole program.
import { rgb256, toOklab, audit, … } from 'roundel/theme';Functions
audit
Every token's verdict, as data — without throwing.
function audit(theme?: Theme): ThemeFinding[];| Parameter | Type |
|---|---|
theme (optional) | Theme |
Returns ThemeFinding[]
fly
Fly the theme: decide the colour level from the runtime once, check every hex token
against the ground, and set what the tokens paint from now on. Call it at startup, with
{ json } when the run was asked for --json; a later call replaces the theme.
function fly(theme: Theme, rt: Runtime, opts?: ModeOptions): void;| Parameter | Type |
|---|---|
theme | Theme |
rt | Runtime |
opts (optional) | ModeOptions |
Returns void
rgb256
The sRGB of a 256-palette index, which is ansi256 run backwards. Defined for 16–255 only,
and that is the whole reason this check is possible: entries 0–15 are the user's terminal
theme and entries 16–255 are not. Exported because it is the only honest way to ask
"what will the terminal actually paint", which is a question a caller checking its own
theme has as much right to ask as fly() does. The 6×6×6 cube and the 24-step grey ramp are the xterm
values every terminal ships and none of them themes, so a contrast number over them is
measured rather than invented — which is exactly what contrast.ts says cannot be done for
the basic sixteen. ansi256 never returns below 16, so every paint it produces is knowable.
function rgb256(index: number): Hex;| Parameter | Type |
|---|---|
index | number |
Returns Hex
toOklab
sRGB 0–255 to OKLab. Björn Ottosson's matrices, written as straight-line arithmetic.
function toOklab(r: number, g: number, b: number): [number, number, number];| Parameter | Type |
|---|---|
r | number |
g | number |
b | number |
Returns [number, number, number]
Types
Hex
type Hex = `#${string}`;Style
type Style = Hex | readonly Format[];Theme
A theme: a style per token, the ground the hex ones are checked against, and which WCAG level to hold them to.
type Theme = Partial<Record<TokenName, Style>> & {
ground?: Hex;
conformance?: Conformance;
};roundel/plugin
Every export of roundel/plugin, with its signature and doc comment: validate, register, reset, theme, contributions, registered and 2 more, plus 3 types.
roundel/contrast
Every export of roundel/contrast, with its signature and doc comment: channels, luminance, contrast, reportTheme, AA, AAA and 2 more, plus 2 types.