Skip to main content

dioxus_bootstrap_css/
types.rs

1use std::fmt;
2
3/// Bootstrap contextual color variants.
4#[derive(Clone, Copy, Debug, Default, PartialEq)]
5pub enum Color {
6    #[default]
7    Primary,
8    Secondary,
9    Success,
10    Danger,
11    Warning,
12    Info,
13    Light,
14    Dark,
15}
16
17impl fmt::Display for Color {
18    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
19        match self {
20            Color::Primary => write!(f, "primary"),
21            Color::Secondary => write!(f, "secondary"),
22            Color::Success => write!(f, "success"),
23            Color::Danger => write!(f, "danger"),
24            Color::Warning => write!(f, "warning"),
25            Color::Info => write!(f, "info"),
26            Color::Light => write!(f, "light"),
27            Color::Dark => write!(f, "dark"),
28        }
29    }
30}
31
32/// Bootstrap size variants.
33#[derive(Clone, Copy, Debug, Default, PartialEq)]
34pub enum Size {
35    Sm,
36    #[default]
37    Md,
38    Lg,
39}
40
41impl fmt::Display for Size {
42    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
43        match self {
44            Size::Sm => write!(f, "sm"),
45            Size::Md => write!(f, "md"),
46            Size::Lg => write!(f, "lg"),
47        }
48    }
49}
50
51/// Bootstrap column span (1-12 or auto).
52#[derive(Clone, Copy, Debug, PartialEq)]
53pub enum ColumnSize {
54    Auto,
55    Span(u8),
56}
57
58impl fmt::Display for ColumnSize {
59    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60        match self {
61            ColumnSize::Auto => write!(f, "auto"),
62            ColumnSize::Span(n) => write!(f, "{n}"),
63        }
64    }
65}
66
67/// Bootstrap navbar expand breakpoints.
68#[derive(Clone, Copy, Debug, Default, PartialEq)]
69pub enum NavbarExpand {
70    Sm,
71    #[default]
72    Md,
73    Lg,
74    Xl,
75    Xxl,
76    Always,
77}
78
79impl fmt::Display for NavbarExpand {
80    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
81        match self {
82            NavbarExpand::Sm => write!(f, "navbar-expand-sm"),
83            NavbarExpand::Md => write!(f, "navbar-expand-md"),
84            NavbarExpand::Lg => write!(f, "navbar-expand-lg"),
85            NavbarExpand::Xl => write!(f, "navbar-expand-xl"),
86            NavbarExpand::Xxl => write!(f, "navbar-expand-xxl"),
87            NavbarExpand::Always => write!(f, "navbar-expand"),
88        }
89    }
90}
91
92/// Bootstrap modal size.
93#[derive(Clone, Copy, Debug, Default, PartialEq)]
94pub enum ModalSize {
95    Sm,
96    #[default]
97    Default,
98    Lg,
99    Xl,
100}
101
102/// Spinner style variant.
103#[derive(Clone, Copy, Debug, Default, PartialEq)]
104pub enum SpinnerStyle {
105    #[default]
106    Border,
107    Grow,
108}