mirror of
https://github.com/adoyle0/thaw.git
synced 2025-03-13 05:59:49 -04:00
✨ feat: add option component
This commit is contained in:
parent
13df204940
commit
10f5403826
4 changed files with 27 additions and 17 deletions
|
@ -1,5 +1,5 @@
|
||||||
mod theme;
|
mod theme;
|
||||||
use crate::{theme::*, utils::mount_style::mount_style};
|
use crate::{components::*, theme::*, utils::mount_style::mount_style};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_icons::*;
|
use leptos_icons::*;
|
||||||
use stylers::style_sheet_str;
|
use stylers::style_sheet_str;
|
||||||
|
@ -77,22 +77,14 @@ pub fn Button(
|
||||||
class=("melt-button--round", move || round.get())
|
class=("melt-button--round", move || round.get())
|
||||||
style=move || css_vars.get()
|
style=move || css_vars.get()
|
||||||
>
|
>
|
||||||
{
|
<OptionComp value=icon view=move |cx, icon| {
|
||||||
if let Some(icon) = icon {
|
|
||||||
view!{cx,
|
view!{cx,
|
||||||
<Icon icon=icon style=icon_style/>
|
<Icon icon=icon style=icon_style/>
|
||||||
}.into()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
|
||||||
if let Some(children) = children {
|
|
||||||
children(cx).into()
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}/>
|
||||||
|
<OptionComp value=children view=move |cx, children| {
|
||||||
|
children(cx).into_view(cx)
|
||||||
|
}/>
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
src/components/mod.rs
Normal file
3
src/components/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
mod option_comp;
|
||||||
|
|
||||||
|
pub use option_comp::*;
|
14
src/components/option_comp.rs
Normal file
14
src/components/option_comp.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
use leptos::*;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn OptionComp<T, VF, IV>(cx: Scope, value: Option<T>, view: VF) -> impl IntoView
|
||||||
|
where
|
||||||
|
VF: Fn(Scope, T) -> IV + 'static,
|
||||||
|
IV: IntoView,
|
||||||
|
{
|
||||||
|
if let Some(value) = value {
|
||||||
|
view(cx, value).into_view(cx)
|
||||||
|
} else {
|
||||||
|
().into_view(cx)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
mod button;
|
mod button;
|
||||||
mod card;
|
mod card;
|
||||||
mod checkbox;
|
mod checkbox;
|
||||||
|
mod components;
|
||||||
mod input;
|
mod input;
|
||||||
mod modal;
|
mod modal;
|
||||||
mod progress;
|
mod progress;
|
||||||
|
|
Loading…
Add table
Reference in a new issue