Try slot children
This commit is contained in:
parent
8e4800ae8c
commit
d8d567cbce
1 changed files with 30 additions and 10 deletions
|
@ -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>
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue