Skip to main content

nightshade_api/web/base/
panel.rs

1use leptos::prelude::*;
2
3/// A framed section, typically for editor sidebars. A non-empty `title` renders
4/// a header above the `children`, which fill the panel body.
5#[component]
6pub fn Panel(
7    #[prop(into, optional)] title: String,
8    #[prop(into, optional)] class: String,
9    children: Children,
10) -> impl IntoView {
11    let header = (!title.is_empty())
12        .then(|| view! { <div class="nightshade-panel-title">{title.clone()}</div> });
13    view! {
14        <div class=format!("nightshade-panel {class}")>
15            {header}
16            <div class="nightshade-panel-body">{children()}</div>
17        </div>
18    }
19}