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"
}
Summary
Functions
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.
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.
Initial set of expanded sections. Mirrors the legacy default of "colors" being open by default.
Toggle a section's expanded/collapsed state in the MapSet.
Functions
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 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.
Initial set of expanded sections. Mirrors the legacy default of "colors" being open by default.
Attributes
form(:any) (required) - A Phoenix.HTML.Form built withas: :formatting.myself(:any) (required) - phx-target — the parent LC's myself.open_sections(:any) (required) - MapSet of section keys currently expanded.
Toggle a section's expanded/collapsed state in the MapSet.