Raxol.Style.Theme (Raxol v0.2.0)
View SourceTheme management for Raxol applications.
This module provides functionality for creating, switching, and customizing themes. Themes define the visual appearance of the application, including colors, borders, and component-specific styles.
Summary
Functions
Applies a theme by its name, setting it as the current theme for the process.
Creates and registers a high-contrast variant based on predefined high-contrast colors. This variant overrides the color palette.
Gets the current active theme. Returns the default theme if none is set.
Exports the current theme as a map suitable for serialization.
Gets a color from the current theme's palette, considering active variants. Checks the active variant first, then the base palette. (Note: Need a way to know the active variant - maybe from Accessibility state?) This is a placeholder - the logic to check active variant needs refinement.
Gets a style from the current theme by name.
Gets a specific theme struct by its name. Returns nil if the theme name is not found.
Imports a theme from the given map data.
Returns a list of available theme structs.
Creates a new theme with the specified attributes.
Registers a new style in the current theme.
Registers a theme variant. Theme variants allow for alternate visual styles like high-contrast, dark mode, etc. A variant can include overrides for both :styles and :color_palette.
Sets the color palette for the current theme.
Sets the current active theme.
Types
Functions
@spec apply_theme(String.t()) :: :ok | :error
Applies a theme by its name, setting it as the current theme for the process.
Returns :ok
if the theme was found and applied, :error
otherwise.
Creates and registers a high-contrast variant based on predefined high-contrast colors. This variant overrides the color palette.
Gets the current active theme. Returns the default theme if none is set.
Exports the current theme as a map suitable for serialization.
Gets a color from the current theme's palette, considering active variants. Checks the active variant first, then the base palette. (Note: Need a way to know the active variant - maybe from Accessibility state?) This is a placeholder - the logic to check active variant needs refinement.
Gets a style from the current theme by name.
Gets a specific theme struct by its name. Returns nil if the theme name is not found.
Imports a theme from the given map data.
@spec list_themes() :: [t()]
Returns a list of available theme structs.
Creates a new theme with the specified attributes.
Registers a new style in the current theme.
Registers a theme variant. Theme variants allow for alternate visual styles like high-contrast, dark mode, etc. A variant can include overrides for both :styles and :color_palette.
Sets the color palette for the current theme.
Sets the current active theme.