Raxol.Style.Colors.Theme (Raxol v0.2.0)
View SourceManages color themes for the Raxol application.
This module provides functionality for:
- Creating and managing themes
- Applying themes to the application
- Accessing theme colors
- Updating theme colors
Summary
Functions
Applies a theme to the application.
Creates a dark mode version of a theme.
Creates a high contrast version of a theme.
Creates a new theme from a given palette map and optional name.
Gets all UI colors from a theme.
Gets a UI color from a theme.
Creates a standard theme with default colors.
Updates UI colors in a theme.
Types
Functions
Applies a theme to the application.
Parameters
theme
- The theme to apply
Returns
:ok
on success{:error, reason}
on failure
Creates a dark mode version of a theme.
Parameters
theme
- The theme to create a dark mode version of
Returns
- A new theme with dark mode colors
Creates a high contrast version of a theme.
Parameters
theme
- The theme to create a high contrast version of
Returns
- A new theme with high contrast colors
Creates a new theme from a given palette map and optional name.
Assumes the input palette map contains Color structs or maps convertible to Color structs.
Parameters
palette
- A map representing the color palette (e.g., %{"primary" => %{r: 0, g: 119, b: 204, a: 1.0}, ...})name
(optional) - The name for the theme. Defaults to "Custom".
Returns
- A new theme struct.
Examples
iex> nord_palette = Raxol.Style.Colors.Palette.nord()
iex> theme = Raxol.Style.Colors.Theme.from_palette(nord_palette, "Nord Theme")
iex> theme.name
"Nord Theme"
iex> theme.palette["polar_night_1"]
%{r: 46, g: 52, b: 64, a: 1.0}
Gets all UI colors from a theme.
Parameters
theme
- The theme to get the colors from
Returns
- A map of UI elements to their colors
Gets a UI color from a theme.
Parameters
theme
- The theme to get the color fromelement
- The UI element to get the color for
Returns
- The color for the specified UI element
Creates a standard theme with default colors.
Returns
- A new theme with default colors
Updates UI colors in a theme.
Parameters
theme
- The theme to updatecolors
- A map of UI elements to their new colors
Returns
- The updated theme