Skip to main content

nightshade_api/web/
status_bar.rs

1//! A horizontal status strip built from small labelled cells, like an editor's bottom bar.
2
3use leptos::prelude::*;
4
5/// The status strip container. Renders a `role="status"` row and lays out its
6/// `StatusItem` and `StatusSpacer` children left to right.
7#[component]
8pub fn StatusBar(children: Children) -> impl IntoView {
9    view! { <div class="nightshade-status-bar" role="status">{children()}</div> }
10}
11
12/// A single cell in the status bar. Shows an optional leading `icon` before the
13/// children, and forwards an extra `class` for styling.
14#[component]
15pub fn StatusItem(
16    #[prop(into, optional)] icon: String,
17    #[prop(into, optional)] class: String,
18    children: Children,
19) -> impl IntoView {
20    let has_icon = !icon.is_empty();
21    view! {
22        <div class=format!("nightshade-status-item {class}")>
23            {has_icon.then(|| view! { <span class="nightshade-status-icon">{icon}</span> })}
24            {children()}
25        </div>
26    }
27}
28
29/// A flexible gap that pushes the items after it to the far end of the bar.
30#[component]
31pub fn StatusSpacer() -> impl IntoView {
32    view! { <div class="nightshade-status-spacer"></div> }
33}