Skip to main content

orbital_base_components/drawer/
parts.rs

1use leptos::prelude::*;
2
3#[component]
4pub fn BaseDrawerHeader(
5    #[prop(optional, into)] class: MaybeProp<String>,
6    children: Children,
7) -> impl IntoView {
8    view! {
9        <header
10            class=move || {
11                let mut parts = vec!["orbital-drawer-header".to_string()];
12                if let Some(extra) = class.get() {
13                    if !extra.is_empty() {
14                        parts.push(extra);
15                    }
16                }
17                parts.join(" ")
18            }
19        >
20            {children()}
21        </header>
22    }
23}
24
25#[slot]
26pub struct DrawerHeaderTitleAction {
27    pub children: Children,
28}
29
30#[component]
31pub fn BaseDrawerHeaderTitle(
32    #[prop(optional, into)] class: MaybeProp<String>,
33    #[prop(optional)] drawer_header_title_action: Option<DrawerHeaderTitleAction>,
34    children: Children,
35) -> impl IntoView {
36    view! {
37        <div
38            class=move || {
39                let mut parts = vec!["orbital-drawer-header-title".to_string()];
40                if let Some(extra) = class.get() {
41                    if !extra.is_empty() {
42                        parts.push(extra);
43                    }
44                }
45                parts.join(" ")
46            }
47        >
48            <h2 class="orbital-drawer-header-title__heading">{children()}</h2>
49            {drawer_header_title_action.map(|action| {
50                view! {
51                    <div class="orbital-drawer-header-title__action">
52                        {(action.children)()}
53                    </div>
54                }
55            })}
56        </div>
57    }
58}
59
60#[component]
61pub fn BaseDrawerBody(
62    #[prop(optional, into)] class: MaybeProp<String>,
63    children: Children,
64) -> impl IntoView {
65    view! {
66        <div
67            class=move || {
68                let mut parts = vec!["orbital-drawer-body".to_string()];
69                if let Some(extra) = class.get() {
70                    if !extra.is_empty() {
71                        parts.push(extra);
72                    }
73                }
74                parts.join(" ")
75            }
76        >
77            {children()}
78        </div>
79    }
80}