# `PhiaUiDesign.Canvas.Variables`
[🔗](https://github.com/charlenopires/PhiaUI/blob/v0.1.17/lib/phiaui_design/canvas/variables.ex#L1)

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"}
    }

# `variable_def`

```elixir
@type variable_def() :: %{
  value: term(),
  type: :color | :spacing | :number | :string,
  theme_overrides: %{optional(atom()) =&gt; term()}
}
```

# `delete`

```elixir
@spec delete(reference(), String.t()) :: :ok
```

Delete a single variable.

# `get_all`

```elixir
@spec get_all(reference()) :: %{required(String.t()) =&gt; variable_def()}
```

Get all variables from the scene.

# `is_variable_ref?`

```elixir
@spec is_variable_ref?(term()) :: boolean()
```

Check if a value is a variable reference (`"$..."`).

# `put`

```elixir
@spec put(reference(), String.t(), variable_def()) :: :ok
```

Set a single variable.

# `put_all`

```elixir
@spec put_all(reference(), %{required(String.t()) =&gt; variable_def()}) :: :ok
```

Merge multiple variables at once.

# `resolve`

```elixir
@spec resolve(term(), reference(), atom()) :: term()
```

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_attrs`

```elixir
@spec resolve_attrs(map(), reference(), atom()) :: map()
```

Resolve all variable references in an attrs map.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
