tailwind_css_fixes/modules/transition/transit/
mod.rs1use super::*;
2
3#[derive(Clone, Debug)]
4enum Transition {
5 None,
6 All,
7 Default,
8 Colors,
9 Opacity,
10 Shadow,
11 Transform,
12 Arbitrary(TailwindArbitrary),
13}
14
15#[doc=include_str!("readme.md")]
16#[derive(Clone, Debug)]
17pub struct TailwindTransition {
18 kind: Transition,
19}
20
21impl Display for Transition {
22 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
23 match self {
24 Self::None => write!(f, "-none"),
25 Self::All => write!(f, "-all"),
26 Self::Default => write!(f, ""),
27 Self::Colors => write!(f, "-colors"),
28 Self::Opacity => write!(f, "-opacity"),
29 Self::Shadow => write!(f, "-shadow"),
30 Self::Transform => write!(f, "-transform"),
31 Self::Arbitrary(g) => write!(f, "-[{}]", g.get_class()),
32 }
33 }
34}
35
36impl Display for TailwindTransition {
37 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
38 write!(f, "transition[{}]", self.kind)
39 }
40}
41
42impl TailwindInstance for TailwindTransition {
43 fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
44 css_attributes! {}
45 }
46}
47
48impl TailwindTransition {
49 pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
50 Ok(Self { kind: Transition::parse(pattern, arbitrary)? })
51 }
52 pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
53 Ok(Self { kind: Transition::parse_arbitrary(arbitrary)? })
54 }
55}
56
57impl Transition {
58 pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
59 let t = match pattern {
60 [] if arbitrary.is_none() => Self::Default,
61 [] => Self::parse_arbitrary(arbitrary)?,
62 ["none"] => Self::None,
63 ["all"] => Self::All,
64 ["colors"] => Self::Colors,
65 ["opacity"] => Self::Opacity,
66 ["shadow"] => Self::Shadow,
67 ["transform"] => Self::Transform,
68 _ => return syntax_error!("Unknown transition instructions: {}", pattern.join("-")),
69 };
70 Ok(t)
71 }
72 pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
73 Ok(Self::Arbitrary(TailwindArbitrary::new(arbitrary)?))
74 }
75}