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]
|
||||
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>
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue