tailwind_css_fixes/modules/effects/mix_blend/
mod.rs

1use super::*;
2
3#[doc=include_str!("readme.md")]
4#[derive(Clone, Debug)]
5pub struct TailwindBlend {
6    kind: StandardValue,
7}
8
9crate::macros::sealed::keyword_instance!(TailwindBlend => "mix-blend-mode");
10
11impl Display for TailwindBlend {
12    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
13        write!(f, "mix-blend-{}", self.kind)
14    }
15}
16
17impl TailwindBlend {
18    /// <https://tailwindcss.com/docs/mix-blend-mode>
19    pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
20        let kind = StandardValue::parser("mix-blend", &Self::check_valid)(pattern, arbitrary)?;
21        Ok(Self { kind })
22    }
23    /// get class of `<blend-mode>`
24    ///
25    /// - https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
26    #[inline]
27    pub fn get_class(&self) -> String {
28        self.kind.to_string()
29    }
30    /// get properties of `<blend-mode>`
31    ///
32    /// - https://developer.mozilla.org/zh-CN/docs/Web/CSS/blend-mode
33    #[inline]
34    pub fn get_properties(&self) -> &str {
35        self.kind.get_properties()
36    }
37    pub fn check_valid(mode: &str) -> bool {
38        let set = BTreeSet::from_iter(vec![
39            "normal",
40            "multiply",
41            "screen",
42            "overlay",
43            "darken",
44            "lighten",
45            "color-dodge",
46            "color-burn",
47            "hard-light",
48            "soft-light",
49            "difference",
50            "exclusion",
51            "hue",
52            "saturation",
53            "color",
54            "luminosity",
55        ]);
56        set.contains(mode)
57    }
58}