Guppy.App.Theme (guppy v0.1.0)

Copy Markdown View Source

App-scoped theme metadata and semantic tokens.

Themes are plain Elixir data. They validate semantic color tokens and resolve style definitions to canonical primitive IR style tuples before native render.

Summary

Functions

Looks up a semantic color token in a validated theme.

Returns a theme color reference for use inside theme style definitions.

Returns one of Guppy's built-in default themes.

Returns a validated theme refined from an existing theme and override data.

Looks up a resolved semantic style token in a validated theme.

Types

appearance()

@type appearance() :: :light | :dark | :system

color_role()

@type color_role() ::
  :bg
  | :text_color
  | :text_bg
  | :border_color
  | :text_decoration_color
  | :strikethrough_color

color_value()

@type color_value() :: atom() | String.t()

t()

@type t() :: %Guppy.App.Theme{
  appearance: appearance(),
  colors: %{optional(String.t()) => color_value()},
  id: String.t(),
  metadata: map(),
  name: String.t(),
  styles: %{optional(String.t()) => list()}
}

Functions

color(theme, token)

@spec color(t(), atom() | String.t()) :: {:ok, color_value()} | {:error, term()}

Looks up a semantic color token in a validated theme.

color_ref(role, token)

@spec color_ref(color_role(), atom() | String.t()) ::
  {:theme_color, color_role(), atom() | String.t()}

Returns a theme color reference for use inside theme style definitions.

default(atom)

@spec default(:dark | :light) :: t()

Returns one of Guppy's built-in default themes.

refine(theme, overrides)

@spec refine(t(), map() | keyword()) :: {:ok, t()} | {:error, term()}

Returns a validated theme refined from an existing theme and override data.

style(theme, token)

@spec style(t(), atom() | String.t()) :: {:ok, list()} | {:error, term()}

Looks up a resolved semantic style token in a validated theme.