Refactor ruin_app, add some README files, minor usability in reactivity

This commit is contained in:
2026-03-25 22:32:11 -04:00
parent 5f67c06083
commit 341d07d82f
28 changed files with 2782 additions and 2118 deletions

View File

@@ -686,23 +686,49 @@ fn expand_node(node: &Node) -> proc_macro2::TokenStream {
let value = &property.value;
quote! { .#name(#value) }
});
let children = expand_children(&node.children);
if is_component_path(path) {
// Component nodes: eager children so #[component] builder impls keep working.
let children = expand_children(&node.children);
quote! {
#path::builder()
#(#prop_calls)*
.children(#children)
}
} else {
} else if is_text_path(path) {
// text(): children are TextChildren (string/value), not Views — keep eager.
let children = expand_children(&node.children);
quote! {
::ruin_app::#path()
#(#prop_calls)*
.children(#children)
}
} else {
// Primitive container nodes (column, row, block, button, scroll_box, …):
// Wrap children in a LazyChildren closure so that PartialTextStyle context is
// pushed BEFORE children run, enabling correct text style inheritance.
//
// Each child is spread via Children::into_views(), which handles:
// - Child::Node results (View) via impl<T: IntoView> Children for T
// - &str literals via Children for &str
// - ChildViews (slot values) via Children for ChildViews (flattens)
let items = node.children.iter().map(expand_child);
quote! {
::ruin_app::#path()
#(#prop_calls)*
.children(::ruin_app::LazyChildren(|| {
let mut __v: ::std::vec::Vec<::ruin_app::View> = ::std::vec::Vec::new();
#(__v.extend(::ruin_app::Children::into_views(#items));)*
__v
}))
}
}
}
fn is_text_path(path: &Path) -> bool {
path.segments.len() == 1 && path.segments[0].ident == "text"
}
fn expand_provider_node(node: &Node) -> proc_macro2::TokenStream {
let path = &node.path;
let value = match node.props.as_slice() {