Runtime theme operations for host modules using Pote.Theme.
All functions in this module receive the host module as their first
argument and call host_module.config_app/0, host_module.storage_dir/0,
and host_module.defaults/0 at runtime. This allows the host module
to override storage_dir/0 freely without any macro recompilation.
Summary
Functions
Activates a theme by name. Writes through to :theme_active.
Returns the active theme as a Pote.Theme.Theme struct.
Looks up a single colour key in the active theme.
Returns the colour map for the active theme.
Installs a theme to disk. Accepts a Pote.Theme.Theme struct.
Installs a built-in template theme by name.
Lists all themes available in storage_dir.
Registers the resolver with Pote so Pote.parse("theme:<key>")
and atom lookups consult this theme system. Idempotent.
Returns the list of built-in template theme names.
Functions
Activates a theme by name. Writes through to :theme_active.
@spec active(module()) :: Pote.Theme.Theme.t()
Returns the active theme as a Pote.Theme.Theme struct.
Reads :theme_active from the application's config, loads the
JSON file, and returns the parsed theme. Falls back to the
built-in default theme when no theme is selected or the
active file is unreadable.
@spec color(module(), String.t()) :: {:ok, Pote.Theme.Theme.rgb()} | :not_found
Looks up a single colour key in the active theme.
Returns {:ok, {r, g, b}} on hit, :not_found on miss.
@spec colors(module()) :: %{optional(String.t()) => Pote.Theme.Theme.rgb()}
Returns the colour map for the active theme.
@spec install!(module(), Pote.Theme.Theme.t()) :: :ok | {:error, term()}
Installs a theme to disk. Accepts a Pote.Theme.Theme struct.
Installs a built-in template theme by name.
Returns :ok if the template was installed, {:error, :not_found}
if the template does not exist.
Lists all themes available in storage_dir.
@spec register_with_pote(module()) :: :ok
Registers the resolver with Pote so Pote.parse("theme:<key>")
and atom lookups consult this theme system. Idempotent.
@spec templates() :: [String.t()]
Returns the list of built-in template theme names.