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

generate_stylesheet()

@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>"]

import_rule(rule_source, target_name)

(macro)
@spec import_rule(atom(), binary() | atom()) :: Macro.t()

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.

registered_themes()

@spec registered_themes() :: map()

Registers and retrieves all available themes.

theme_module()

@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

theme_name()

@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