Skip to content

Commit

Permalink
Take into consideration if classname is signable before allowing signs
Browse files Browse the repository at this point in the history
  • Loading branch information
Oyelowo committed Oct 11, 2023
1 parent 7f13a25 commit 3465f57
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tw-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 3 additions & 0 deletions tw-macro/src/tailwind/signable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,7 @@ pub const SIGNABLES: [&str; 40] = [
"grid-auto-columns",
"z",
"order",
// "scroll-mx",
// "scroll-my",
// "scroll-m",
];

0 comments on commit 3465f57

Please sign in to comment.