tailwind_css_fixes/modules/flexbox/place/place_self/
mod.rs

1use super::*;
2
3#[doc=include_str!("readme.md")]
4#[derive(Debug, Clone)]
5pub struct TailwindPlaceSelf {
6    kind: StandardValue,
7}
8
9crate::macros::sealed::keyword_instance!(TailwindPlaceSelf => "place-self");
10
11impl Display for TailwindPlaceSelf {
12    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
13        write!(f, "place-self-{}", self.kind)
14    }
15}
16
17impl TailwindPlaceSelf {
18    /// <https://tailwindcss.com/docs/place-self>
19    pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
20        Ok(Self { kind: StandardValue::parser("place-self", &Self::check_valid)(pattern, arbitrary)? })
21    }
22    /// dispatch to [place-self](https://developer.mozilla.org/en-US/docs/Web/CSS/place-self)
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/place-self#syntax>
27    pub fn check_valid(mode: &str) -> bool {
28        let set = BTreeSet::from_iter(vec![
29            "center",
30            "end",
31            "flex-end",
32            "flex-start",
33            "inherit",
34            "initial",
35            "normal",
36            "revert",
37            "space-around",
38            "space-between",
39            "space-evenly",
40            "start",
41            "stretch",
42            "unset",
43        ]);
44        set.contains(mode)
45    }
46}