Site Wide Semantic Colour Tokens

P2 priority Donep2-ft-site-wide-semantic-colour-tokens

One semantic token layer for every theme value

Stage
03-done
Author
Ivan Hawkes
Created
Completed
References

One semantic token layer drives every theme dependent value.

Colour is declared in two layers, and a component reads only the upper one. The palette in be-best/assets/css/main.css carries every colour value, once per scheme, under --palette-* names. be-best/assets/css/tokens.css names the roles components read and aliases the palette. The @theme inline block in main.css puts a role behind every colour utility, so a class in a template names a role and never a colour. The names and the layers are recorded in the technical specification.

Work The Whole Theme Around The Tokens

Acceptance Criteria

Findings: The Contrast Re-tune

The first pass at this table took the sRGB channels of a colour, gamma encoded them, and summed that into a relative luminance, which understates every ratio: the muted ink on a panel measured 1.8 and is 3.4. Recomputed from the linear channels WCAG defines, the pairs it asks about (4.5:1 for text, 3:1 for an icon, a control boundary, a focus ring or an indicator) looked like this before the re-tune, and this after:

pairlightdark
muted ink on a panel3.4 → 6.87.1 → 9.3
muted ink on a sunken surface4.2 → 8.26.1 → 8.0
brand as ink on a panel4.0 → 4.93.3 → 7.9
fill ink on a brand fill5.2 → 6.45.2 → 8.8
fill ink on a danger fill4.6 → 6.42.8 → 6.5
danger as text on a panel3.5 → 4.96.0 → 5.8
success as text on a panel5.2 → 5.77.5 → 8.6
a heading on a panel8.1 → 10.86.3 → 10.2
a link on a panel11.1 → 13.78.5 → 12.8
a link on a pointer2.7 → 6.64.8 → 10.4
a control boundary on a panel1.1 → 3.63.4 → 3.6
the focus ring against a panel4.0 → 4.93.3 → 7.9
ink on the brand tint (next/prev)— → 12.9— → 18.1
the language chip ink on the bar— → 4.8— → 4.8

What the re-tune touched, all of it in the palette layer and the roles that alias it:

Three fixes came out of reading the roles rather than the colours:

The pairs are measured from the built token values behind dashboard/raw/all-html-elements.html, the raw element fixture: 34 pairs, both schemes, all pass at 4.5:1 for text and 3:1 for a graphic.