basecoat_core/props/sidebar.rs
1use crate::{AttrMap, BasecoatProps, Children, Markup};
2use std::borrow::Cow;
3
4/// Sidebar — maps to CSS class `.sidebar`.
5///
6/// Renders a responsive `<aside>` that behaves as an in-flow column above the
7/// `breakpoint_px` viewport width and as an overlay drawer below it. The
8/// matching WASM controller (`basecoat-controllers`) reads/writes the
9/// expanded/collapsed state to `localStorage` under the key
10/// `basecoat:sidebar:{id}` and toggles the `data-state` attribute.
11///
12/// The `id` is required: it is the key used both for the localStorage entry
13/// and for matching the sibling toggle button's `aria-controls`/
14/// `data-sidebar-toggle` attribute.
15#[derive(BasecoatProps, Default, Clone, Debug)]
16pub struct SidebarProps {
17 /// Unique DOM id — required for the controller and localStorage key.
18 #[prop(optional, into)]
19 pub id: Option<Cow<'static, str>>,
20 /// Optional `<header class="sidebar-header">` content rendered at the top.
21 #[prop(optional)]
22 pub header: Option<Markup>,
23 /// Optional `<footer class="sidebar-footer">` content rendered at the bottom.
24 #[prop(optional)]
25 pub footer: Option<Markup>,
26 /// Initial expanded state. Defaults to `true`. The controller reconciles
27 /// this against `localStorage` on hydrate.
28 #[prop(default = true)]
29 pub default_open: bool,
30 /// Viewport breakpoint in CSS pixels above which the sidebar is in-flow
31 /// rather than an overlay drawer. Defaults to `768.0` (Tailwind `md`).
32 #[prop(default = 768.0)]
33 pub breakpoint_px: f64,
34 #[prop(optional, into)]
35 pub class: Option<Cow<'static, str>>,
36 #[prop(extend)]
37 pub attrs: AttrMap,
38 pub children: Children,
39}