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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
use super::*;
#[doc = include_str!("readme.md")]
#[derive(Clone, Debug)]
pub struct TailwindFrom {
color: TailwindColor,
}
#[doc = include_str!("readme.md")]
#[derive(Clone, Debug)]
pub struct TailwindVia {
color: TailwindColor,
}
#[doc = include_str!("readme.md")]
#[derive(Clone, Debug)]
pub struct TailwindTo {
color: TailwindColor,
}
impl From<TailwindColor> for TailwindFrom {
fn from(color: TailwindColor) -> Self {
Self { color }
}
}
impl From<TailwindColor> for TailwindVia {
fn from(color: TailwindColor) -> Self {
Self { color }
}
}
impl From<TailwindColor> for TailwindTo {
fn from(color: TailwindColor) -> Self {
Self { color }
}
}
impl Display for TailwindFrom {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "from-{}", self.color)
}
}
impl Display for TailwindVia {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "via-{}", self.color)
}
}
impl Display for TailwindTo {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "to-{}", self.color)
}
}
impl TailwindInstance for TailwindFrom {
fn attributes(&self, ctx: &TailwindBuilder) -> BTreeSet<CssAttribute> {
let color = self.color.get_properties(ctx);
css_attributes! {
"--tw-gradient-from" => color,
"--tw-gradient-stops" => format!("var(--tw-gradient-from),var(--tw-gradient-to,{color})", color=color)
}
}
}
impl TailwindInstance for TailwindVia {
fn attributes(&self, ctx: &TailwindBuilder) -> BTreeSet<CssAttribute> {
let color = self.color.get_properties(ctx);
css_attributes! {
"--tw-gradient-stops" => format!("var(--tw-gradient-from),{color},var(--tw-gradient-to,{color})", color=color)
}
}
}
impl TailwindInstance for TailwindTo {
fn attributes(&self, ctx: &TailwindBuilder) -> BTreeSet<CssAttribute> {
let color = self.color.get_properties(ctx);
css_attributes! {
"--tw-gradient-to" => color
}
}
}
impl TailwindFrom {
pub fn parse(input: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
Ok(Self { color: TailwindColor::parse(input, arbitrary)? })
}
pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
Ok(Self { color: TailwindColor::parse_arbitrary(arbitrary)? })
}
}
impl TailwindVia {
pub fn parse(input: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
Ok(Self { color: TailwindColor::parse(input, arbitrary)? })
}
pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
Ok(Self { color: TailwindColor::parse_arbitrary(arbitrary)? })
}
}
impl TailwindTo {
pub fn parse(input: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
Ok(Self { color: TailwindColor::parse(input, arbitrary)? })
}
pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
Ok(Self { color: TailwindColor::parse_arbitrary(arbitrary)? })
}
}