Try slot children

This commit is contained in:
Florian RICHER 2023-10-09 20:35:40 +02:00
parent 8e4800ae8c
commit d8d567cbce

View file

@ -15,22 +15,42 @@ pub fn Timeline(
} }
} }
#[slot]
pub struct TimelineCardContent {
children: ChildrenFn,
}
#[slot]
pub struct TimelineCardSummary {
children: ChildrenFn,
tags: ChildrenFn,
}
#[component] #[component]
pub fn TimelineCard<F, IV>( pub fn TimelineCard(
titles: F, #[prop(default=vec![])] titles: Vec<TimelineCardSummary>,
children: Children, #[prop(default=vec![])] childrens: Vec<TimelineCardContent>,
) -> impl IntoView ) -> impl IntoView {
where
F: Fn() -> IV,
IV: IntoView,
{
view! { view! {
<details> <details>
<summary> <summary>
{ titles() } {
titles.iter().map(|v| view! {
<>
{ (v.children)() }
{
view! {
<div class="flex flex-wrap gap-2 mt-2">
{ (v.tags)() }
</div>
}
}
</>
}).collect_view()
}
<i><Icon icon=Icon::from(FaCaretDownSolid) /></i> <i><Icon icon=Icon::from(FaCaretDownSolid) /></i>
</summary> </summary>
<div>{ children() }</div> <div>{ childrens.iter().map(|v| (v.children)()).collect_view() }</div>
</details> </details>
} }
} }