# `Macaw.Frame.Component`
[🔗](https://github.com/dcoai/macaw_frame/blob/v0.1.0/lib/macaw/frame/component.ex#L1)

Building a Frame (spec/01 §2.3): `use Macaw.Frame.Component` defines a module that is the
Frame in every respect but its name and its registry.

    defmodule MyApp.Frame do
      use Macaw.Frame.Component, name: "my_app.frame", packages: [MyApp.FrameKinds]
    end

**The registry is fixed by the module** (spec/01 §2.3, macaw spec/00 §4.4 rule 3): it
holds `Macaw.Frame.Package` and the packages listed, built once when the module compiles
by `Macaw.Frame.Layers.document/1`, so `declarations/1`, which is handed the settings
alone, reaches the same layer kinds and coordinate models as every transition. A package
list the registry refuses (two kinds of one name, a member with no behavior, a module
that is no package) fails the module's compilation with every fault named. Nothing is
read from the application environment or a process.

**The text measurer is the module's too**: `metrics:` names a module implementing
`Macaw.Layers.Text.Metrics` (macaw_layers#59), which every text the Frame lays out is
measured with: its legends, its labels' fit, its margins and its diagrams' boxes. It is
resolved once, with the theme's font, when the Frame compiles (`Macaw.Layers.Text.measurer/1`,
macaw_layers#63), and every text measures on that resolved measurer. Without it the
Frame measures by `Macaw.Layers.Text.Estimate`, 0.6 em per grapheme, resolved the same way.

The module defined is a `:contained` component of kind `:content` (`use
Macaw.Component`), and its callbacks are the Frame's: `parameters/0` (§2.1),
`declarations/1` (§2.2), `variables/1` (§5.4), `budget/3` and `budget/4` (spec/05 §2,
`Macaw.Frame.Budget`), `order/2`, `reducer/3` and `reducer/4` (spec/05 §3,
`Macaw.Frame.Requests`),
the contained value's transitions `init/2`, `init/3`, `delivery/3`, `size/2`, `bound/3`,
`tick_interval/1` and `tick/2` (§3, `Macaw.Frame.Value`), `segments/1` (the drawing's
binary segments, raw, spec/10 §6), `request/2` (the keyboard's
`"arm"`, `"disarm"` and `"key"`, spec/11 §5.6, `Macaw.Frame.Keyboard`), and `render/2`
(§3.7, §4).
`__registry__/0` answers its registry.

`Macaw.Frame` is the one built with no package beside macaw_frame's own.

# `assets`

```elixir
@spec assets() :: [String.t(), ...]
```

The Frame's static assets (spec/01 §1, spec/10 §3.6): its static stylesheet,
`priv/static/macaw_frame/frame.css`, served from the page's own origin.

# `parameters`

```elixir
@spec parameters() :: %{required(String.t()) =&gt; Macaw.Data.Parameter.t()}
```

The Frame's five parameters (spec/01 §2.1): `design`, the frame document it draws, not
bindable; `title` and `description`, bindable text; `backend`, `"auto"`, `"svg"` or
`"canvas"`; and `sync`, the group of its `:local` keys.

# `registry`

```elixir
@spec registry(term()) :: {:ok, map()} | {:error, String.t()}
```

The registry of `Macaw.Frame.Package` and `packages` (spec/01 §2.3,
`Macaw.Frame.Layers.document/1`), with the context its spatial steps are validated
under: `{:ok, registry}`, or `{:error, message}` naming every fault, which a Frame
module's compilation raises.

# `variables`

```elixir
@spec variables(term(), map()) ::
  {:ok, %{required(String.t()) =&gt; map()}} | {:error, [{list(), term()}, ...]}
```

A design's variables as qualified parameters (spec/01 §5.4): `{:ok, %{"vars.<name>" =>
parameter}}`, each declared variable with its type, default and values, or the
document's faults under `["design"]`. Whether each is bindable is
`Macaw.Component.variables/2`'s rule: a default and a type other than `:term`.

---

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