tailwind_css_fixes/systems/css_global/attribute/
mod.rs

1use super::*;
2
3mod traits;
4
5/// A css property is used to remove duplicates.
6///
7/// In principle, each css property will only appear once, and the one set later will override the previous one.
8#[derive(Debug, Clone, Default, Ord, PartialOrd, Eq, PartialEq, Hash)]
9pub struct CssAttributes {
10    normal: ImportantMap,
11    transforms: ImportantSet,
12    backdrop_filter: ImportantSet,
13    filter: ImportantSet,
14}
15
16impl CssAttributes {
17    /// # Arguments
18    ///
19    /// * `key`: css class
20    /// * `value`: css property
21    ///
22    /// returns: [`CssAttribute`]
23    #[track_caller]
24    pub fn insert<K, V>(&mut self, key: K, value: V)
25    where
26        K: Into<String>,
27        V: Into<String>,
28    {
29        let key = key.into();
30        match key.as_str() {
31            "transform" => self.transforms.insert(value.into()),
32            "backdrop-filter" => self.backdrop_filter.insert(value.into()),
33            "filter" => self.filter.insert(value.into()),
34            _ => self.normal.insert(key, value.into()),
35        };
36    }
37
38    /// # Arguments
39    ///
40    /// * `items`:
41    ///
42    /// returns: ()
43    pub fn extend<T>(&mut self, items: T)
44    where
45        T: IntoIterator<Item = (String, String)>,
46    {
47        for i in items {
48            self.insert(i.0, i.1);
49        }
50    }
51}