yew_bootstrap/util/
color.rs

1use std::fmt;
2
3/// # Colors
4/// Bootstrap colors for buttons, links, etc.
5#[derive(Clone, PartialEq, Eq)]
6pub enum Color {
7    Primary,
8    Secondary,
9    Success,
10    Info,
11    Warning,
12    Danger,
13    Light,
14    Dark,
15    Link,
16}
17
18impl fmt::Display for Color {
19    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
20        match *self {
21            Color::Primary => write!(f, "primary"),
22            Color::Secondary => write!(f, "secondary"),
23            Color::Success => write!(f, "success"),
24            Color::Info => write!(f, "info"),
25            Color::Warning => write!(f, "warning"),
26            Color::Danger => write!(f, "danger"),
27            Color::Light => write!(f, "light"),
28            Color::Dark => write!(f, "dark"),
29            Color::Link => write!(f, "link"),
30        }
31    }
32}
33
34/// # Colors
35/// Bootstrap colors for text. Like [Color] but includes white and muted.
36#[derive(Clone, PartialEq, Eq)]
37pub enum TextColor {
38    Primary,
39    Secondary,
40    Success,
41    Info,
42    Warning,
43    Danger,
44    Light,
45    Dark,
46    Link,
47    White,
48    Muted,
49}
50
51impl fmt::Display for TextColor {
52    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
53        match *self {
54            TextColor::Primary => write!(f, "primary"),
55            TextColor::Secondary => write!(f, "secondary"),
56            TextColor::Success => write!(f, "success"),
57            TextColor::Info => write!(f, "info"),
58            TextColor::Warning => write!(f, "warning"),
59            TextColor::Danger => write!(f, "danger"),
60            TextColor::Light => write!(f, "light"),
61            TextColor::Dark => write!(f, "dark"),
62            TextColor::Link => write!(f, "link"),
63            TextColor::White => write!(f, "white"),
64            TextColor::Muted => write!(f, "muted"),
65        }
66    }
67}