feat(dsl): add a library of structural screen layouts

feat(dsl): add a library of structural screen layouts

#2 in tonybierman/dioxus-mcp — merged 2026-05-28

What

Adds 12 page-level structural screen layouts to the registry, selectable via a screen's template.kind exactly like the existing kinds:

Structural Navigation Content
holy_grail, bento_grid, masonry, full_bleed sticky_sidebar, mega_menu, drawer card_grid, editorial, hero_scroll, split_screen, scroll_sticky

*interactive — templates wire a use_signal open/close toggle.

How

Each layout is a complex: false LayoutDescriptor:

  • a Tailwind-classed minijinja template that emits a full component file (honors wrap_with via conditional wrapper braces; {{ root_class }} rides along as a customization hook so class: overrides still apply)
  • a preview skeleton for the cockpit navigator's approximate render

They're seeded as built-ins (registry::builtin_layouts) so they ship with every project and surface in get_registry. No DSL parser or render-pipeline changes — the registry's runtime-layout path (render_registry_layout) already supported this shape.

The CORE_SCREEN DSL spec now documents the structural kinds, notes the Tailwind assumption, and points at get_registry as the authoritative list.

Styling / scope decisions

  • Tailwind utility classes (matches the existing styled: tailwind preset on client_crud) — no CSS files, no schema change. Generated Rust compiles regardless of whether Tailwind is wired up; it just won't look styled without it.
  • Deliberately skips the CSS-technique trio (subgrid / container-query / intrinsic) — those are styling techniques more than distinct page shells.

Files

  • crates/dioxus-mcp/src/tools/dsl/layout_library.rs (new) — 12 templates, library_layouts(), tests
  • crates/dioxus-mcp/src/tools/dsl/mod.rspub(crate) mod layout_library;
  • crates/dioxus-mcp/src/registry.rs — chain library into builtin_layouts() (5 → 17); count tests updated
  • crates/dioxus-mcp/src/tools/dsl/specs.rsCORE_SCREEN doc + holy_grail example

Verification

  • Full suite green (458 + 39 tests); cargo fmt + cargo clippy --all-targets -D warnings clean.
  • Real compile check: rendered all 12 bodies and compiled them against actual Dioxus 0.7 — the conditional class: if … {}, if/for nodes, event closures, and use_signal toggles all build clean (the one thing string-level tests can't prove).
  • Confirmed live get_registry returns all 12 once the server runs the rebuilt binary.

🤖 Generated with Claude Code

Last updated 2026-05-28