tailwind_css_fixes/systems/css_global/attribute/
traits.rs

1use super::*;
2
3impl Display for CssAttributes {
4    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
5        // Write normal attributes (based on Display impl of ImportantMap):
6        // - property: value;
7        write!(f, "{}", self.normal)?;
8        // - normal attribiutes with special formats:
9        if !self.transforms.is_empty() {
10            write!(f, "transform:{}", self.transforms)?
11        }
12        if !self.filter.is_empty() {
13            write!(f, "filter:{}", self.filter)?
14        }
15        if !self.backdrop_filter.is_empty() {
16            write!(f, "backdrop-filter:{}", self.backdrop_filter)?
17        }
18
19        // Write each of the nested rules
20        for (selector, nested_attrs) in &self.nested {
21            write!(f, "{} {{ {} }}", selector, nested_attrs)?;
22        }
23        Ok(())
24    }
25}
26
27impl Add<Self> for CssAttributes {
28    type Output = CssAttributes;
29
30    fn add(self, rhs: Self) -> Self::Output {
31        let mut out = self;
32        out += rhs;
33        out
34    }
35}
36
37impl AddAssign<Self> for CssAttributes {
38    fn add_assign(&mut self, rhs: Self) {
39        self.normal += rhs.normal;
40        self.transforms += rhs.transforms;
41        self.filter += rhs.filter;
42        self.backdrop_filter += rhs.backdrop_filter;
43    }
44}