Skip to main content

orbital_base_components/button/
compound_button.rs

1use leptos::prelude::*;
2
3use super::BaseButton;
4
5#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
6pub enum CompoundButtonIconPosition {
7    #[default]
8    Before,
9    After,
10}
11
12#[component]
13pub fn BaseCompoundButton(
14    #[prop(optional, into)] class: MaybeProp<String>,
15    #[prop(optional, into)] appearance: MaybeProp<String>,
16    #[prop(optional, into)] shape: MaybeProp<String>,
17    #[prop(optional, into)] size: MaybeProp<String>,
18    #[prop(optional, into)] disabled: Signal<bool>,
19    #[prop(optional, into)] disabled_focusable: Signal<bool>,
20    #[prop(optional, into)] secondary_content: MaybeProp<String>,
21    #[prop(optional)] on_click: Option<Callback<leptos::ev::MouseEvent>>,
22    #[prop(optional)] icon_before: Option<Children>,
23    #[prop(optional)] icon_after: Option<Children>,
24    children: Children,
25) -> impl IntoView {
26    view! {
27        <BaseButton
28            class=class
29            appearance=appearance
30            shape=shape
31            size=size
32            disabled=disabled
33            disabled_focusable=disabled_focusable
34            nostrip:on_click=on_click
35        >
36            <span class="orbital-compound-button__content">
37                {icon_before.map(|c| c())}
38                <span class="orbital-compound-button__text">
39                    <span class="orbital-compound-button__primary">{children()}</span>
40                    {move || secondary_content.get().map(|text| view! {
41                        <span class="orbital-compound-button__secondary">{text}</span>
42                    })}
43                </span>
44                {icon_after.map(|c| c())}
45            </span>
46        </BaseButton>
47    }
48}