Skip to content

Adopt component macro 0.5.0: required props, Into setters, composed apply - #28

Draft
JedimEmO wants to merge 1 commit into
mainfrom
improve-component-macro
Draft

Adopt component macro 0.5.0: required props, Into setters, composed apply#28
JedimEmO wants to merge 1 commit into
mainfrom
improve-component-macro

Conversation

@JedimEmO

Copy link
Copy Markdown
Owner

Summary

Adopts futures-signals-component-macro 0.5.0 across dwui and the webpage. Depends on that PR — see the merge checklist below.

Required props, enforced at compile time

card.content, heading.content, and virtual_scroll.render_item are now #[required]. Omitting them was previously a silent empty render (or a placeholder div for the virtual scroller); it is now a targeted compile error:

error[E0277]: missing required props for component `card`
   | required props: `content` — set each with `.content(...)`

The enforcement immediately caught two real bugs: card! call sites in components_page.rs and example_small.rs that injected children through .apply() and never set content — both now pass real content nodes.

#[into] ergonomics

All Option<Dom>, String, and optional-scalar props across 26 components take impl Into<T> now. Call-site cleanup: 50 .content(Some(...)).content(...), 86 literal .to_string() args dropped, and the four .content(html!(...).into()) sites that would have become ambiguous pass the Dom directly.

Spotlight bug fixed by composed apply

section_card calls .apply(crate::fx::spotlight) followed by a second .apply(...); under 0.4 the second call silently discarded the first, so the gallery spotlight effect was dead code. With composing apply it works again — verified in headless Chrome: all 24 section cards carry the --sx/--sy spotlight vars on hover, layout is unchanged, zero console errors, and the restructured modal example opens with its focus trap intact.

Render-fn apply handling is untouched (the prop keeps its Option<Box<dyn FnOnce>> type) — dwui compiled with zero source edits against the new macro before any of this adoption, which was verified explicitly.

Test plan

  • cargo check --workspace --all-targets, cargo test (native)
  • wasm-pack test --headless --firefox crates/dwui — 51 component + 19 styling browser tests green
  • cargo clippy — zero new warnings vs baseline; cargo fmt --check at exact parity with pre-existing state
  • trunk build + headless-Chrome visual verification of the components page (spotlight vars, layout, modal open/close)
  • cargo doc -p dwui — generated macro doc tables now mark [required] and impl Into<T> setters

Merge checklist

🤖 Generated with Claude Code

…pply

Bumps futures-signals-component-macro to 0.5.0 (via a temporary
[patch.crates-io] path override until it is published) and adopts its
new opt-in features across dwui and the webpage:

- card.content, heading.content, and virtual_scroll.render_item are now
  #[required], so omitting them is a compile error instead of a silent
  empty render; render fns drop the Option handling and render_item
  loses its fake |_| html!("div") default.
- #[into] on all Option<Dom>, String, and optional-scalar props across
  26 components. Call sites shed 50 .content(Some(...)) wrappers and 86
  literal .to_string() calls, and the four .content(x.into()) args that
  would have become ambiguous now pass the Dom directly.
- The two card! call sites that injected children through .apply()
  instead of setting content (caught by the new compile-time
  enforcement) now pass real content nodes.
- The composed apply fixes the components-page spotlight: the second
  .apply() call no longer discards fx::spotlight, so section cards
  light up under the cursor again (verified in headless Chrome: all 24
  cards carry the --sx/--sy vars, layout unchanged, no console errors).

The [patch.crates-io] override must be dropped once 0.5.0 is on
crates.io.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant