mirror of
https://github.com/adoyle0/thaw.git
synced 2025-03-13 14:09:49 -04:00
57 lines
1.6 KiB
Rust
57 lines
1.6 KiB
Rust
mod breadcrumb_item;
|
|
mod theme;
|
|
|
|
use crate::{
|
|
use_theme,
|
|
utils::{class_list::class_list, mount_style},
|
|
Theme,
|
|
};
|
|
pub use breadcrumb_item::BreadcrumbItem;
|
|
use leptos::*;
|
|
pub use theme::BreadcrumbTheme;
|
|
|
|
#[component]
|
|
pub fn Breadcrumb(
|
|
#[prop(default = MaybeSignal::Static("/".to_string()),into)] separator: MaybeSignal<String>,
|
|
#[prop(optional, into)] class: MaybeSignal<String>,
|
|
children: Children,
|
|
) -> impl IntoView {
|
|
mount_style("breadcrumb", include_str!("./breadcrumb.css"));
|
|
let theme = use_theme(Theme::light);
|
|
let css_vars = create_memo(move |_| {
|
|
let mut css_vars = String::new();
|
|
theme.with(|theme| {
|
|
css_vars.push_str(&format!(
|
|
"--thaw-font-color: {};",
|
|
theme.breadcrumb.item_font_color
|
|
));
|
|
css_vars.push_str(&format!(
|
|
"--thaw-font-color-hover: {};",
|
|
theme.breadcrumb.item_font_color_hover
|
|
));
|
|
css_vars.push_str(&format!(
|
|
"--thaw-background-color-hover: {};",
|
|
theme.breadcrumb.item_background_color_hover
|
|
));
|
|
});
|
|
css_vars
|
|
});
|
|
|
|
view! {
|
|
<Provider value=BreadcrumbSeparatorInjection(separator)>
|
|
<nav
|
|
class=class_list!["thaw-breadcrumb", move || class.get()]
|
|
style=move || css_vars.get()
|
|
>
|
|
<ul>{children()}</ul>
|
|
</nav>
|
|
</Provider>
|
|
}
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub(crate) struct BreadcrumbSeparatorInjection(MaybeSignal<String>);
|
|
|
|
pub(crate) fn use_breadcrumb_separator() -> BreadcrumbSeparatorInjection {
|
|
expect_context()
|
|
}
|