euv_ui/component/sidebar/view/struct.rs
1use super::*;
2
3/// One node of the [`euv_sidebar`] navigation tree.
4///
5/// A node with empty `children` is a leaf link; a node with children is a
6/// collapsible group whose `link` (when set) navigates to the group index
7/// page without toggling the group.
8#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
9pub struct EuvSidebarItem {
10 /// The display text.
11 #[get(type(copy))]
12 pub text: &'static str,
13 /// The leaf route; groups may link to their index page.
14 #[get(type(copy))]
15 pub link: Option<&'static str>,
16 /// Nested children (non-empty renders a collapsible group).
17 #[get(type(copy))]
18 pub children: &'static [EuvSidebarItem],
19}
20
21/// Props for the [`euv_sidebar`] component.
22///
23/// The `collapsed` signal is caller-owned so several sidebars (desktop aside
24/// and mobile drawer) can share the collapse state; `prefix` is internal and
25/// used by the recursion to key groups.
26#[derive(Clone, CustomDebug, Default)]
27pub struct EuvSidebarProps {
28 /// The current route signal (drives the active link highlight).
29 pub route_signal: Signal<String>,
30 /// The collapsed group keys.
31 pub collapsed: Signal<Vec<String>>,
32 /// The tree items.
33 pub items: &'static [EuvSidebarItem],
34 /// The group key prefix (internal recursion state, leave default).
35 pub prefix: String,
36}
37
38/// Props of the [`euv_sidebar_item`] component.
39#[derive(Clone, CustomDebug, Default)]
40pub struct EuvSidebarItemProps {
41 /// The current route signal.
42 pub route_signal: Signal<String>,
43 /// The collapsed group keys.
44 pub collapsed: Signal<Vec<String>>,
45 /// The item to render.
46 pub item: EuvSidebarItem,
47 /// The group key prefix of the parent.
48 pub prefix: String,
49}