impulse_thaw/breadcrumb/
mod.rs

1use leptos::prelude::*;
2use thaw_utils::{class_list, mount_style};
3
4#[component]
5pub fn Breadcrumb(
6    #[prop(optional, into)] class: MaybeProp<String>,
7    children: Children,
8) -> impl IntoView {
9    mount_style("breadcrumb", include_str!("./breadcrumb.css"));
10
11    view! {
12        <nav class=class_list!["thaw-breadcrumb", class]>
13            <ol role="list" class="thaw-breadcrumb__list">
14                {children()}
15            </ol>
16        </nav>
17    }
18}
19
20#[component]
21pub fn BreadcrumbItem(
22    #[prop(optional, into)] class: MaybeProp<String>,
23    children: Children,
24) -> impl IntoView {
25    view! { <li class=class_list!["thaw-breadcrumb-item", class]>{children()}</li> }
26}
27
28#[component]
29pub fn BreadcrumbButton(
30    #[prop(optional, into)] class: MaybeProp<String>,
31    /// Defines current sate of BreadcrumbButton.
32    #[prop(optional, into)]
33    current: Signal<bool>,
34    children: Children,
35) -> impl IntoView {
36    view! {
37        <button
38            class=class_list![
39                "thaw-breadcrumb-button",
40                ("thaw-breadcrumb-button--current", move || current.get()),
41                class
42            ]
43            aria-disabled=move || current.get().then(|| "true")
44            aria-current=move || current.get().then(|| "page")
45        >
46            {children()}
47        </button>
48    }
49}
50
51#[component]
52pub fn BreadcrumbDivider(#[prop(optional, into)] class: MaybeProp<String>) -> impl IntoView {
53    view! {
54        <li class=class_list!["thaw-breadcrumb-divider", class] aria-hidden="true">
55            <svg
56                fill="currentColor"
57                aria-hidden="true"
58                width="1em"
59                height="1em"
60                viewBox="0 0 20 20"
61            >
62                <path
63                    d="M7.65 4.15c.2-.2.5-.2.7 0l5.49 5.46c.21.22.21.57 0 .78l-5.49 5.46a.5.5 0 0 1-.7-.7L12.8 10 7.65 4.85a.5.5 0 0 1 0-.7Z"
64                    fill="currentColor"
65                ></path>
66            </svg>
67        </li>
68    }
69}