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-", |f, s| match s {
14 "both" => write!(f, "resize"),
15 "horizontal" => write!(f, "resize-x"),
16 "vertical" => write!(f, "resize-y"),
17 _ => Err(std::fmt::Error),
18 })
19 }
20}
21
22impl TailwindResize {
23 pub fn parse(pattern: &[&str], arbitrary: &TailwindArbitrary) -> Result<Self> {
25 let kind = match pattern {
26 [] if arbitrary.is_none() => StandardValue::from("both"),
27 ["x"] => StandardValue::from("horizontal"),
28 ["y"] => StandardValue::from("vertical"),
29 _ => StandardValue::parser("resize", &Self::check_valid)(pattern, arbitrary)?,
30 };
31 Ok(Self { kind })
32 }
33 pub fn check_valid(mode: &str) -> bool {
35 let set = BTreeSet::from_iter(vec![
36 "block",
37 "both",
38 "horizontal",
39 "inherit",
40 "initial",
41 "inline",
42 "none",
43 "revert",
44 "unset",
45 "vertical",
46 ]);
47 set.contains(mode)
48 }
49}