From 1e27d18cb360933efaab734d37159dae4f26eee0 Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Tue, 10 Oct 2023 20:04:29 +0200 Subject: [PATCH] Implement Timeline (No css) --- src/app/components/timeline.rs | 105 ++++++++++++++++++++++++--------- 1 file changed, 78 insertions(+), 27 deletions(-) diff --git a/src/app/components/timeline.rs b/src/app/components/timeline.rs index da5e516..ef35f6f 100644 --- a/src/app/components/timeline.rs +++ b/src/app/components/timeline.rs @@ -4,53 +4,104 @@ use leptos_icons::*; #[component] pub fn Timeline( - children: Children + #[prop(default=vec![])] elements: Vec, ) -> impl IntoView { view! {
    - { children() } + { elements.collect_view() }
} } +#[slot] +pub struct TimelineElementLabel { + children: ChildrenFn, +} + +impl IntoView for TimelineElementLabel { + fn into_view(self) -> View { + let view = view! { <>{ (self.children)() } }; + view.into_view() + } +} + +#[slot] +pub struct TimelineElement { + #[prop(default=vec![])] labels: Vec, + #[prop(default=vec![])] cards: Vec, +} + +impl IntoView for TimelineElement { + fn into_view(self) -> View { + let view = view! { +
  • +
    + { self.labels.collect_view() } +
    +
    + { self.cards.collect_view() } +
    +
  • + }; + view.into_view() + } +} + #[slot] pub struct TimelineCardContent { children: ChildrenFn, } +impl IntoView for TimelineCardContent { + fn into_view(self) -> View { + let view = view! { <>{ (self.children)() } }; + view.into_view() + } +} + #[slot] pub struct TimelineCardSummary { children: ChildrenFn, tags: ChildrenFn, } -#[component] -pub fn TimelineCard( - #[prop(default=vec![])] titles: Vec, - #[prop(default=vec![])] childrens: Vec, -) -> impl IntoView { - view! { -
    - +impl IntoView for TimelineCardSummary { + fn into_view(self) -> View { + let view = view! { + <> + { (self.children)() } { - titles.iter().map(|v| view! { - <> - { (v.children)() } - { - view! { -
    - { (v.tags)() } -
    - } - } - - }).collect_view() + view! { +
    + { (self.tags)() } +
    + } } - -
    -
    { childrens.iter().map(|v| (v.children)()).collect_view() }
    -
    + + }; + view.into_view() } -} \ No newline at end of file +} + +#[slot] +pub struct TimelineCard { + #[prop(default=vec![])] titles: Vec, + #[prop(default=vec![])] cards: Vec, +} + +impl IntoView for TimelineCard { + fn into_view(self) -> View { + let view = view! { +
    + + { self.titles.collect_view() } + + +
    { self.cards.collect_view() }
    +
    + }; + view.into_view() + } +}