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
use crate::modules::flexbox::*;
#[derive(Debug, Copy, Clone)]
enum JustifyContent {
Start,
End,
Center,
Between,
Around,
Evenly,
Global(CssBehavior),
}
#[doc=include_str!("readme.md")]
#[derive(Debug, Copy, Clone)]
pub struct TailwindJustifyContent {
kind: JustifyContent,
}
impl Display for JustifyContent {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Start => write!(f, "start"),
Self::End => write!(f, "end"),
Self::Center => write!(f, "center"),
Self::Between => write!(f, "between"),
Self::Around => write!(f, "around"),
Self::Evenly => write!(f, "evenly"),
Self::Global(g) => write!(f, "{}", g),
}
}
}
impl Display for TailwindJustifyContent {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "justify-{}", self.kind)
}
}
impl TailwindInstance for TailwindJustifyContent {
fn attributes(&self, _: &TailwindBuilder) -> BTreeSet<CssAttribute> {
let content = match self.kind {
JustifyContent::Start => "flex-start".to_string(),
JustifyContent::End => "flex-end".to_string(),
JustifyContent::Center => "center".to_string(),
JustifyContent::Between => "space-between".to_string(),
JustifyContent::Around => "space-around".to_string(),
JustifyContent::Evenly => "space-evenly".to_string(),
JustifyContent::Global(g) => g.to_string(),
};
css_attributes! {
"justify-content" => content
}
}
}
impl TailwindJustifyContent {
pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
debug_assert!(arbitrary.is_none(), "forbidden arbitrary after justify");
let kind = match pattern {
["start"] => JustifyContent::Start,
["end"] => JustifyContent::End,
["center"] => JustifyContent::Center,
["between"] => JustifyContent::Between,
["around"] => JustifyContent::Around,
["evenly"] => JustifyContent::Evenly,
_ => return syntax_error!("Unknown justify instructions: {}", pattern.join("-")),
};
Ok(Self { kind })
}
}