Raxol.UI.StyleHelper (Raxol v2.9.2)

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.

The text attributes (:bold, :italic, :underline, :strikethrough, :reverse, :dim) set in a merged component style, for a component that builds its own element style from it.

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.

text_attributes(style)

@spec text_attributes(map()) :: map()

The text attributes (:bold, :italic, :underline, :strikethrough, :reverse, :dim) set in a merged component style, for a component that builds its own element style from it.