Skip to main content

leptos_daisyui_rs/components/loading/
style.rs

1/// Style definitions for the Loading component.
2#[derive(Clone, Debug, Default)]
3pub enum LoadingColor {
4    /// Default theme color
5    #[default]
6    Default,
7
8    /// Neutral gray color scheme
9    Neutral,
10
11    /// Primary theme color
12    Primary,
13
14    /// Secondary theme color
15    Secondary,
16
17    /// Accent theme color
18    Accent,
19
20    /// Information/info theme color (typically blue)
21    Info,
22
23    /// Success theme color (typically green)
24    Success,
25
26    /// Warning theme color (typically yellow/orange)
27    Warning,
28
29    /// Error theme color (typically red)
30    Error,
31}
32
33impl LoadingColor {
34    /// CSS class string
35    pub fn as_str(&self) -> &'static str {
36        match self {
37            LoadingColor::Default => "",
38            LoadingColor::Neutral => "text-neutral",
39            LoadingColor::Primary => "text-primary",
40            LoadingColor::Secondary => "text-secondary",
41            LoadingColor::Accent => "text-accent",
42            LoadingColor::Info => "text-info",
43            LoadingColor::Success => "text-success",
44            LoadingColor::Warning => "text-warning",
45            LoadingColor::Error => "text-error",
46        }
47    }
48}
49
50/// Animation type variations for loading indicators.
51#[derive(Clone, Debug, Default)]
52pub enum LoadingType {
53    /// Classic spinning circle animation (default)
54    #[default]
55    Spinner,
56
57    /// Three bouncing dots animation
58    Dots,
59
60    /// Rotating ring with gap animation
61    Ring,
62
63    /// Bouncing ball animation
64    Ball,
65
66    /// Animated vertical bars
67    Bars,
68
69    /// Infinity symbol animation
70    Infinity,
71}
72
73impl LoadingType {
74    /// CSS class string
75    pub fn as_str(&self) -> &'static str {
76        match self {
77            LoadingType::Spinner => "loading-spinner",
78            LoadingType::Dots => "loading-dots",
79            LoadingType::Ring => "loading-ring",
80            LoadingType::Ball => "loading-ball",
81            LoadingType::Bars => "loading-bars",
82            LoadingType::Infinity => "loading-infinity",
83        }
84    }
85}
86
87/// Size variations for loading indicators.
88#[derive(Clone, Debug, Default)]
89pub enum LoadingSize {
90    /// Extra small size
91    Xs,
92
93    /// Small size
94    Sm,
95
96    /// Medium size (explicit)
97    #[default]
98    Md,
99
100    /// Large size
101    Lg,
102
103    /// Extra large size
104    Xl,
105}
106
107impl LoadingSize {
108    /// CSS class string
109    pub fn as_str(&self) -> &'static str {
110        match self {
111            LoadingSize::Xs => "loading-xs",
112            LoadingSize::Sm => "loading-sm",
113            LoadingSize::Md => "loading-md",
114            LoadingSize::Lg => "loading-lg",
115            LoadingSize::Xl => "loading-xl",
116        }
117    }
118}