mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-02 08:34:15 -05:00
2be216043e
* feat: extract utils as the library * fix: thaw_components dependencies
21 lines
451 B
Rust
21 lines
451 B
Rust
use super::Fallback;
|
|
use leptos::*;
|
|
|
|
#[component]
|
|
pub fn OptionComp<T, CF, IV>(
|
|
value: Option<T>,
|
|
children: CF,
|
|
#[prop(optional)] fallback: Option<Fallback>,
|
|
) -> impl IntoView
|
|
where
|
|
CF: FnOnce(T) -> IV + 'static,
|
|
IV: IntoView,
|
|
{
|
|
if let Some(value) = value {
|
|
children(value).into_view()
|
|
} else if let Some(fallback) = fallback {
|
|
(fallback.children)().into_view()
|
|
} else {
|
|
().into_view()
|
|
}
|
|
}
|