euv_ui/component/loading/view/fn.rs
1use crate::*;
2
3/// A loading indicator component with spinner and optional subtitle.
4///
5/// Renders a spinner with a title (and optional subtitle) in either inline
6/// or overlay mode. In overlay mode the component is absolutely positioned
7/// to cover its parent container, making it ideal for overlaying canvases
8/// or other content areas during asynchronous initialization.
9///
10/// # Arguments
11///
12/// - `VirtualNode<EuvLoadingProps>` - The props node containing title, subtitle, overlay, and background.
13///
14/// # Returns
15///
16/// - `VirtualNode` - A styled loading indicator element.
17#[component]
18pub fn euv_loading(node: VirtualNode<EuvLoadingProps>) -> VirtualNode {
19 let EuvLoadingProps {
20 title,
21 subtitle,
22 overlay,
23 background,
24 }: EuvLoadingProps = node.try_get_props().unwrap_or_default();
25 let has_subtitle: bool = !subtitle.is_empty();
26 if overlay {
27 html! {
28 div {
29 class: c_loading_overlay(background)
30 div {
31 class: c_spinner()
32 }
33 div {
34 class: c_loading_text_col()
35 span {
36 class: c_loading_title()
37 title
38 }
39 if has_subtitle {
40 span {
41 class: c_loading_subtitle()
42 subtitle
43 }
44 }
45 }
46 }
47 }
48 } else {
49 html! {
50 div {
51 class: c_loading_container()
52 div {
53 class: c_spinner()
54 }
55 div {
56 class: c_loading_text_col()
57 span {
58 class: c_loading_title()
59 title
60 }
61 if has_subtitle {
62 span {
63 class: c_loading_subtitle()
64 subtitle
65 }
66 }
67 }
68 }
69 }
70 }
71}