Aurora. Uix. Templates. ThemeHelper
(Aurora UIX v0.1.4-rc.1)
Copy Markdown
Provides helper functions for embedding theme-based styles within HEEx templates.
Offers a convenient way to include compiled or dynamic themeable stylesheets. Leverages the configured theme module to apply consistent styling and manage CSS rule generation.
Summary
Functions
Generates a complete stylesheet from all rules in the theme module.
Extracts the rule contents and replace and create a new rule using the target_name.
Registers and retrieves all available themes.
Returns the configured theme module.
Returns the name of the configured theme.
Functions
@spec generate_stylesheet() :: binary()
Generates a complete stylesheet from all rules in the theme module.
Returns
binary() - All the :root_colors from all the registered themes plus the CSS rules from the configured theme module.
Examples
iex> generate_stylesheet(MyApp.Theme)
["<style>.button { color: blue; }</style>", "<style>.card { ... }</style>"]
Extracts the rule contents and replace and create a new rule using the target_name.
Parameters
rule_source(atom()) - rule name to import from.target_name(binary()|atom()) - rule to create.
Returns
binary()- The new css rule.
@spec registered_themes() :: map()
Registers and retrieves all available themes.
@spec theme_module() :: module()
Returns the configured theme module.
Returns
module() | nil - The theme module configured at compile time, nil if the configured module name
is not registered. This might provoke an error in calling modules.
Examples
iex> theme_module()
Aurora.Uix.Templates.Basic.Themes.WhiteCharcoal
@spec theme_name() :: atom()
Returns the name of the configured theme.
Returns
atom() - The name of the configured theme.
Examples
iex> theme_name()
:white_charcoal