Raxol.Core.ColorSystem (Raxol v0.2.0)

View Source

Provides access to the application's color palette, considering the current theme and accessibility settings (like high contrast mode).

Components should use ColorSystem.get/2 to retrieve semantic colors.

Summary

Functions

Gets the effective color value for a given semantic color name.

Gets a color value and ensures it's returned in a specific format (e.g., RGB tuple). Useful when a specific color representation is required for rendering.

Functions

get(theme_id, color_name)

@spec get(atom(), atom()) :: Raxol.Style.Colors.color_value() | nil

Gets the effective color value for a given semantic color name.

It retrieves the color from the specified theme (by ID), automatically considering whether a high contrast variant is active based on accessibility settings.

Args:

  • theme_id: The atom ID of the theme to use (e.g., :default, :dark).
  • color_name: The semantic name of the color (e.g., :primary, :background).

Returns the color value (e.g., :red, {:rgb, r, g, b}) or nil if not found.

get_as(theme_id, color_name, format \\ :term)

@spec get_as(atom(), atom(), atom()) :: any() | nil

Gets a color value and ensures it's returned in a specific format (e.g., RGB tuple). Useful when a specific color representation is required for rendering.

Args:

  • theme_id: The atom ID of the theme to use.
  • color_name: The semantic name of the color.
  • format: The desired output format (:rgb_tuple, :hex_string, :term).

Supported formats: :rgb_tuple, :hex_string, :term