Raxol.Core.Accessibility.ThemeIntegration (Raxol v0.4.0)

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 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() :: atom()

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

get_active_variant()

@spec get_active_variant() :: atom()

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()
:normal | :high_contrast

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