Skip to main content

euv_ui/component/doc_kit/
impl.rs

1use super::*;
2
3/// Fluent builders and theme helpers for `EuvDocToc`.
4impl EuvDocToc {
5    /// Sets a custom heading title displayed above the table-of-contents list.
6    ///
7    /// # Arguments
8    ///
9    /// - `Self` - Source table-of-contents component.
10    /// - `TextValue` - Heading title convertible into `String`.
11    ///
12    /// # Returns
13    ///
14    /// - `Self` - Updated table-of-contents component.
15    #[must_use]
16    pub fn title<TextValue>(mut self, title: TextValue) -> Self
17    where
18        TextValue: Into<String>,
19    {
20        self.set_title(title.into());
21        self
22    }
23
24    /// Registers a callback invoked with the clicked heading anchor slug.
25    ///
26    /// # Arguments
27    ///
28    /// - `Self` - Source table-of-contents component.
29    /// - `CallbackFn` - Selection callback receiving the heading slug slice.
30    ///
31    /// # Returns
32    ///
33    /// - `Self` - Updated table-of-contents component.
34    #[must_use]
35    pub fn on_select<CallbackFn>(mut self, handler: CallbackFn) -> Self
36    where
37        CallbackFn: Fn(&str) + 'static,
38    {
39        self.set_on_select(Some(Rc::new(handler)));
40        self
41    }
42
43    /// Resolves `(row_bg, bar_bg, label_fg)` for a documentation TOC row state.
44    ///
45    /// # Arguments
46    ///
47    /// - `ThemePalette` - Live theme palette.
48    /// - `bool` - Whether this heading matches the active slug.
49    /// - `bool` - Whether the pointer is currently hovering this row.
50    ///
51    /// # Returns
52    ///
53    /// - `(Color, Color, Color)` - Paired row background, rail indicator fill, and readable label color.
54    #[must_use]
55    pub fn row_colors(palette: ThemePalette, active: bool, hovered: bool) -> (Color, Color, Color) {
56        let surface: SurfaceColors =
57            palette.interaction_colors(InteractionRole::NavItem, active, hovered, false);
58        let rail_color: Color = if active {
59            surface.get_border()
60        } else {
61            palette.get_border()
62        };
63        (surface.get_bg(), rail_color, surface.get_fg())
64    }
65}
66
67/// Declarative `#[component]` implementation for `EuvDocToc`.
68#[component]
69/// Inherent implementation of [`EuvDocToc`].
70impl EuvDocToc {
71    /// Renders an interactive hierarchical table-of-contents outline with live active-slug highlighting.
72    ///
73    /// # Arguments
74    ///
75    /// - `&Self` - Table-of-contents component reference.
76    ///
77    /// # Returns
78    ///
79    /// - `NodeId` - Mounted outline card node handle.
80    fn render(&self) -> NodeId {
81        let mut ctx: Context = current_context();
82        let base_tokens: ThemeTokens = self.get_tokens();
83        let init_tok: ThemeTokens = live_tokens_untracked(base_tokens);
84        let init_p: ThemePalette = init_tok.get_palette();
85        let init_g: ThemeGeometry = init_tok.get_geometry();
86        let active_slug: Signal<String> = self.get_active_slug();
87        let hovered_idx: Signal<Option<usize>> = Signal::new(None);
88        let Self {
89            items,
90            title,
91            on_select,
92            ..
93        } = self;
94        let heading_label: &str = if title.trim().is_empty() {
95            DOC_TOC_DEFAULT_TITLE
96        } else {
97            title.as_str()
98        };
99        let init_slug: String = active_slug.get_untracked();
100        let slugs: Vec<String> = items
101            .iter()
102            .map(|item: &EuvDocTocItem| item.get_slug().clone())
103            .collect();
104        let outer_radius: f32 = init_g.get_radius_lg();
105        let row_radius: f32 = concentric_radius(outer_radius, CONTROL_INSET);
106        let mut bound_rows: Vec<(NodeId, NodeId, NodeId)> = Vec::with_capacity(items.len());
107        let mut owned_nodes: Vec<NodeId> = Vec::with_capacity(items.len() * 3 + 2);
108        let mut row_nodes: Vec<NodeId> = Vec::with_capacity(items.len());
109        let mut header_txt_node: NodeId = NodeId::default();
110        for (idx, item) in items.iter().enumerate() {
111            let depth_steps: u8 = item.get_level().saturating_sub(2).min(4);
112            let indent: f32 = (depth_steps as f32) * DOC_TOC_INDENT_STEP;
113            let is_active: bool = !init_slug.is_empty() && init_slug == *item.get_slug();
114            let (init_row_bg, init_bar_bg, init_lbl_fg): (Color, Color, Color) =
115                Self::row_colors(init_p, is_active, false);
116            let slug_owned: String = item.get_slug().clone();
117            let cb_opt: Option<MarkdownStrCallback> = on_select.clone();
118            let on_pick = move |_: &UiEvent| {
119                let _: bool = active_slug.set_if_changed(slug_owned.clone());
120                if let Some(callback_fn) = cb_opt.as_ref() {
121                    callback_fn(&slug_owned);
122                }
123            };
124            let on_enter = move |_: &UiEvent| {
125                let _: bool = hovered_idx.set_if_changed(Some(idx));
126            };
127            let on_leave = move |_: &UiEvent| {
128                if hovered_idx.get_untracked() == Some(idx) {
129                    let _: bool = hovered_idx.set_if_changed(None);
130                }
131            };
132            let mut row_id: NodeId = NodeId::default();
133            let mut bar_id: NodeId = NodeId::default();
134            let mut lbl_id: NodeId = NodeId::default();
135            let row_eighth_style: Style = style! {
136                Width(Length::Percent(100.0))
137                Padding(Edges::new(4.0, SPACE_SM, 4.0, SPACE_XS + indent))
138                AlignItems::Center
139                Gap(SPACE_SM)
140                Radius(row_radius)
141                Background(init_row_bg)
142                CursorIcon::Pointer
143                Overflow::Hidden
144            };
145            let view_fifth_style: Style = style! {
146                Width(Length::Px(2.5))
147                Height(Length::Px(14.0))
148                FlexShrink(0.0)
149                Radius(RADIUS_PILL)
150                Background(init_bar_bg)
151            };
152            let text_eighth_style: Style = style! {
153                FlexGrow(1.0)
154                FlexShrink(1.0)
155                MinWidth(Length::Px(0.0))
156                FontSize(12.5)
157                if is_active { FontWeight::SemiBold } else { FontWeight::Normal }
158                TextColor(init_lbl_fg)
159                Overflow::Hidden
160                TextOverflow::Ellipsis
161            };
162            let item_node: NodeId = view! {
163                row {
164                    node_ref: row_id
165                    style: row_eighth_style
166                    role: A11yRole::Button
167                    a11y_label: item.get_title().clone()
168                    on_click: on_pick
169                    on_pointer_enter: on_enter
170                    on_pointer_leave: on_leave
171                    view {
172                        node_ref: bar_id
173                        style: view_fifth_style
174                    }
175                    text {
176                        node_ref: lbl_id
177                        style: text_eighth_style
178                        { item.get_title().as_str() }
179                    }
180                }
181            };
182            owned_nodes.push(row_id);
183            owned_nodes.push(bar_id);
184            owned_nodes.push(lbl_id);
185            bound_rows.push((row_id, bar_id, lbl_id));
186            row_nodes.push(item_node);
187        }
188        let column_fifth_style: Style = style! {
189            Width(Length::Percent(100.0))
190            Padding(Edges::all(SPACE_MD))
191            Gap(SPACE_XS)
192            Background(init_p.get_card())
193            Border::new(init_g.get_border_width(), init_p.get_border())
194            Radius(outer_radius)
195            Overflow::Hidden
196        };
197        let text_seventh_style: Style = style! {
198            Width(Length::Percent(100.0))
199            FontSize(11.5)
200            FontWeight::Bold
201            TextColor(init_p.get_muted_foreground())
202        };
203        let root: NodeId = view! {
204            column {
205                style: column_fifth_style
206                text {
207                    node_ref: header_txt_node
208                    style: text_seventh_style
209                    { heading_label }
210                }
211            }
212        };
213        owned_nodes.push(root);
214        owned_nodes.push(header_txt_node);
215        if !row_nodes.is_empty() {
216            ctx.append_many(root, row_nodes.as_slice());
217        }
218        let scene: SceneHandle = ctx.get_scene().clone();
219        let scene_eff: SceneHandle = scene.clone();
220        let (scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
221            let mut prev_tok: ThemeTokens = init_tok;
222            let mut prev_slug: String = init_slug;
223            let mut prev_hover: Option<usize> = None;
224            Effect::new(move || {
225                let next_slug: String = active_slug.get();
226                let next_hover: Option<usize> = hovered_idx.get();
227                let live_tok: ThemeTokens = use_live_tokens(base_tokens);
228                let theme_changed: bool = live_tok != prev_tok;
229                if !theme_changed && next_slug == prev_slug && next_hover == prev_hover {
230                    return;
231                }
232                prev_tok = live_tok;
233                prev_slug = next_slug.clone();
234                prev_hover = next_hover;
235                let theme_palette: ThemePalette = live_tok.get_palette();
236                let geometry: ThemeGeometry = live_tok.get_geometry();
237                let muted: Color = theme_palette.get_muted_foreground();
238                scene_eff.with_write(
239                    |tree: &mut SceneTree| {
240                        if theme_changed {
241                            if let Some(item_count) = tree.get_node_mut(root) {
242                                item_count
243                                    .get_mut_style()
244                                    .get_mut_paint()
245                                    .set_background(Some(theme_palette.get_card()))
246                                    .set_border(Border::new(
247                                        geometry.get_border_width(),
248                                        theme_palette.get_border(),
249                                    ));
250                                tree.mark_dirty(root, DIRTY_PAINT);
251                            }
252                            if let Some(node_entry) = tree.get_node_mut(header_txt_node) {
253                                node_entry.get_mut_style().get_mut_text().set_color(muted);
254                                tree.mark_dirty(header_txt_node, DIRTY_PAINT);
255                            }
256                        }
257                        for (idx, &(row_id, bar_id, lbl_id)) in bound_rows.iter().enumerate() {
258                            let is_cur: bool = slugs.get(idx).is_some_and(|text_value: &String| {
259                                !next_slug.is_empty() && text_value == &next_slug
260                            });
261                            let is_hov: bool = !is_cur && next_hover == Some(idx);
262                            let (row_bg, bar_bg, lbl_fg): (Color, Color, Color) =
263                                Self::row_colors(theme_palette, is_cur, is_hov);
264                            if let Some(normal_vec) = tree.get_node_mut(row_id) {
265                                normal_vec
266                                    .get_mut_style()
267                                    .get_mut_paint()
268                                    .set_background(Some(row_bg));
269                                tree.mark_dirty(row_id, DIRTY_PAINT);
270                            }
271                            if let Some(total_len) = tree.get_node_mut(bar_id) {
272                                total_len
273                                    .get_mut_style()
274                                    .get_mut_paint()
275                                    .set_background(Some(bar_bg));
276                                tree.mark_dirty(bar_id, DIRTY_PAINT);
277                            }
278                            if let Some(item_count_primary) = tree.get_node_mut(lbl_id) {
279                                item_count_primary
280                                    .get_mut_style()
281                                    .get_mut_text()
282                                    .set_weight(if is_cur {
283                                        FontWeight::SemiBold
284                                    } else {
285                                        FontWeight::Normal
286                                    })
287                                    .set_color(lbl_fg);
288                                tree.mark_dirty(lbl_id, DIRTY_TEXT | DIRTY_PAINT);
289                            }
290                        }
291                    },
292                    (),
293                );
294            })
295        });
296        scene.with_write(
297            |tree: &mut SceneTree| {
298                mark_theme_owned(tree, owned_nodes.as_slice());
299                tree.attach_scope(root, scope);
300            },
301            (),
302        );
303        root
304    }
305}
306
307/// Fluent builders and theme helpers for `EuvDocPager`.
308impl EuvDocPager {
309    /// Overrides the localized label displayed above the previous-page card.
310    ///
311    /// # Arguments
312    ///
313    /// - `Self` - Source documentation pager.
314    /// - `TextValue` - Localized previous-page label.
315    ///
316    /// # Returns
317    ///
318    /// - `Self` - Updated documentation pager.
319    #[must_use]
320    pub fn prev_label<TextValue>(mut self, label: TextValue) -> Self
321    where
322        TextValue: Into<String>,
323    {
324        self.set_prev_label(label.into());
325        self
326    }
327
328    /// Overrides the localized label displayed above the next-page card.
329    ///
330    /// # Arguments
331    ///
332    /// - `Self` - Source documentation pager.
333    /// - `TextValue` - Localized next-page label.
334    ///
335    /// # Returns
336    ///
337    /// - `Self` - Updated documentation pager.
338    #[must_use]
339    pub fn next_label<TextValue>(mut self, label: TextValue) -> Self
340    where
341        TextValue: Into<String>,
342    {
343        self.set_next_label(label.into());
344        self
345    }
346
347    /// Registers a callback invoked with the target route when Previous or Next is clicked.
348    ///
349    /// # Arguments
350    ///
351    /// - `Self` - Source documentation pager.
352    /// - `CallbackFn` - Navigation callback receiving the destination route slice.
353    ///
354    /// # Returns
355    ///
356    /// - `Self` - Updated documentation pager.
357    #[must_use]
358    pub fn on_navigate<CallbackFn>(mut self, handler: CallbackFn) -> Self
359    where
360        CallbackFn: Fn(&str) + 'static,
361    {
362        self.set_on_navigate(Some(Rc::new(handler)));
363        self
364    }
365
366    /// Resolves `(card_bg, border_color, title_fg, meta_fg)` for a documentation pager card.
367    ///
368    /// # Arguments
369    ///
370    /// - `ThemePalette` - Live theme palette.
371    /// - `bool` - Whether the pointer is currently hovering the pager card.
372    ///
373    /// # Returns
374    ///
375    /// - `(Color, Color, Color, Color)` - Paired card background, border color, readable title color, and muted caption color.
376    #[must_use]
377    pub fn card_colors(palette: ThemePalette, hovered: bool) -> (Color, Color, Color, Color) {
378        let surface: SurfaceColors =
379            palette.interaction_colors(InteractionRole::OutlineSurface, false, hovered, false);
380        let meta_fg: Color =
381            palette.readable_foreground_with(palette.get_muted_foreground(), surface.get_bg());
382        (
383            surface.get_bg(),
384            surface.get_border(),
385            surface.get_fg(),
386            meta_fg,
387        )
388    }
389
390    /// Mounts one directional pager card (`Previous` or `Next`) with compact height, vector arrow, and route handler.
391    ///
392    /// # Arguments
393    ///
394    /// - `&EuvDocPagerLink` - Destination link metadata.
395    /// - `bool` - `true` for next-page right-aligned card, `false` for previous-page left-aligned card.
396    /// - `&str` - Custom directional caption (falls back to `"Previous"` / `"Next"` when empty).
397    /// - `Signal<String>` - Active route signal to update on click.
398    /// - `Option<MarkdownStrCallback>` - Optional navigation callback.
399    /// - `ThemeTokens` - Base theme tokens.
400    ///
401    /// # Returns
402    ///
403    /// - `NodeId` - Mounted pager card node handle.
404    fn mount_pager_card(
405        link: &EuvDocPagerLink,
406        is_next: bool,
407        custom_label: &str,
408        active_route: Signal<String>,
409        on_navigate: Option<MarkdownStrCallback>,
410        base_tokens: ThemeTokens,
411    ) -> NodeId {
412        let ctx: Context = current_context();
413        let init_tok: ThemeTokens = live_tokens_untracked(base_tokens);
414        let theme_palette: ThemePalette = init_tok.get_palette();
415        let geometry: ThemeGeometry = init_tok.get_geometry();
416        let hovered: Signal<bool> = Signal::new(false);
417        let (init_bg, init_border, init_title_fg, init_meta_fg): (Color, Color, Color, Color) =
418            Self::card_colors(theme_palette, false);
419        let target_route: String = link.get_route().clone();
420        let on_card_click = move |_: &UiEvent| {
421            let _: bool = active_route.set_if_changed(target_route.clone());
422            if let Some(callback_fn) = on_navigate.as_ref() {
423                callback_fn(&target_route);
424            }
425        };
426        let on_card_enter = move |_: &UiEvent| {
427            let _: bool = hovered.set_if_changed(true);
428        };
429        let on_card_leave = move |_: &UiEvent| {
430            let _: bool = hovered.set_if_changed(false);
431        };
432        let arrow_icon: EuvIconName = if is_next {
433            EuvIconName::ArrowRight
434        } else {
435            EuvIconName::ArrowLeft
436        };
437        let paint_arrow = move |bounds: Rect, display_list: &mut DisplayList| {
438            let live_p: ThemePalette = live_tokens_untracked(base_tokens).get_palette();
439            draw_euv_icon(arrow_icon, bounds, display_list, live_p.get_primary());
440        };
441        let dir_label: &str = if !custom_label.trim().is_empty() {
442            custom_label.trim()
443        } else if is_next {
444            DOC_PAGER_NEXT_LABEL
445        } else {
446            DOC_PAGER_PREV_LABEL
447        };
448        let title_lbl: &str = link.get_title().as_str();
449        let align_items: AlignItems = if is_next {
450            AlignItems::End
451        } else {
452            AlignItems::Start
453        };
454        let text_align: TextAlign = if is_next {
455            TextAlign::Right
456        } else {
457            TextAlign::Left
458        };
459        let header_justify: JustifyContent = if is_next {
460            JustifyContent::End
461        } else {
462            JustifyContent::Start
463        };
464        let a11y_text: String = format!("{dir_label}: {title_lbl}");
465        let mut dir_txt_id: NodeId = NodeId::default();
466        let mut arrow_id: NodeId = NodeId::default();
467        let mut title_txt_id: NodeId = NodeId::default();
468        let dir_row: NodeId = if is_next {
469            let row_seventh_style: Style = style! {
470                Width(Length::Percent(100.0))
471                Height(Length::Px(15.0))
472                header_justify
473                AlignItems::Center
474                Gap(SPACE_XS)
475            };
476            let text_sixth_style: Style = style! {
477                FlexShrink(0.0)
478                Height(Length::Px(15.0))
479                FontSize(11.0)
480                FontWeight::Medium
481                TextColor(init_meta_fg)
482            };
483            let canvas_tertiary_style: Style = style! {
484                Width(Length::Px(12.0))
485                Height(Length::Px(12.0))
486                FlexShrink(0.0)
487            };
488            view! {
489                row {
490                    style: row_seventh_style
491                    text {
492                        node_ref: dir_txt_id
493                        style: text_sixth_style
494                        { dir_label }
495                    }
496                    canvas {
497                        node_ref: arrow_id
498                        style: canvas_tertiary_style
499                        caching: CanvasCaching::RetainedStatic
500                        painter: paint_arrow
501                    }
502                }
503            }
504        } else {
505            let row_sixth_style: Style = style! {
506                Width(Length::Percent(100.0))
507                Height(Length::Px(15.0))
508                header_justify
509                AlignItems::Center
510                Gap(SPACE_XS)
511            };
512            let canvas_secondary_style: Style = style! {
513                Width(Length::Px(12.0))
514                Height(Length::Px(12.0))
515                FlexShrink(0.0)
516            };
517            let text_fifth_style: Style = style! {
518                FlexShrink(0.0)
519                Height(Length::Px(15.0))
520                FontSize(11.0)
521                FontWeight::Medium
522                TextColor(init_meta_fg)
523            };
524            view! {
525                row {
526                    style: row_sixth_style
527                    canvas {
528                        node_ref: arrow_id
529                        style: canvas_secondary_style
530                        caching: CanvasCaching::RetainedStatic
531                        painter: paint_arrow
532                    }
533                    text {
534                        node_ref: dir_txt_id
535                        style: text_fifth_style
536                        { dir_label }
537                    }
538                }
539            }
540        };
541        let column_quaternary_style: Style = style! {
542            Width(Length::Percent(100.0))
543            Height(Length::Px(56.0))
544            MinWidth(Length::Px(0.0))
545            Padding(Edges::symmetric(DOC_PAGER_PAD_V, DOC_PAGER_PAD_H))
546            Gap(DOC_PAGER_INNER_GAP)
547            JustifyContent::Center
548            align_items
549            Background(init_bg)
550            Border::new(geometry.get_border_width(), init_border)
551            Radius(geometry.get_radius_md())
552            Overflow::Hidden
553            CursorIcon::Pointer
554        };
555        let text_quaternary_style: Style = style! {
556            Width(Length::Percent(100.0))
557            Height(Length::Px(20.0))
558            FontSize(14.0)
559            FontWeight::SemiBold
560            TextColor(init_title_fg)
561            text_align
562            Overflow::Hidden
563            TextOverflow::Ellipsis
564        };
565        let card_node: NodeId = view! {
566            column {
567                style: column_quaternary_style
568                role: A11yRole::Button
569                a11y_label: a11y_text
570                on_click: on_card_click
571                on_pointer_enter: on_card_enter
572                on_pointer_leave: on_card_leave
573                { dir_row }
574                text {
575                    node_ref: title_txt_id
576                    style: text_quaternary_style
577                    { title_lbl }
578                }
579            }
580        };
581        let scene: SceneHandle = ctx.get_scene().clone();
582        let scene_eff: SceneHandle = scene.clone();
583        let prev_state: Cell<(bool, ThemeKey)> = Cell::new((false, init_tok.key()));
584        let (scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
585            Effect::new(move || {
586                let is_hov: bool = hovered.get();
587                let live_tok: ThemeTokens = use_live_tokens(base_tokens);
588                let (old_hov, old_key): (bool, ThemeKey) =
589                    prev_state.replace((is_hov, live_tok.key()));
590                if old_hov == is_hov && old_key == live_tok.key() {
591                    return;
592                }
593                let live_p: ThemePalette = live_tok.get_palette();
594                let border_width: f32 = live_tok.get_geometry().get_border_width();
595                let (bg, border, title_fg, meta_fg): (Color, Color, Color, Color) =
596                    Self::card_colors(live_p, is_hov);
597                scene_eff.with_write(
598                    |tree: &mut SceneTree| {
599                        if let Some(item_count) = tree.get_node_mut(card_node) {
600                            item_count
601                                .get_mut_style()
602                                .get_mut_paint()
603                                .set_background(Some(bg))
604                                .set_border(Border::new(border_width, border));
605                            tree.mark_dirty(card_node, DIRTY_PAINT);
606                        }
607                        if let Some(node_entry) = tree.get_node_mut(dir_txt_id) {
608                            node_entry.get_mut_style().get_mut_text().set_color(meta_fg);
609                            tree.mark_dirty(dir_txt_id, DIRTY_PAINT);
610                        }
611                        if let Some(normal_vec) = tree.get_node_mut(title_txt_id) {
612                            normal_vec
613                                .get_mut_style()
614                                .get_mut_text()
615                                .set_color(title_fg);
616                            tree.mark_dirty(title_txt_id, DIRTY_PAINT);
617                        }
618                        tree.mark_dirty(arrow_id, DIRTY_PAINT);
619                    },
620                    (),
621                );
622            })
623        });
624        scene.with_write(
625            |tree: &mut SceneTree| {
626                let owned: [NodeId; 4] = [card_node, dir_txt_id, arrow_id, title_txt_id];
627                mark_theme_owned(tree, &owned);
628                tree.attach_scope(card_node, scope);
629            },
630            (),
631        );
632        card_node
633    }
634}
635
636/// Declarative `#[component]` implementation for `EuvDocPager`.
637#[component]
638/// Inherent implementation of [`EuvDocPager`].
639impl EuvDocPager {
640    /// Renders responsive Previous and Next article navigation cards splitting width 50%/50% on wide viewports (`>= 640px`) and stacking cleanly on narrow screens.
641    ///
642    /// # Arguments
643    ///
644    /// - `&Self` - Documentation pager component reference.
645    ///
646    /// # Returns
647    ///
648    /// - `NodeId` - Mounted pager container handle.
649    fn render(&self) -> NodeId {
650        let mut ctx: Context = current_context();
651        let tokens: ThemeTokens = self.get_tokens();
652        let active_route: Signal<String> = self.get_active_route();
653        let vp_sig: Signal<Size> = ctx.get_viewport_size();
654        let init_wide: bool = vp_sig.get_untracked().get_width() >= DOC_PAGER_WIDE_BREAKPOINT;
655        let Self {
656            prev,
657            next,
658            prev_label,
659            next_label,
660            on_navigate,
661            ..
662        } = self;
663        let has_any: bool = prev.is_some() || next.is_some();
664        if !has_any {
665            let view_quaternary_style: Style = style! {
666                Display::None
667                Width(Length::Percent(100.0))
668            };
669            return view! {
670                view {
671                    style: view_quaternary_style
672                }
673            };
674        }
675        let mut spacer_slots: Vec<NodeId> = Vec::with_capacity(1);
676        let left_slot: NodeId = if let Some(prev_link) = prev.as_ref() {
677            Self::mount_pager_card(
678                prev_link,
679                false,
680                prev_label.as_str(),
681                active_route,
682                on_navigate.clone(),
683                tokens,
684            )
685        } else {
686            let view_tertiary_style: Style = style! {
687                if init_wide { Display::Flex } else { Display::None }
688                Width(Length::Percent(100.0))
689                Height(Length::Px(1.0))
690                PointerEvents::None
691            };
692            let spacer: NodeId = view! {
693                view {
694                    style: view_tertiary_style
695                }
696            };
697            spacer_slots.push(spacer);
698            spacer
699        };
700        let right_slot: NodeId = if let Some(next_link) = next.as_ref() {
701            Self::mount_pager_card(
702                next_link,
703                true,
704                next_label.as_str(),
705                active_route,
706                on_navigate.clone(),
707                tokens,
708            )
709        } else {
710            let view_secondary_style: Style = style! {
711                if init_wide { Display::Flex } else { Display::None }
712                Width(Length::Percent(100.0))
713                Height(Length::Px(1.0))
714                PointerEvents::None
715            };
716            let spacer: NodeId = view! {
717                view {
718                    style: view_secondary_style
719                }
720            };
721            spacer_slots.push(spacer);
722            spacer
723        };
724        let grid_style: Style = style! {
725            GridColumns(if init_wide { 2 } else { 1 })
726            Width(Length::Percent(100.0))
727            Gap(if init_wide { SPACE_MD } else { SPACE_SM })
728            Padding(Edges::new(SPACE_SM, 0.0, 0.0, 0.0))
729        };
730        let root: NodeId = view! {
731            grid {
732                style: grid_style
733            }
734        };
735        ctx.append_many(root, &[left_slot, right_slot]);
736        let scene: SceneHandle = ctx.get_scene().clone();
737        let scene_eff: SceneHandle = scene.clone();
738        let prev_wide: Cell<bool> = Cell::new(init_wide);
739        let (bp_scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
740            Effect::new(move || {
741                let is_wide: bool = vp_sig.get().get_width() >= DOC_PAGER_WIDE_BREAKPOINT;
742                let was_wide: bool = prev_wide.replace(is_wide);
743                if is_wide == was_wide {
744                    return;
745                }
746                scene_eff.with_write(
747                    |tree: &mut SceneTree| {
748                        let dirty_l: u16 = DIRTY_LAYOUT | DIRTY_SUBTREE_LAYOUT;
749                        if let Some(item_count) = tree.get_node_mut(root) {
750                            let lay: &mut LayoutStyle = item_count.get_mut_style().get_mut_layout();
751                            lay.set_grid_columns(if is_wide { 2 } else { 1 });
752                            tree.mark_dirty(root, dirty_l | DIRTY_PAINT);
753                        }
754                        for &spacer_id in spacer_slots.iter() {
755                            if let Some(node_entry) = tree.get_node_mut(spacer_id) {
756                                node_entry.get_mut_style().get_mut_layout().set_display(
757                                    if is_wide {
758                                        Display::Flex
759                                    } else {
760                                        Display::None
761                                    },
762                                );
763                                tree.mark_dirty(spacer_id, dirty_l | DIRTY_PAINT);
764                            }
765                        }
766                    },
767                    (),
768                );
769            })
770        });
771        scene.with_write(
772            |tree: &mut SceneTree| {
773                tree.attach_scope(root, bp_scope);
774            },
775            (),
776        );
777        root
778    }
779}
780
781/// Fluent builders for `EuvDocSectionGroup`.
782impl EuvDocSectionGroup {
783    /// Configures whether the section group starts collapsed.
784    ///
785    /// # Arguments
786    ///
787    /// - `Self` - Source section group.
788    /// - `bool` - When `true`, renders initially collapsed unless it contains the active route.
789    ///
790    /// # Returns
791    ///
792    /// - `Self` - Updated section group.
793    #[must_use]
794    pub fn collapsed(mut self, is_collapsed: bool) -> Self {
795        self.set_collapsed(is_collapsed);
796        self
797    }
798}
799
800/// Fluent builders and theme helpers for `EuvDocSectionNav`.
801impl EuvDocSectionNav {
802    /// Registers a callback invoked whenever a sidebar navigation route is selected.
803    ///
804    /// # Arguments
805    ///
806    /// - `Self` - Source section navigation component.
807    /// - `CallbackFn` - Callback receiving the selected route path slice.
808    ///
809    /// # Returns
810    ///
811    /// - `Self` - Updated section navigation component.
812    #[must_use]
813    pub fn on_select<CallbackFn>(mut self, handler: CallbackFn) -> Self
814    where
815        CallbackFn: Fn(&str) + 'static,
816    {
817        self.set_on_select(Some(Rc::new(handler)));
818        self
819    }
820
821    /// Resolves `(row_bg, indicator_bg, label_fg)` for a documentation section nav item.
822    ///
823    /// # Arguments
824    ///
825    /// - `ThemePalette` - Live theme palette.
826    /// - `bool` - Whether this item matches the active route.
827    /// - `bool` - Whether the pointer is currently hovering this item.
828    ///
829    /// # Returns
830    ///
831    /// - `(Color, Color, Color)` - Paired row background, indicator fill, and readable label color.
832    #[must_use]
833    pub fn item_colors(
834        palette: ThemePalette,
835        active: bool,
836        hovered: bool,
837    ) -> (Color, Color, Color) {
838        let surface: SurfaceColors =
839            palette.interaction_colors(InteractionRole::NavItem, active, hovered, false);
840        let indicator_color: Color = if active {
841            surface.get_border()
842        } else {
843            COLOR_TRANSPARENT
844        };
845        (surface.get_bg(), indicator_color, surface.get_fg())
846    }
847}
848
849/// Declarative `#[component]` implementation for `EuvDocSectionNav`.
850#[component]
851/// Inherent implementation of [`EuvDocSectionNav`].
852impl EuvDocSectionNav {
853    /// Renders grouped collapsible documentation sections with item count badges and reactive active route indicators.
854    ///
855    /// # Arguments
856    ///
857    /// - `&Self` - Section navigation component reference.
858    ///
859    /// # Returns
860    ///
861    /// - `NodeId` - Mounted sidebar section column handle.
862    fn render(&self) -> NodeId {
863        let mut ctx: Context = current_context();
864        let base_tokens: ThemeTokens = self.get_tokens();
865        let init_tok: ThemeTokens = live_tokens_untracked(base_tokens);
866        let init_p: ThemePalette = init_tok.get_palette();
867        let init_g: ThemeGeometry = init_tok.get_geometry();
868        let active_route: Signal<String> = self.get_active_route();
869        let hovered_item: Signal<Option<usize>> = Signal::new(None);
870        let Self {
871            groups, on_select, ..
872        } = self;
873        let init_route: String = active_route.get_untracked();
874        let row_h: f32 = init_g.get_control_sm().max(DOC_NAV_ROW_MIN_HEIGHT);
875        let init_badge_fg: Color =
876            init_p.readable_foreground_with(init_p.get_muted_foreground(), init_p.get_muted());
877        let mut group_nodes: Vec<NodeId> = Vec::with_capacity(groups.len());
878        let mut group_headers: Vec<DocSectionHeaderEntry> = Vec::with_capacity(groups.len());
879        let mut bound_items: Vec<(String, NodeId, NodeId, NodeId)> = Vec::new();
880        let mut owned_nodes: Vec<NodeId> = Vec::new();
881        for group in groups.iter() {
882            let group_routes: Vec<String> = group
883                .get_items()
884                .iter()
885                .map(|it: &EuvNavItem| it.get_path().clone())
886                .collect();
887            let contains_active: bool = group_routes
888                .iter()
889                .any(|text_value: &String| text_value.as_str() == init_route.as_str());
890            let open_sig: Signal<bool> = Signal::new(contains_active || !group.get_collapsed());
891            let count_text: String = group.get_items().len().to_string();
892            let title_upper: String = group.get_title().to_ascii_uppercase();
893            let on_toggle_group = move |_: &UiEvent| {
894                let _: bool = open_sig.set(!open_sig.get_untracked());
895            };
896            let paint_chev = move |bounds: Rect, display_list: &mut DisplayList| {
897                let live_p: ThemePalette = live_tokens_untracked(base_tokens).get_palette();
898                let icon: EuvIconName = if open_sig.get_untracked() {
899                    EuvIconName::ChevronDown
900                } else {
901                    EuvIconName::ArrowRight
902                };
903                draw_euv_icon(icon, bounds, display_list, live_p.get_muted_foreground());
904            };
905            let mut item_nodes: Vec<NodeId> = Vec::with_capacity(group.get_items().len());
906            for item in group.get_items().iter() {
907                let item_idx: usize = bound_items.len();
908                let is_active: bool = item.get_path().as_str() == init_route.as_str();
909                let (init_row_bg, init_ind_bg, init_lbl_fg): (Color, Color, Color) =
910                    Self::item_colors(init_p, is_active, false);
911                let path_owned: String = item.get_path().clone();
912                let cb_opt: Option<MarkdownStrCallback> = on_select.clone();
913                let on_pick_route = move |_: &UiEvent| {
914                    let _: bool = active_route.set_if_changed(path_owned.clone());
915                    if let Some(callback_fn) = cb_opt.as_ref() {
916                        callback_fn(&path_owned);
917                    }
918                };
919                let on_enter_item = move |_: &UiEvent| {
920                    let _: bool = hovered_item.set_if_changed(Some(item_idx));
921                };
922                let on_leave_item = move |_: &UiEvent| {
923                    if hovered_item.get_untracked() == Some(item_idx) {
924                        let _: bool = hovered_item.set_if_changed(None);
925                    }
926                };
927                let mut row_id: NodeId = NodeId::default();
928                let mut ind_id: NodeId = NodeId::default();
929                let mut lbl_id: NodeId = NodeId::default();
930                let row_fifth_style: Style = style! {
931                    Width(Length::Percent(100.0))
932                    Height(Length::Px(row_h))
933                    AlignItems::Center
934                    Gap(SPACE_SM)
935                    Padding(Edges::symmetric(0.0, SPACE_SM))
936                    Radius(init_g.get_radius_md())
937                    Background(init_row_bg)
938                    CursorIcon::Pointer
939                    Overflow::Hidden
940                };
941                let view_style: Style = style! {
942                    Width(Length::Px(3.5))
943                    Height(Length::Px(18.0))
944                    FlexShrink(0.0)
945                    Radius(RADIUS_PILL)
946                    Background(init_ind_bg)
947                };
948                let text_tertiary_style: Style = style! {
949                    FlexGrow(1.0)
950                    FlexShrink(1.0)
951                    MinWidth(Length::Px(0.0))
952                    FontSize(13.0)
953                    if is_active { FontWeight::SemiBold } else { FontWeight::Medium }
954                    TextColor(init_lbl_fg)
955                    Overflow::Hidden
956                    TextOverflow::Ellipsis
957                };
958                let item_row: NodeId = view! {
959                    row {
960                        node_ref: row_id
961                        style: row_fifth_style
962                        role: A11yRole::Button
963                        a11y_label: item.get_label().clone()
964                        on_click: on_pick_route
965                        on_pointer_enter: on_enter_item
966                        on_pointer_leave: on_leave_item
967                        view {
968                            node_ref: ind_id
969                            style: view_style
970                        }
971                        text {
972                            node_ref: lbl_id
973                            style: text_tertiary_style
974                            { item.get_label().as_str() }
975                        }
976                    }
977                };
978                owned_nodes.push(row_id);
979                owned_nodes.push(ind_id);
980                owned_nodes.push(lbl_id);
981                bound_items.push((item.get_path().clone(), row_id, ind_id, lbl_id));
982                item_nodes.push(item_row);
983            }
984            let init_open: bool = open_sig.get_untracked();
985            let mut hdr_txt: NodeId = NodeId::default();
986            let mut badge_box: NodeId = NodeId::default();
987            let mut badge_txt: NodeId = NodeId::default();
988            let mut chev_node: NodeId = NodeId::default();
989            let mut list_col: NodeId = NodeId::default();
990            let column_secondary_style: Style = style! {
991                Width(Length::Percent(100.0))
992                Gap(2.0)
993                Padding(Edges::new(SPACE_XS, 0.0, 0.0, 0.0))
994            };
995            let row_secondary_style: Style = style! {
996                Width(Length::Percent(100.0))
997                Padding(Edges::symmetric(4.0, SPACE_SM))
998                JustifyContent::SpaceBetween
999                AlignItems::Center
1000                Gap(SPACE_XS)
1001                Radius(init_g.get_radius_sm())
1002                CursorIcon::Pointer
1003                Overflow::Hidden
1004            };
1005            let row_tertiary_style: Style = style! {
1006                FlexGrow(1.0)
1007                FlexShrink(1.0)
1008                MinWidth(Length::Px(0.0))
1009                AlignItems::Center
1010                Gap(SPACE_XS)
1011                Overflow::Hidden
1012            };
1013            let canvas_style: Style = style! {
1014                Width(Length::Px(12.0))
1015                Height(Length::Px(12.0))
1016                FlexShrink(0.0)
1017            };
1018            let text_style: Style = style! {
1019                FlexGrow(1.0)
1020                FlexShrink(1.0)
1021                MinWidth(Length::Px(0.0))
1022                FontSize(11.0)
1023                FontWeight::Bold
1024                TextColor(init_p.get_muted_foreground())
1025                Overflow::Hidden
1026                TextOverflow::Ellipsis
1027            };
1028            let row_quaternary_style: Style = style! {
1029                FlexShrink(0.0)
1030                JustifyContent::Center
1031                AlignItems::Center
1032                Padding(Edges::symmetric(1.0, 6.0))
1033                Radius(RADIUS_PILL)
1034                Background(init_p.get_muted())
1035                Border::new(init_g.get_border_width(), init_p.get_border())
1036                Overflow::Hidden
1037            };
1038            let text_secondary_style: Style = style! {
1039                FontSize(10.5)
1040                FontWeight::SemiBold
1041                TextColor(init_badge_fg)
1042            };
1043            let column_tertiary_style: Style = style! {
1044                if init_open { Display::Flex } else { Display::None }
1045                Width(Length::Percent(100.0))
1046                Gap(2.0)
1047            };
1048            let group_col: NodeId = view! {
1049                column {
1050                    style: column_secondary_style
1051                    row {
1052                        style: row_secondary_style
1053                        role: A11yRole::Button
1054                        a11y_label: group.get_title().clone()
1055                        on_click: on_toggle_group
1056                        row {
1057                            style: row_tertiary_style
1058                            canvas {
1059                                node_ref: chev_node
1060                                style: canvas_style
1061                                painter: paint_chev
1062                            }
1063                            text {
1064                                node_ref: hdr_txt
1065                                style: text_style
1066                                { title_upper }
1067                            }
1068                        }
1069                        row {
1070                            node_ref: badge_box
1071                            style: row_quaternary_style
1072                            text {
1073                                node_ref: badge_txt
1074                                style: text_secondary_style
1075                                { count_text }
1076                            }
1077                        }
1078                    }
1079                    column {
1080                        node_ref: list_col
1081                        style: column_tertiary_style
1082                        ..item_nodes
1083                    }
1084                }
1085            };
1086            owned_nodes.push(hdr_txt);
1087            owned_nodes.push(badge_box);
1088            owned_nodes.push(badge_txt);
1089            owned_nodes.push(chev_node);
1090            group_headers.push(DocSectionHeaderEntry {
1091                hdr_id: hdr_txt,
1092                badge_id: badge_box,
1093                badge_txt_id: badge_txt,
1094                chev_id: chev_node,
1095                list_id: list_col,
1096                open_sig,
1097                routes: group_routes,
1098            });
1099            group_nodes.push(group_col);
1100        }
1101        let column_style: Style = style! {
1102            Width(Length::Percent(100.0))
1103            Gap(SPACE_SM)
1104        };
1105        let root: NodeId = view! {
1106            column {
1107                style: column_style
1108            }
1109        };
1110        if !group_nodes.is_empty() {
1111            ctx.append_many(root, group_nodes.as_slice());
1112        }
1113        let scene: SceneHandle = ctx.get_scene().clone();
1114        let scene_eff: SceneHandle = scene.clone();
1115        let (scope, _): (Scope, Effect) = Scope::run(|_: Scope| {
1116            for entry in group_headers.iter() {
1117                let chev_id: NodeId = entry.chev_id;
1118                let list_id: NodeId = entry.list_id;
1119                let open_sig: Signal<bool> = entry.open_sig;
1120                let scale_factor: SceneHandle = scene_eff.clone();
1121                let _: Effect = Effect::new(move || {
1122                    let is_open: bool = open_sig.get();
1123                    scale_factor.with_write(
1124                        |tree: &mut SceneTree| {
1125                            if let Some(item_count) = tree.get_node_mut(list_id) {
1126                                item_count.get_mut_style().get_mut_layout().set_display(
1127                                    if is_open {
1128                                        Display::Flex
1129                                    } else {
1130                                        Display::None
1131                                    },
1132                                );
1133                                let dirty_flags: u16 =
1134                                    (DIRTY_LAYOUT | DIRTY_SUBTREE_LAYOUT) | DIRTY_PAINT;
1135                                tree.mark_dirty(list_id, dirty_flags);
1136                            }
1137                            tree.mark_dirty(chev_id, DIRTY_PAINT);
1138                        },
1139                        (),
1140                    );
1141                });
1142            }
1143            let mut prev_tok: ThemeTokens = init_tok;
1144            let mut prev_route: String = init_route;
1145            let mut prev_hover: Option<usize> = None;
1146            Effect::new(move || {
1147                let next_route: String = active_route.get();
1148                let next_hover: Option<usize> = hovered_item.get();
1149                let live_tok: ThemeTokens = use_live_tokens(base_tokens);
1150                let theme_changed: bool = live_tok != prev_tok;
1151                if !theme_changed && next_route == prev_route && next_hover == prev_hover {
1152                    return;
1153                }
1154                let route_changed: bool = next_route != prev_route;
1155                prev_tok = live_tok;
1156                prev_route = next_route.clone();
1157                prev_hover = next_hover;
1158                if route_changed {
1159                    for entry in group_headers.iter() {
1160                        if entry
1161                            .routes
1162                            .iter()
1163                            .any(|label_str: &String| label_str.as_str() == next_route.as_str())
1164                        {
1165                            let _: bool = entry.open_sig.set_if_changed(true);
1166                        }
1167                    }
1168                }
1169                let theme_palette: ThemePalette = live_tok.get_palette();
1170                let border_width: f32 = live_tok.get_geometry().get_border_width();
1171                let muted: Color = theme_palette.get_muted_foreground();
1172                let badge_fg: Color =
1173                    theme_palette.readable_foreground_with(muted, theme_palette.get_muted());
1174                scene_eff.with_write(
1175                    |tree: &mut SceneTree| {
1176                        if theme_changed {
1177                            for entry in group_headers.iter() {
1178                                let hdr_id: NodeId = entry.hdr_id;
1179                                let badge_id: NodeId = entry.badge_id;
1180                                let badge_txt_id: NodeId = entry.badge_txt_id;
1181                                let chev_id: NodeId = entry.chev_id;
1182                                if let Some(node_entry) = tree.get_node_mut(hdr_id) {
1183                                    node_entry.get_mut_style().get_mut_text().set_color(muted);
1184                                    tree.mark_dirty(hdr_id, DIRTY_PAINT);
1185                                }
1186                                if let Some(normal_vec) = tree.get_node_mut(badge_id) {
1187                                    normal_vec
1188                                        .get_mut_style()
1189                                        .get_mut_paint()
1190                                        .set_background(Some(theme_palette.get_muted()))
1191                                        .set_border(Border::new(
1192                                            border_width,
1193                                            theme_palette.get_border(),
1194                                        ));
1195                                    tree.mark_dirty(badge_id, DIRTY_PAINT);
1196                                }
1197                                if let Some(total_len) = tree.get_node_mut(badge_txt_id) {
1198                                    total_len.get_mut_style().get_mut_text().set_color(badge_fg);
1199                                    tree.mark_dirty(badge_txt_id, DIRTY_PAINT);
1200                                }
1201                                tree.mark_dirty(chev_id, DIRTY_PAINT);
1202                            }
1203                        }
1204                        for (idx, (path, row_id, ind_id, lbl_id)) in bound_items.iter().enumerate()
1205                        {
1206                            let is_cur: bool = path.as_str() == next_route.as_str();
1207                            let is_hov: bool = !is_cur && next_hover == Some(idx);
1208                            let (row_bg, ind_bg, lbl_fg): (Color, Color, Color) =
1209                                Self::item_colors(theme_palette, is_cur, is_hov);
1210                            if let Some(item_count_primary) = tree.get_node_mut(*row_id) {
1211                                item_count_primary
1212                                    .get_mut_style()
1213                                    .get_mut_paint()
1214                                    .set_background(Some(row_bg));
1215                                tree.mark_dirty(*row_id, DIRTY_PAINT);
1216                            }
1217                            if let Some(item_count_secondary) = tree.get_node_mut(*ind_id) {
1218                                item_count_secondary
1219                                    .get_mut_style()
1220                                    .get_mut_paint()
1221                                    .set_background(Some(ind_bg));
1222                                tree.mark_dirty(*ind_id, DIRTY_PAINT);
1223                            }
1224                            if let Some(item_count_next) = tree.get_node_mut(*lbl_id) {
1225                                item_count_next
1226                                    .get_mut_style()
1227                                    .get_mut_text()
1228                                    .set_weight(if is_cur {
1229                                        FontWeight::SemiBold
1230                                    } else {
1231                                        FontWeight::Medium
1232                                    })
1233                                    .set_color(lbl_fg);
1234                                tree.mark_dirty(*lbl_id, DIRTY_TEXT | DIRTY_PAINT);
1235                            }
1236                        }
1237                    },
1238                    (),
1239                );
1240            })
1241        });
1242        scene.with_write(
1243            |tree: &mut SceneTree| {
1244                mark_theme_owned(tree, owned_nodes.as_slice());
1245                tree.attach_scope(root, scope);
1246            },
1247            (),
1248        );
1249        root
1250    }
1251}
1252
1253/// Fluent builders for `EuvDocMetaBar`.
1254impl EuvDocMetaBar {
1255    /// Sets an optional last-updated label displayed as a metadata tag.
1256    ///
1257    /// # Arguments
1258    ///
1259    /// - `Self` - Source metadata bar.
1260    /// - `TextValue` - Updated date or label convertible into `String`.
1261    ///
1262    /// # Returns
1263    ///
1264    /// - `Self` - Updated metadata bar.
1265    #[must_use]
1266    pub fn updated<TextValue>(mut self, updated: TextValue) -> Self
1267    where
1268        TextValue: Into<String>,
1269    {
1270        self.set_updated(updated.into());
1271        self
1272    }
1273
1274    /// Sets an optional source file or route metadata label displayed as a tag.
1275    ///
1276    /// # Arguments
1277    ///
1278    /// - `Self` - Source metadata bar.
1279    /// - `TextValue` - Source path label convertible into `String`.
1280    ///
1281    /// # Returns
1282    ///
1283    /// - `Self` - Updated metadata bar.
1284    #[must_use]
1285    pub fn source_path<TextValue>(mut self, source_path: TextValue) -> Self
1286    where
1287        TextValue: Into<String>,
1288    {
1289        self.set_source_path(source_path.into());
1290        self
1291    }
1292}
1293
1294/// Declarative `#[component]` implementation for `EuvDocMetaBar`.
1295#[component]
1296/// Inherent implementation of [`EuvDocMetaBar`].
1297impl EuvDocMetaBar {
1298    /// Renders a wrapping documentation metadata strip composed from `EuvBadge` and `EuvTag`.
1299    ///
1300    /// # Arguments
1301    ///
1302    /// - `&Self` - Documentation metadata bar reference.
1303    ///
1304    /// # Returns
1305    ///
1306    /// - `NodeId` - Mounted metadata bar row handle.
1307    fn render(&self) -> NodeId {
1308        let tokens: ThemeTokens = live_tokens_untracked(self.get_tokens());
1309        let mins: usize = self.get_reading_minutes().max(1);
1310        let words: usize = self.get_word_count();
1311        let Self {
1312            section,
1313            updated,
1314            source_path,
1315            ..
1316        } = self;
1317        let read_tag: String = format!("{mins} {DOC_META_MIN_READ_SUFFIX}");
1318        let words_tag: String = format!("{words} {DOC_META_WORDS_SUFFIX}");
1319        let has_updated: bool = !updated.trim().is_empty();
1320        let updated_tag: String = format!("{DOC_META_UPDATED_PREFIX} {}", updated.trim());
1321        let has_source: bool = !source_path.trim().is_empty();
1322        let row_style: Style = style! {
1323            Width(Length::Percent(100.0))
1324            FlexWrap::Wrap
1325            AlignItems::Center
1326            Gap(SPACE_SM)
1327        };
1328        view! {
1329            row {
1330                style: row_style
1331                if !section.trim().is_empty() {
1332                    EuvBadge {
1333                        label: section.clone()
1334                        tone: EuvTone::Primary
1335                        tokens: tokens
1336                    }
1337                }
1338                EuvTag {
1339                    label: read_tag
1340                    tone: EuvTone::Neutral
1341                    tokens: tokens
1342                }
1343                if words > 0 {
1344                    EuvTag {
1345                        label: words_tag
1346                        tone: EuvTone::Neutral
1347                        tokens: tokens
1348                    }
1349                }
1350                if has_updated {
1351                    EuvTag {
1352                        label: updated_tag
1353                        tone: EuvTone::Success
1354                        tokens: tokens
1355                    }
1356                }
1357                if has_source {
1358                    EuvTag {
1359                        label: source_path.clone()
1360                        tone: EuvTone::Neutral
1361                        tokens: tokens
1362                    }
1363                }
1364            }
1365        }
1366    }
1367}