MithrilUI.Theme.Generator (Mithril UI v0.1.2)
View SourceGenerates DaisyUI-compatible theme CSS from Phoenix configuration.
This module reads custom theme definitions from the application config and generates CSS that can be used with DaisyUI's theming system.
Usage
Define themes in your config:
config :mithril_ui,
themes: [
%{
name: "brand_light",
label: "Brand Light",
color_scheme: :light,
colors: %{
primary: "#4F46E5",
primary_content: "#FFFFFF",
# ... other colors
}
}
]Generate CSS:
MithrilUI.Theme.Generator.generate_css()
# => "[data-theme=\"brand_light\"] { ... }"Or use the mix task:
mix mithril_ui.gen.themes
Summary
Functions
Returns the default output path for generated theme CSS.
Generates CSS for all custom themes defined in config.
Generates CSS for a single theme definition.
Writes generated CSS to the specified file path.
Functions
@spec default_output_path() :: String.t()
Returns the default output path for generated theme CSS.
@spec generate_css() :: String.t()
Generates CSS for all custom themes defined in config.
Returns a string containing all theme CSS rules.
Generates CSS for a single theme definition.
Parameters
theme- A map containing theme configuration
Example
theme = %{
name: "custom",
color_scheme: :light,
colors: %{primary: "#4F46E5"}
}
MithrilUI.Theme.Generator.theme_to_css(theme)
Writes generated CSS to the specified file path.
Returns :ok on success or {:error, reason} on failure.