Variable/token system for the PhiaUI Design canvas.
Variables are stored in the scene's ETS table under the :__variables__ key.
Each variable has a name, value, type, and optional theme overrides.
Variable references in attrs use the "$name" syntax. The resolve/3 function
replaces these references with concrete values based on the current theme.
Variable definition
%{
value: "#3b82f6",
type: :color,
theme_overrides: %{dark: "#60a5fa"}
}
Summary
Functions
Delete a single variable.
Get all variables from the scene.
Check if a value is a variable reference ("$...").
Set a single variable.
Merge multiple variables at once.
Resolve a value that may be a variable reference.
Resolve all variable references in an attrs map.
Types
Functions
Delete a single variable.
@spec get_all(reference()) :: %{required(String.t()) => variable_def()}
Get all variables from the scene.
Check if a value is a variable reference ("$...").
@spec put(reference(), String.t(), variable_def()) :: :ok
Set a single variable.
@spec put_all(reference(), %{required(String.t()) => variable_def()}) :: :ok
Merge multiple variables at once.
Resolve a value that may be a variable reference.
If the value is a string starting with "$", look it up in the scene's
variables and return the concrete value (respecting theme overrides).
Otherwise, return the value as-is.
Resolve all variable references in an attrs map.