Lets the emails draw with the site's own values. It reads a style's design tokens out of the stylesheets the client loads, src/tokens.css and then src/themes/<style>.css, so styles.ts names a token wherever it needs a color, a gradient, a font or a radius, and a change to a theme reaches its emails with nothing copied to keep in step.

Mail clients know no custom properties, so a token comes back resolved for one scheme: its var()s followed, its light-dark() picked, its color-mix() computed. Only the rules that set tokens on the root element are read (:root, the style's [data-style], and either of those with the scheme's [data-color-scheme]); a theme states its forced schemes that way beside each prefers-color-scheme block, so the media blocks are skipped.

Functions

f
readTokens(
style: StyleName,
scheme: Scheme
): ThemeTokens

Returns the tokens of style in scheme, read from the site's stylesheets at the time of the call. styles.ts reads each style once, at load.

Interfaces

I
ThemeTokens

Returned by readTokens: the tokens of one style in one scheme, read as the kind of value each is.

Type Aliases

T
Scheme = "light" | "dark"

A scheme a token is resolved for. "auto" is drawn from both.