Raxol.Core.Accessibility.ThemeIntegration (Raxol v2.0.1)

View Source

Manages the integration between accessibility settings and the active theme.

Listens for accessibility changes (e.g., high contrast toggle) and updates the active theme accordingly.

Summary

Functions

Apply the current accessibility settings to components. This function is typically called during initialization to ensure components reflect the persisted preferences. Accepts a keyword list of options (e.g., [high_contrast: true, ...]).

Clean up the theme integration.

Returns the current accessibility mode based on settings. Defaults to :normal if high contrast is off.

Returns the current active theme variant for accessibility-aware theming. Used by the renderer and theming system to select the correct theme variant.

Get the current color scheme based on accessibility settings.

Get the current text scale based on accessibility settings.

Get the current theme based on accessibility settings.

Handle high contrast mode changes. Updates the theme based on high contrast setting.

Handle large text setting changes.

Handle reduced motion setting changes.

Initialize the theme integration.

Functions

apply_settings(options)

Apply the current accessibility settings to components. This function is typically called during initialization to ensure components reflect the persisted preferences. Accepts a keyword list of options (e.g., [high_contrast: true, ...]).

cleanup()

Clean up the theme integration.

Unregisters event handlers.

Examples

iex> ThemeIntegration.cleanup()
:ok

get_accessibility_mode()

@spec get_accessibility_mode() :: :high_contrast | :standard

Returns the current accessibility mode based on settings. Defaults to :normal if high contrast is off.

get_active_variant()

@spec get_active_variant() :: :high_contrast | :reduced_motion | :standard

Returns the current active theme variant for accessibility-aware theming. Used by the renderer and theming system to select the correct theme variant.

Examples

iex> ThemeIntegration.get_active_variant()
:standard | :high_contrast | :reduced_motion

get_color_scheme()

@spec get_color_scheme() :: %{
  bg: :black | {:rgb, 30, 30, 30},
  fg: :white | {:rgb, 220, 220, 220},
  accent: :yellow | :blue,
  error: :red,
  success: :green,
  warning: :yellow
}

Get the current color scheme based on accessibility settings.

Examples

iex> ThemeIntegration.get_color_scheme()
%{bg: :black, fg: :white}  # Returns high contrast colors when enabled

get_text_scale()

@spec get_text_scale() :: float()

Get the current text scale based on accessibility settings.

Examples

iex> ThemeIntegration.get_text_scale()
1.5  # Returns scale factor for large text mode

get_theme()

Get the current theme based on accessibility settings.

Examples

iex> ThemeIntegration.get_theme()
%Theme{}  # Returns the current theme with accessibility adjustments

handle_high_contrast(arg)

Handle high contrast mode changes. Updates the theme based on high contrast setting.

handle_large_text(arg)

Handle large text setting changes.

Examples

iex> ThemeIntegration.handle_large_text({:accessibility_large_text, true})
:ok

handle_reduced_motion(arg)

Handle reduced motion setting changes.

Examples

iex> ThemeIntegration.handle_reduced_motion({:accessibility_reduced_motion, true})
:ok

init()

Initialize the theme integration.

Registers event handlers for accessibility setting changes.

Examples

iex> ThemeIntegration.init()
:ok