Twm.Config.Theme (Twm v0.1.0)
View SourceTheme helper functions for Twm.
This module provides functions for working with themes in Tailwind CSS classes.
It converts the TypeScript fromTheme
functions to Elixir.
Summary
Functions
Returns animate-related theme values.
Returns aspect-related theme values.
Returns blur-related theme values.
Returns breakpoint-related theme values.
Calls a theme getter function with the provided theme configuration.
Returns color-related theme values.
Returns container-related theme values.
Returns drop-shadow-related theme values.
Returns ease-related theme values.
Returns font-related theme values.
Returns font-weight-related theme values.
Creates a theme getter function for the specified theme key.
Returns inset-shadow-related theme values.
Returns leading-related theme values.
Returns perspective-related theme values.
Returns radius-related theme values.
Returns shadow-related theme values.
Returns spacing-related theme values.
Returns text-related theme values.
Returns text-shadow-related theme values.
Checks if a value is a theme getter.
Returns tracking-related theme values.
Functions
Returns animate-related theme values.
This is a convenience function for the animate theme.
Returns aspect-related theme values.
This is a convenience function for the aspect theme.
Returns blur-related theme values.
This is a convenience function for the blur theme.
Returns breakpoint-related theme values.
This is a convenience function for the breakpoint theme.
@spec call_theme_getter(Twm.Config.Theme.ThemeGetter.t() | function(), map()) :: list()
Calls a theme getter function with the provided theme configuration.
This function handles both ThemeGetter
structs and regular functions
for backwards compatibility.
Parameters
theme_getter
- AThemeGetter
struct or regular functiontheme_config
- The theme configuration map
Examples
iex> theme_spacing = Twm.Config.Theme.from_theme(:spacing)
iex> config = %{spacing: ["1", "2", "4"]}
iex> Twm.Config.Theme.call_theme_getter(theme_spacing, config)
["1", "2", "4"]
Returns color-related theme values.
This is a convenience function for the color theme.
Returns container-related theme values.
This is a convenience function for the container theme.
Returns drop-shadow-related theme values.
This is a convenience function for the drop-shadow theme.
Returns ease-related theme values.
This is a convenience function for the ease theme.
Returns font-related theme values.
This is a convenience function for the font theme.
Returns font-weight-related theme values.
This is a convenience function for the font-weight theme.
@spec from_theme(String.t() | atom()) :: Twm.Config.Theme.ThemeGetter.t()
Creates a theme getter function for the specified theme key.
This is the Elixir equivalent of the TypeScript fromTheme
function.
Returns a ThemeGetter
struct that can be identified as a theme getter
and called to extract theme values.
Parameters
theme_key
- The theme key to extract from theme configuration (string or atom)
Returns
A ThemeGetter
struct containing:
:key
- The theme key:getter_fn
- Function that extracts values from theme config:is_theme_getter
- Alwaystrue
to mark this as a theme getter
Examples
iex> theme_spacing = Twm.Config.Theme.from_theme("spacing")
iex> theme_spacing.is_theme_getter
true
iex> theme_color = Twm.Config.Theme.from_theme(:color)
iex> theme_color.key
:color
iex> theme_config = %{spacing: ["1", "2", "4", "8"]}
iex> theme_spacing = Twm.Config.Theme.from_theme("spacing")
iex> Twm.Config.Theme.call_theme_getter(theme_spacing, theme_config)
["1", "2", "4", "8"]
iex> theme_config = %{color: ["red", "blue"]}
iex> theme_missing = Twm.Config.Theme.from_theme("missing")
iex> Twm.Config.Theme.call_theme_getter(theme_missing, theme_config)
[]
Returns inset-shadow-related theme values.
This is a convenience function for the inset-shadow theme.
Returns leading-related theme values.
This is a convenience function for the leading theme.
Returns perspective-related theme values.
This is a convenience function for the perspective theme.
Returns radius-related theme values.
This is a convenience function for the radius theme.
Returns shadow-related theme values.
This is a convenience function for the shadow theme.
Returns spacing-related theme values.
This is a convenience function for the spacing theme.
Returns text-related theme values.
This is a convenience function for the text theme.
Returns text-shadow-related theme values.
This is a convenience function for the text-shadow theme.
Checks if a value is a theme getter.
Examples
iex> theme_spacing = Twm.Config.Theme.from_theme(:spacing)
iex> Twm.Config.Theme.theme_getter?(theme_spacing)
true
iex> regular_func = fn x -> x end
iex> Twm.Config.Theme.theme_getter?(regular_func)
false
Returns tracking-related theme values.
This is a convenience function for the tracking theme.