AshUi.Phoenix.RootLayout (ash_ui_phoenix v0.1.0)

Copy Markdown View Source

Document assembly for routed AshUi resources (DESIGN.md §9).

The layout is a framework function of declared data — there are no root_layout_* env/assign channels and no fallback hrefs:

  • <base href> derived from the mount scope (conn.script_name), so relative stylesheet hrefs resolve correctly at any route depth.
  • One <link rel="stylesheet"> per EFFECTIVE stylesheet of the routed resource (AshUi.Info.stylesheets/1), linked in declared order. Each declared entry is served as-declared, resolved against the base.
  • The framework runtime scripts (blueprint_runtime_script_paths/0), unconditional.
  • Runtime-state stamping (see below).

Runtime state contract

Runtime state is host-stamped, never compiled: a map with the optional keys :scheme, :fonts, and :zoom, provided under the SINGLE key :ash_ui_runtime_state — as a layout assign, or in the Plug session under "ash_ui_runtime_state" (assign wins):

%{scheme: "dark", fonts: %{ui: "Inter", mono: "Iosevka"}, zoom: 1.25}

Stamping (each key only when present; absent runtime state stamps nothing):

  • scheme → data-theme="<scheme>" on <html>. Palette blocks live in token stylesheets keyed on :root[data-theme=…].
  • fonts → one --font-<name>: <value> custom property per entry, inline on <html>.
  • zoom → the <html> root font-size (16px * zoom). Generated layout sizing is rem-based, so this is the single document scale knob.

A theme or font change is an attribute/token flip — never a re-link, never a recompile.

Summary

Functions

The framework runtime script paths, linked unconditionally in every AshUi document.

Functions

blueprint_runtime_script_paths()

The framework runtime script paths, linked unconditionally in every AshUi document.

render(assigns)