Skip to main content

euv_ui/component/doc_kit/
struct.rs

1use super::*;
2
3/// Single hierarchical heading entry displayed inside `EuvDocToc`.
4#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
5pub struct EuvDocTocItem {
6    /// Heading depth from 1 to 6 controlling outline indentation.
7    #[get(type(copy))]
8    pub(crate) level: u8,
9    /// Canonical heading anchor slug.
10    pub(crate) slug: String,
11    /// Visible heading label.
12    pub(crate) title: String,
13}
14
15/// Interactive hierarchical table-of-contents outline with active heading highlight and click callback.
16#[derive(Clone, CustomDebug, Data, New, Props)]
17pub struct EuvDocToc {
18    /// Ordered table-of-contents heading entries.
19    pub(crate) items: Vec<EuvDocTocItem>,
20    /// Reactive currently active heading slug signal.
21    #[get(type(copy))]
22    pub(crate) active_slug: Signal<String>,
23    /// Active UI theme tokens.
24    #[get(type(copy))]
25    pub(crate) tokens: ThemeTokens,
26    /// Optional heading title above the outline (`"On This Page"` when empty).
27    #[new(skip)]
28    #[prop(custom)]
29    pub(crate) title: String,
30    /// Optional callback invoked with the selected heading slug when clicked.
31    #[new(skip)]
32    #[debug(skip)]
33    #[get(skip)]
34    #[prop(custom)]
35    pub(crate) on_select: Option<MarkdownStrCallback>,
36}
37
38/// Destination descriptor for a previous or next article card inside `EuvDocPager`.
39#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
40pub struct EuvDocPagerLink {
41    /// Target canonical route path.
42    pub(crate) route: String,
43    /// Destination article title.
44    pub(crate) title: String,
45    /// Optional destination section name.
46    pub(crate) section: String,
47}
48
49/// Responsive Previous / Next documentation article navigation card pair.
50#[derive(Clone, CustomDebug, Data, New, Props)]
51pub struct EuvDocPager {
52    /// Optional previous article destination.
53    #[get(skip)]
54    pub(crate) prev: Option<EuvDocPagerLink>,
55    /// Optional next article destination.
56    #[get(skip)]
57    pub(crate) next: Option<EuvDocPagerLink>,
58    /// Reactive active route signal updated on card activation.
59    #[get(type(copy))]
60    pub(crate) active_route: Signal<String>,
61    /// Active UI theme tokens.
62    #[get(type(copy))]
63    pub(crate) tokens: ThemeTokens,
64    /// Optional localized label above the previous article card (`"Previous"` when empty).
65    #[new(skip)]
66    #[prop(custom)]
67    pub(crate) prev_label: String,
68    /// Optional localized label above the next article card (`"Next"` when empty).
69    #[new(skip)]
70    #[prop(custom)]
71    pub(crate) next_label: String,
72    /// Optional callback invoked with the navigated route string.
73    #[new(skip)]
74    #[debug(skip)]
75    #[get(skip)]
76    #[prop(custom)]
77    pub(crate) on_navigate: Option<MarkdownStrCallback>,
78}
79
80/// Collapsible section group containing categorized navigation items for `EuvDocSectionNav`.
81#[derive(Clone, Data, Debug, Eq, New, PartialEq)]
82pub struct EuvDocSectionGroup {
83    /// Visible section header title.
84    pub(crate) title: String,
85    /// Ordered navigation items belonging to this section.
86    pub(crate) items: Vec<EuvNavItem>,
87    /// Whether the section starts expanded (`true` by default).
88    #[new(skip)]
89    #[get(type(copy))]
90    pub(crate) collapsed: bool,
91}
92
93/// Grouped collapsible documentation sidebar navigation with active route indicator and section item counts.
94#[derive(Clone, CustomDebug, Data, New, Props)]
95pub struct EuvDocSectionNav {
96    /// Ordered collapsible documentation section groups.
97    pub(crate) groups: Vec<EuvDocSectionGroup>,
98    /// Reactive active route signal highlighted across all groups.
99    #[get(type(copy))]
100    pub(crate) active_route: Signal<String>,
101    /// Active UI theme tokens.
102    #[get(type(copy))]
103    pub(crate) tokens: ThemeTokens,
104    /// Optional callback invoked with the selected route path.
105    #[new(skip)]
106    #[debug(skip)]
107    #[get(skip)]
108    #[prop(custom)]
109    pub(crate) on_select: Option<MarkdownStrCallback>,
110}
111
112/// Compact article metadata strip showing section badge, reading time, word count, and optional source or update tags.
113#[derive(Clone, Data, Debug, New, Props)]
114pub struct EuvDocMetaBar {
115    /// Primary documentation section label.
116    pub(crate) section: String,
117    /// Estimated reading duration in minutes (clamped to at least 1).
118    #[get(type(copy))]
119    pub(crate) reading_minutes: usize,
120    /// Total prose word count in the article.
121    #[get(type(copy))]
122    pub(crate) word_count: usize,
123    /// Active UI theme tokens.
124    #[get(type(copy))]
125    pub(crate) tokens: ThemeTokens,
126    /// Optional last-updated date or timestamp string.
127    #[new(skip)]
128    #[prop(custom)]
129    pub(crate) updated: String,
130    /// Optional route or source file metadata label.
131    #[new(skip)]
132    #[prop(custom)]
133    pub(crate) source_path: String,
134}
135
136/// Reactive header node handle bundle for a collapsible `EuvDocSectionNav` section group.
137pub(crate) struct DocSectionHeaderEntry {
138    /// Section title text node.
139    pub(crate) hdr_id: NodeId,
140    /// Section item count badge node.
141    pub(crate) badge_id: NodeId,
142    /// Section item count badge label text node.
143    pub(crate) badge_txt_id: NodeId,
144    /// Collapsible chevron canvas node.
145    pub(crate) chev_id: NodeId,
146    /// Section items container column node.
147    pub(crate) list_id: NodeId,
148    /// Reactive expanded state signal.
149    pub(crate) open_sig: Signal<bool>,
150    /// Route paths owned by this section group.
151    pub(crate) routes: Vec<String>,
152}