Mailglass.Components.Theme (Mailglass v0.1.0)

Copy Markdown View Source

Theme-token resolver backed by :persistent_term.

Reads the brand theme cached by Mailglass.Config.validate_at_boot!/0 (D-19). The theme map shape:

[
  colors: %{ink: "#0D1B2A", glass: "#277B96", ...},
  fonts:  %{body: "...", display: "...", mono: "..."}
]

All reads are O(1). Unknown tokens fall back to sensible defaults rather than raising — components render even if boot-time validation has not yet populated the cache (e.g. in minimal test setups).

Summary

Functions

Returns the hex color for a brand token.

Returns the font-stack string for a font role.

Returns the cached theme keyword list. Empty list when uncached.

Functions

color(token)

(since 0.1.0)
@spec color(atom()) :: String.t()

Returns the hex color for a brand token.

Accepts :ink, :glass, :ice, :mist, :paper, :slate by default. Falls back to #277B96 (Glass) for unknown tokens.

Examples

iex> Mailglass.Components.Theme.color(:unknown_token)
"#277B96"

font(role)

(since 0.1.0)
@spec font(atom()) :: String.t()

Returns the font-stack string for a font role.

Accepts :body, :display, :mono by default. Falls back to sans-serif for unknown roles.

get()

(since 0.1.0)
@spec get() :: keyword()

Returns the cached theme keyword list. Empty list when uncached.