1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use super::*;
impl Default for PaletteSystem {
fn default() -> Self {
Self { gradient: false, inner: Default::default() }
}
}
impl Display for Palette {
fn fmt(&self, _f: &mut Formatter<'_>) -> std::fmt::Result {
todo!()
}
}
impl Display for ColorResolver {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Inherit => f.write_str("inherit"),
Self::Current => f.write_str("current"),
Self::Transparent => f.write_str("transparent"),
Self::Black => f.write_str("black"),
Self::White => f.write_str("white"),
Self::Themed { name, weight } => {
write!(f, "{}-{}", name, weight)
}
}
}
}
macro_rules! color_wrapper {
($t:ty) => {
impl $t {
pub const INHERIT: Self = Self { color: ColorResolver::Inherit };
pub const CURRENT: Self = Self { color: ColorResolver::Current };
pub const TRANSPARENT: Self = Self { color: ColorResolver::Transparent };
pub const BLACK: Self = Self { color: ColorResolver::Black };
pub const WHITE: Self = Self { color: ColorResolver::White };
}
impl $t {
#[inline]
pub fn parse(name: &str, weight: &str) -> Result<Self> {
let w = parse_integer(weight)?;
Ok(Self { color: ColorResolver::new(name, w.1) })
}
#[inline]
pub fn new(name: String, weight: usize) -> Result<Self> {
Ok(Self { color: ColorResolver::new(name, weight) })
}
}
};
($($t:ty),+ $(,)?) => {
$(color_wrapper!($t);)+
};
}
color_wrapper![TailwindTextColor, TailwindRingColor, TailwindBackgroundColor];