use leptos::prelude::*;
#[component]
pub fn Inspector(children: Children) -> impl IntoView {
view! { <div class="nightshade-inspector">{children()}</div> }
}
#[component]
pub fn InspectorSection(
#[prop(into)] title: String,
#[prop(default = true)] default_open: bool,
#[prop(optional, into)] actions: ViewFn,
children: ChildrenFn,
) -> impl IntoView {
let open = RwSignal::new(default_open);
view! {
<div class="nightshade-inspector-section">
<div class="nightshade-inspector-headrow">
<button
class="nightshade-inspector-header"
on:click=move |_| open.update(|value| *value = !*value)
>
<span class="nightshade-inspector-caret" class:open=move || open.get()>
"\u{25b8}"
</span>
{title}
</button>
<div class="nightshade-inspector-actions">{actions.run()}</div>
</div>
<Show when=move || open.get() fallback=|| ()>
<div class="nightshade-inspector-body">{children()}</div>
</Show>
</div>
}
}
#[component]
pub fn InspectorRow(#[prop(into)] label: String, children: Children) -> impl IntoView {
view! {
<div class="nightshade-inspector-row">
<span class="nightshade-inspector-label">{label}</span>
<div class="nightshade-inspector-control">{children()}</div>
</div>
}
}