mod theme; use crate::{ components::*, icon::*, use_theme, utils::{mount_style::mount_style, StoredMaybeSignal}, Theme, }; use leptos::*; pub use theme::NavBarTheme; #[component] pub fn NavBar( #[prop(optional, into)] title: MaybeSignal, #[prop(optional, into)] left_arrow: MaybeSignal, #[prop(optional, into)] left_text: MaybeSignal, #[prop(optional, into)] on_click_left: Option>, #[prop(optional, into)] right_text: MaybeSignal, #[prop(optional, into)] on_click_right: Option>, ) -> impl IntoView { mount_style("nav-bar", include_str!("./nav-bar.css")); let theme = use_theme(Theme::light); let css_vars = create_memo(move |_| { theme.with(|theme| { format!( "--thaw-background-color: {};", theme.nav_bar.background_color ) }) }); let title: StoredMaybeSignal<_> = title.into(); let left_text: StoredMaybeSignal<_> = left_text.into(); let right_text: StoredMaybeSignal<_> = right_text.into(); let on_click_left = move |ev| { if let Some(click_left) = on_click_left.as_ref() { click_left.call(ev); } }; let on_click_right = move |ev| { if let Some(click_right) = on_click_right.as_ref() { click_right.call(ev); } }; view! {
{move || left_text.get()}
{move || title.get()}
{move || right_text.get()}
} }