Raxol.UI.StyleHelper (Raxol v2.6.0)

View Source

Shared style/theme merging for UI components.

Consolidates the repeated pattern of merging context theme, component theme, component-specific theme styles, and inline styles that was duplicated across 11+ component render/2 functions.

Summary

Functions

Merges theme and style for a component render pass.

Merges theme/style and applies focus styling if the component is focused.

Functions

merge_component_styles(state, context, component_name)

@spec merge_component_styles(map(), map(), atom()) :: map()

Merges theme and style for a component render pass.

Precedence (lowest to highest):

  1. Context theme (from parent/app)
  2. Component-specific theme styles (via Theme.component_style/2)
  3. Component's inline state.style

Returns the merged base style map.

merge_component_styles_with_focus(state, context, component_name)

@spec merge_component_styles_with_focus(map(), map(), atom()) :: map()

Merges theme/style and applies focus styling if the component is focused.

Combines merge_component_styles/3 with FocusHelper.maybe_focus_style/3.