From 3465f578bb8d924fbd0e13e6c67e7f12cc57ef83 Mon Sep 17 00:00:00 2001 From: oyelowo Date: Tue, 10 Oct 2023 18:40:58 -0600 Subject: [PATCH] Take into consideration if classname is signable before allowing signs --- tw-macro/src/lib.rs | 11 ++++++++++- tw-macro/src/tailwind/signable.rs | 3 +++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/tw-macro/src/lib.rs b/tw-macro/src/lib.rs index ffa17be..1c42977 100644 --- a/tw-macro/src/lib.rs +++ b/tw-macro/src/lib.rs @@ -84,7 +84,16 @@ fn parse_predefined_tw_classname(input: &str) -> IResult<&str, ()> { )(i) })(input)?; - if is_valid_classname(class_name.strip_prefix("-").unwrap_or(class_name)) { + let is_signable = SIGNABLES.iter().any(|s| { + class_name + .strip_prefix("-") + .unwrap_or(class_name) + .starts_with(s) + }); + + if is_signable && is_valid_classname(class_name.strip_prefix("-").unwrap_or(class_name)) { + Ok((input, ())) + } else if !is_signable && is_valid_classname(class_name) { Ok((input, ())) } else { Err(nom::Err::Error(nom::error::Error::new( diff --git a/tw-macro/src/tailwind/signable.rs b/tw-macro/src/tailwind/signable.rs index 78a448a..fb03cca 100644 --- a/tw-macro/src/tailwind/signable.rs +++ b/tw-macro/src/tailwind/signable.rs @@ -45,4 +45,7 @@ pub const SIGNABLES: [&str; 40] = [ "grid-auto-columns", "z", "order", + // "scroll-mx", + // "scroll-my", + // "scroll-m", ];