tailwind_css/modules/flexbox/grow/
mod.rs

1use super::*;
2
3#[doc=include_str!("readme.md")]
4#[derive(Debug, Clone)]
5pub struct TailWindGrow {
6    grow: NumericValue,
7}
8
9impl Display for TailWindGrow {
10    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
11        write!(f, "grow-{}", self.grow)
12    }
13}
14
15impl TailwindInstance for TailWindGrow {
16    fn attributes(&self, _: &TailwindBuilder) -> CssAttributes {
17        css_attributes! {
18            "flex-grow" => self.grow
19        }
20    }
21}
22
23impl TailWindGrow {
24    /// https://tailwindcss.com/docs/flex-grow
25    pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
26        let grow = match pattern {
27            [] if arbitrary.is_none() => 100u32.into(),
28            _ => NumericValue::positive_parser("grow", Self::check_valid)(pattern, arbitrary)?,
29        };
30        Ok(Self { grow })
31    }
32    /// <https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow#syntax>
33    pub fn check_valid(mode: &str) -> bool {
34        let set = BTreeSet::from_iter(vec!["inherit", "initial", "revert", "unset"]);
35        set.contains(mode)
36    }
37}