euv_ui/component/toc/view/struct.rs
1use super::*;
2
3/// One entry of the [`euv_toc`] anchor list.
4#[derive(Clone, Copy, CustomDebug, Data, Default, New)]
5pub struct EuvTocItem {
6 /// The heading level (levels deeper than 2 render indented).
7 #[get(type(copy))]
8 pub level: u8,
9 /// The display text.
10 #[get(type(copy))]
11 pub text: &'static str,
12 /// The full href (for hash routers typically `#<route>#<anchor>`).
13 #[get(type(copy))]
14 pub href: &'static str,
15}
16
17/// Props for the [`euv_toc`] component.
18#[derive(Clone, CustomDebug, Default)]
19pub struct EuvTocProps {
20 /// The list title (for example `On this page`).
21 pub title: &'static str,
22 /// The anchor items.
23 pub items: &'static [EuvTocItem],
24 /// The `href` of the entry the reader is currently at; that entry
25 /// renders the `_active` class.
26 ///
27 /// A signal rather than a plain field so scroll-driven highlighting
28 /// is ordinary reactive state the renderer owns: the caller writes
29 /// the signal and the TOC repaints from it. A caller with no
30 /// scroll spy leaves this empty and every entry renders inactive.
31 pub active: Signal<String>,
32}