Raxol.UI.Theming.PaletteRegistry (Raxol v2.0.1)

View Source

Registry for custom color palettes used in the Raxol theming system.

This module provides persistent storage and management of custom color palettes that can be used with the Colors.convert_to_palette/2 function.

Summary

Functions

Returns a specification to start this module under a supervisor.

Checks if a palette exists.

Gets a custom palette by name.

Lists all registered custom palettes.

Registers a custom color palette.

Unregisters a custom color palette.

Updates an existing palette.

Types

color_index()

@type color_index() :: 0..255

color_rgb()

@type color_rgb() :: {0..255, 0..255, 0..255}

palette()

@type palette() :: [palette_color()]

palette_color()

@type palette_color() :: {color_index(), color_rgb()}

palette_name()

@type palette_name() :: atom()

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

exists?(name)

Checks if a palette exists.

Examples

iex> exists?(:my_palette)
true

iex> exists?(:nonexistent)
false

get(name)

Gets a custom palette by name.

Examples

iex> get(:my_palette)
{:ok, [{0, {0, 0, 0}}, {1, {255, 255, 255}}]}

iex> get(:nonexistent)
{:error, :not_found}

handle_manager_call(request, from, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_call/3.

handle_manager_cast(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_cast/2.

handle_manager_info(msg, state)

Callback implementation for Raxol.Core.Behaviours.BaseManager.handle_manager_info/2.

list()

Lists all registered custom palettes.

Examples

iex> list()
[:my_palette, :another_palette]

register(name, colors)

Registers a custom color palette.

Examples

iex> register(:my_palette, [{0, {0, 0, 0}}, {1, {255, 255, 255}}])
:ok

start_link(init_opts \\ [])

unregister(name)

Unregisters a custom color palette.

Examples

iex> unregister(:my_palette)
:ok

update(name, colors)

Updates an existing palette.

Examples

iex> update(:my_palette, [{0, {0, 0, 0}}, {1, {128, 128, 128}}])
:ok