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
use crate::{css_attributes, CssAttribute, CssBehavior, TailwindBuilder, TailwindInstance};
use std::{
collections::BTreeSet,
fmt::{Display, Formatter},
};
#[derive(Copy, Clone, Debug)]
enum BackgroundRepeat {
Repeat,
RepeatX,
RepeatY,
Round,
Space,
None,
Global(CssBehavior),
}
#[doc = include_str!("readme.md")]
#[derive(Copy, Clone, Debug)]
pub struct TailwindBackgroundRepeat {
kind: BackgroundRepeat,
}
impl Display for BackgroundRepeat {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Repeat => write!(f, "repeat"),
Self::RepeatX => write!(f, "repeat-x"),
Self::RepeatY => write!(f, "repeat-y"),
Self::Round => write!(f, "repeat-round"),
Self::Space => write!(f, "repeat-space"),
Self::None => write!(f, "no-repeat"),
Self::Global(g) => write!(f, "{}", g),
}
}
}
impl Display for TailwindBackgroundRepeat {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "bg-{}", self.kind)
}
}
impl TailwindInstance for TailwindBackgroundRepeat {
fn attributes(&self, _: &TailwindBuilder) -> BTreeSet<CssAttribute> {
let clip = match &self.kind {
BackgroundRepeat::Repeat => "repeat".to_string(),
BackgroundRepeat::RepeatX => "repeat-x".to_string(),
BackgroundRepeat::RepeatY => "repeat-y".to_string(),
BackgroundRepeat::Round => "round".to_string(),
BackgroundRepeat::Space => "space".to_string(),
BackgroundRepeat::None => "no-repeat".to_string(),
BackgroundRepeat::Global(g) => g.to_string(),
};
css_attributes! {
"background-repeat" => clip
}
}
}
impl TailwindBackgroundRepeat {
pub const Repeat: Self = Self { kind: BackgroundRepeat::Repeat };
pub const RepeatX: Self = Self { kind: BackgroundRepeat::RepeatX };
pub const RepeatY: Self = Self { kind: BackgroundRepeat::RepeatY };
pub const Round: Self = Self { kind: BackgroundRepeat::Round };
pub const Space: Self = Self { kind: BackgroundRepeat::Space };
pub const None: Self = Self { kind: BackgroundRepeat::None };
}