tailwind_css_fixes/modules/interactivity/resize/
mod.rs1use super::*;
2
3#[doc=include_str!("readme.md")]
4#[derive(Debug, Clone)]
5pub struct TailwindResize {
6 kind: StandardValue,
7}
8
9crate::macros::sealed::keyword_instance!(TailwindResize => "resize");
10
11impl Display for TailwindResize {
12 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
13 self.kind.write_class(f, "resize-", |s| match s {
14 "both" => KeywordClassFormat::CustomClassname("resize"),
15 "horizontal" => KeywordClassFormat::AddAsSuffixCustom("x"),
16 "vertical" => KeywordClassFormat::AddAsSuffixCustom("y"),
17
18 keyword if TailwindResize::check_valid(keyword) => KeywordClassFormat::AddAsSuffix,
19
20 _ => KeywordClassFormat::InvalidKeyword,
21 })
22 }
23}
24
25impl TailwindResize {
26 pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
28 let kind = match pattern {
29 [] if arbitrary.is_none() => StandardValue::from("both"),
30 ["x"] => StandardValue::from("horizontal"),
31 ["y"] => StandardValue::from("vertical"),
32 _ => StandardValue::parser("resize", &Self::check_valid)(pattern, arbitrary)?,
33 };
34 Ok(Self { kind })
35 }
36 pub fn check_valid(mode: &str) -> bool {
38 let set = BTreeSet::from_iter(vec![
39 "block",
40 "both",
41 "horizontal",
42 "inherit",
43 "initial",
44 "inline",
45 "none",
46 "revert",
47 "unset",
48 "vertical",
49 ]);
50 set.contains(mode)
51 }
52}