use crate::assets::navbar_style::NAVBAR_STYLES;
use crate::enums::navbar_enums::NavbarWithLogoConfig;
use crate::Orientation;
use dioxus::prelude::*;
#[component]
pub fn NavbarWithLogo(navbar_logo_config: NavbarWithLogoConfig) -> Element {
let mut menu_open = use_signal(|| false);
let orientation_class = match navbar_logo_config
.orientation
.clone()
.unwrap_or(Orientation::Right)
{
Orientation::Left => "menu-items left",
Orientation::Center => "menu-items center",
Orientation::Right => "menu-items right",
};
rsx! {
div {
style { "{NAVBAR_STYLES}" }
nav {
class: "navbar",
style: "background-color: {navbar_logo_config.background_color.as_css_class()};",
div { class: "nav-div",
Link { to: "{navbar_logo_config.logo_url}",
img {
class: "nav-logo",
src: "{navbar_logo_config.logo_src}",
alt: "{navbar_logo_config.logo_alt}",
}
}
button {
class: "hamburger",
onclick: move |_| menu_open.set(!menu_open()),
match menu_open() {
true => {
rsx! {
svg {
xmlns: "http://www.w3.org/2000/svg",
width: "32",
height: "32",
view_box: "0 0 24 24",
fill: "none",
stroke: "{navbar_logo_config.icon_color.as_css_class()}",
stroke_width: "2",
stroke_linecap: "round",
stroke_linejoin: "round",
path { d: "M18 6L6 18M6 6L18 18" }
}
}
}
false => {
rsx! {
svg {
xmlns: "http://www.w3.org/2000/svg",
width: "32",
height: "32",
view_box: "0 0 24 24",
fill: "none",
stroke: "{navbar_logo_config.icon_color.as_css_class()}",
stroke_width: "2",
stroke_linecap: "round",
stroke_linejoin: "round",
path { d: "M4 6h16M4 12h16M4 18h16" }
}
}
}
}
}
}
div {
class: match menu_open() {
true => "menu open",
false => "menu",
},
style: "background-color: {navbar_logo_config.background_color.as_css_class()};",
div { class: "{orientation_class}",
for (item , link) in navbar_logo_config.nav_items.iter().zip(navbar_logo_config.nav_links.iter()) {
Link {
class: "menu-item",
to: "{link}",
style: "color: {navbar_logo_config.nav_item_color.as_css_class()};",
onclick: move |_| menu_open.set(false),
"{item}"
}
}
}
}
}
}
}
}