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]
pub fn TimelineCard<F, IV>(
titles: F,
children: Children,
) -> impl IntoView
where
F: Fn() -> IV,
IV: IntoView,
{
pub fn TimelineCard(
#[prop(default=vec![])] titles: Vec<TimelineCardSummary>,
#[prop(default=vec![])] childrens: Vec<TimelineCardContent>,
) -> impl IntoView {
view! {
<details>
<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>
</summary>
<div>{ children() }</div>
<div>{ childrens.iter().map(|v| (v.children)()).collect_view() }</div>
</details>
}
}