tailwind_css_fixes/modules/flexbox/justify/justify_content/
mod.rs1use super::*;
2
3#[doc=include_str!("readme.md")]
4#[derive(Debug, Clone)]
5pub struct TailwindJustifyContent {
6 kind: StandardValue,
7}
8
9crate::macros::sealed::keyword_instance!(TailwindJustifyContent => "justify-content", {
10 "between" => "space-between",
12 "around" => "space-around",
13 "evenly" => "space-evenly",
14 "start" => "flex-start",
15 "left" => "flex-start",
16 "end" => "flex-end",
17 "right" => "flex-end",
18 "center-safe" => "safe center",
19 "end-safe" => "safe end",
20 });
22
23impl Display for TailwindJustifyContent {
24 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
25 match &self.kind {
26 StandardValue::Keyword(s) => match s.as_str() {
27 "flex-start" => write!(f, "justify-start"),
29 "flex-end" => write!(f, "justify-end"),
30 "center" => write!(f, "justify-center"),
31 "space-between" => write!(f, "justify-between"),
32 "space-around" => write!(f, "justify-around"),
33 "space-evenly" => write!(f, "justify-evenly"),
34 "safe center" => write!(f, "justify-center-safe"),
35 "safe end" => write!(f, "justify-end-safe"),
36 _ => write!(f, "justify-{}", s),
38 },
39 StandardValue::Arbitrary(s) => s.write_class(f, "justify-content-"),
40 }
41 }
42}
43
44impl TailwindJustifyContent {
45 pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
47 let mut kind = StandardValue::parser("justify-content", &Self::check_valid)(pattern, arbitrary)?;
49
50 if let StandardValue::Keyword(s) = &kind {
52 kind = StandardValue::Keyword(Self::map_keyword(s).to_string());
53 }
54
55 Ok(Self { kind })
56 }
57 pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
59 StandardValue::parse_arbitrary(arbitrary).map(|kind| Self { kind })
60 }
61 pub fn check_valid(mode: &str) -> bool {
63 let set = BTreeSet::from_iter(vec![
64 "start",
65 "end",
66 "center",
67 "between",
68 "around",
69 "evenly",
70 "stretch",
71 "baseline",
72 "normal",
73 "flex-start", "flex-end", "space-around", "space-between", "space-evenly", "start",
79 "stretch",
80 "end-safe",
81 "center-safe",
82 "inherit",
84 "initial",
85 "left",
86 "revert",
87 "right",
88 "unset",
89 ]);
90 set.contains(mode)
91 }
92}