tailwind_css_fixes/modules/interactivity/will_change/
mod.rs

1use super::*;
2
3#[doc=include_str!("readme.md")]
4#[derive(Clone, Debug)]
5pub struct TailwindWillChange {
6    kind: StandardValue,
7}
8
9crate::macros::sealed::keyword_instance!(TailwindWillChange => "will-change");
10
11impl Display for TailwindWillChange {
12    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
13        write!(f, "will-change-{}", self.kind)
14    }
15}
16
17impl TailwindWillChange {
18    /// <https://tailwindcss.com/docs/will-change>
19    pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
20        Ok(Self { kind: StandardValue::parser("will-change", &Self::check_valid)(pattern, arbitrary)? })
21    }
22    /// dispatch to [will-change](https://developer.mozilla.org/en-US/docs/Web/CSS/will-change)
23    pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
24        StandardValue::parse_arbitrary(arbitrary).map(|kind| Self { kind })
25    }
26    /// https://developer.mozilla.org/en-US/docs/Web/CSS/will-change#syntax
27    pub fn check_valid(mode: &str) -> bool {
28        let set = BTreeSet::from_iter(vec![
29            "auto",
30            "contents",
31            "inherit",
32            "initial",
33            "opacity",
34            "revert",
35            "scroll-position",
36            "transform",
37            "unset",
38        ]);
39        set.contains(mode)
40    }
41}