Raxol.UI.ThemeResolver (Raxol v2.0.1)
View SourceConsolidated theme resolution, color processing, and theme-related utilities.
This module provides theme resolution with optional caching for high-performance applications.
Configuration
Set the default caching strategy in application config:
config :raxol, :theme_resolver,
cache_enabled: trueOr control per-call with options:
ThemeResolver.resolve_styles(attrs, component_type, theme, cache: true)Migration from ThemeResolverCached
Replace:
Raxol.UI.ThemeResolverCached.resolve_styles(attrs, component_type, theme)
Raxol.UI.ThemeResolverCached.get_default_theme()With:
Raxol.UI.ThemeResolver.resolve_styles(attrs, component_type, theme, cache: true)
Raxol.UI.ThemeResolver.get_default_theme(cache: true)Examples
# Non-cached (simple operations)
theme = ThemeResolver.resolve_element_theme(element_theme, default_theme)
# Cached (performance-critical operations)
{fg, bg, attrs} = ThemeResolver.resolve_styles(attrs, :button, theme, cache: true)
Summary
Functions
Clear all theme/style caches.
Creates a fallback theme when no default theme is available.
Gets component styles from theme.
Gets the default theme with fallback creation.
Invalidate cache entries for a specific theme.
Merges themes for inheritance (parent theme as base, child theme overrides).
Resolves background color with proper fallbacks.
Resolves an element's theme, handling string themes and providing fallbacks.
Resolves an element's theme with inheritance support.
Resolves foreground color with proper fallbacks.
Resolves style attributes from explicit attrs and component styles.
Resolves foreground and background colors with proper fallbacks. Returns {fg_color, bg_color, style_attrs}.
Resolves color from theme variant.
Functions
Clear all theme/style caches.
Creates a fallback theme when no default theme is available.
Gets component styles from theme.
Gets the default theme with fallback creation.
Options
cache: boolean()- Enable caching for this operation (default: false)
Invalidate cache entries for a specific theme.
Merges themes for inheritance (parent theme as base, child theme overrides).
Resolves background color with proper fallbacks.
Resolves an element's theme, handling string themes and providing fallbacks.
Options
cache: boolean()- Enable caching for this operation (default: false)
Resolves an element's theme with inheritance support.
Options
cache: boolean()- Enable caching for this operation (default: false)
Resolves foreground color with proper fallbacks.
Resolves style attributes from explicit attrs and component styles.
Resolves foreground and background colors with proper fallbacks. Returns {fg_color, bg_color, style_attrs}.
Options
cache: boolean()- Enable caching for this operation (default: false)
Resolves color from theme variant.