fc_dioxus/components/
masthead.rs1use crate::{
3 core::{assets, attrs::component_attributes},
4 prelude::*,
5 theme::use_stylesheets,
6};
7const BEM: Bem = Bem::new("fc-masthead");
8
9#[component]
11pub fn Masthead(
12 brand: Element,
13 #[props(default)]
15 href: Option<String>,
16 #[props(default)]
18 mark: Option<Element>,
19 nav_label: AccessibleName,
21 #[props(default)]
23 nav: Option<Element>,
24 #[props(default)] actions: Option<Element>,
25 #[props(default)] class: Option<String>,
26 #[props(extends = GlobalAttributes)] attributes: Vec<Attribute>,
27) -> Element {
28 let attributes = component_attributes(
29 attributes,
30 ClassList::new(BEM.block()).extend(class.as_deref()),
31 &[],
32 );
33 rsx! {
34 if use_stylesheets() { document::Stylesheet { href: assets::COMPONENTS_MASTHEAD_CSS } }
35 header { ..attributes,
36 a { class: BEM.element("brand"), href,
37 if let Some(mark) = mark { span { class: BEM.element("mark"), aria_hidden: "true", {mark} } }
38 {brand}
39 }
40 if let Some(nav) = nav {
41 nav { aria_label: nav_label.to_string(), ul { class: BEM.element("nav"), {nav} } }
42 }
43 if let Some(actions) = actions { div { class: BEM.element("actions"), {actions} } }
44 }
45 }
46}
47
48#[component]
50pub fn MastheadLink(
51 #[props(default)] href: Option<String>,
52 #[props(default)] onclick: Option<EventHandler<MouseEvent>>,
53 #[props(default)] current: bool,
54 #[props(default)] availability: Availability,
55 children: Element,
56) -> Element {
57 rsx! {
58 li { {super::nav_target(BEM.element("link"), href, onclick, current, &availability, Vec::new(), children)} }
59 }
60}