tailwind_css/modules/flexbox/content/
mod.rs1use super::*;
2
3pub(crate) mod content_align;
4
5#[doc=include_str!("readme.md")]
6#[derive(Debug, Clone)]
7pub struct TailwindContent {
8 kind: StandardValue,
9}
10
11crate::macros::sealed::keyword_instance!(TailwindContent => "content");
12
13impl Display for TailwindContent {
14 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
15 self.kind.fmt(f)
16 }
17}
18
19impl TailwindContent {
20 pub fn adapt(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Box<dyn TailwindInstance>> {
22 let instance = match pattern {
23 [] if arbitrary.is_some() => TailwindContent::parse_arbitrary(arbitrary)?.boxed(),
25 [s @ ("center" | "start" | "end" | "between" | "around" | "evenly")] => TailwindContentAlign::from(*s).boxed(),
27 ["align", rest @ ..] => TailwindContentAlign::parse(rest, arbitrary)?.boxed(),
28 _ => {
30 let s = pattern.join("-");
31 debug_assert!(Self::check_valid(&s));
32 TailwindContent::from(s).boxed()
33 },
34 };
35 Ok(instance)
36 }
37 pub fn parse_arbitrary(arbitrary: &TailwindArbitrary) -> Result<Self> {
38 Ok(Self { kind: StandardValue::Arbitrary(arbitrary.to_owned()) })
39 }
40 pub fn check_valid(mode: &str) -> bool {
42 let set = BTreeSet::from_iter(vec![
43 "close-quote",
44 "inherit",
45 "initial",
46 "no-close-quote",
47 "none",
48 "no-open-quote",
49 "normal",
50 "open-quote",
51 "revert",
52 "unset",
53 ]);
54 set.contains(mode)
55 }
56}