tailwind_css/modules/typography/whitespace/
mod.rs

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