# `Athanor.Components.Formatting.EditorForm`
[🔗](https://github.com/Arsenalist/athanor/blob/v0.1.0-beta.7/lib/athanor/components/formatting/editor_form.ex#L1)

Shared formatting tab UI fragment. Stateless function component.

Each component's editor form LC embeds this via
`Athanor.Components.EditorForm.Shell`. On change, the formatting form
fires `phx-change="update_props"` scoped to the parent LC — the LC's
`handle_event("update_props", %{"formatting" => fmt} = _params, ...)`
pattern-matches the formatting-only shape and writes it wholesale into
`props["formatting"]`.

Saved JSON shape (matches legacy):

    props["formatting"] = %{
      "text_color" => "#RRGGBB" | "",
      "background_color" => "#RRGGBB" | "",
      "border_color" => "#RRGGBB" | "",
      "padding_top" => integer,
      "padding_bottom" => integer,
      "padding_left" => integer,
      "padding_right" => integer,
      "margin_top" => integer,
      "margin_bottom" => integer,
      "margin_left" => integer,
      "margin_right" => integer,
      "border_radius" => integer,
      "border_width" => integer,
      "alignment" => "left" | "center" | "right"
    }

# `build_form`

Build a `Phoenix.HTML.Form` for the formatting fields, defaulted from the
existing formatting map (or an empty map). Use `as: :formatting` so all
fields submit under the `formatting[...]` namespace.

Returns a tracked form ready to pass to `editor_form/1`.

# `coerce_params`

Coerce the params map from a formatting-form phx-change into a clean
prop-ready map (integer fields converted from strings). Matches the JSON
shape on disk.

# `default_open_sections`

Initial set of expanded sections. Mirrors the legacy default of
"colors" being open by default.

# `editor_form`

## Attributes

* `form` (`:any`) (required) - A Phoenix.HTML.Form built with `as: :formatting`.
* `myself` (`:any`) (required) - phx-target — the parent LC's myself.
* `open_sections` (`:any`) (required) - MapSet of section keys currently expanded.

# `toggle_section`

Toggle a section's expanded/collapsed state in the MapSet.

---

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