Skip to content

Commit

Permalink
Supports arbitrary @media modifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Oyelowo committed Oct 10, 2023
1 parent 219a918 commit 439d591
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tailwind/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ bg-[--my-color]
[&_p]:mt-4
flex [@supports(display:grid)]:grid
flex active:hover:[@supports(display:grid)]:grid
[@media(any-hover:hover){&:hover}]:opacity-100
"#
);
println!("TEXT - {}", test);
Expand Down
13 changes: 11 additions & 2 deletions tw-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::str::FromStr;

use nom::{
branch::alt,
bytes::complete::{tag, take_until, take_while1},
bytes::complete::{tag, take_till, take_until, take_while1},
character::complete::{multispace0, multispace1, space0, space1},
combinator::{all_consuming, not, opt, recognize},
multi::separated_list0,
Expand Down Expand Up @@ -827,8 +827,16 @@ fn arbitrary_at_supports_rule_modifier(input: &str) -> IResult<&str, ()> {
Ok((input, ()))
}

//
// [@media(any-hover:hover){&:hover}]:opacity-100
fn arbitrary_at_media_rule_modifier(input: &str) -> IResult<&str, ()> {
// starts with [@media and ends with ]
let (input, _) = tag("[@media(")(input)?;
let (input, _) = take_until("]")(input)?;
let (input, _) = tag("]")(input)?;
Ok((input, ()))
}

//
// group/edit invisible hover:bg-slate-200 group-hover/item:visible
// hidden group-[.is-published]:block
// group-[:nth-of-type(3)_&]:block
Expand Down Expand Up @@ -864,6 +872,7 @@ fn modifier(input: &str) -> IResult<&str, ()> {
arbitrary_front_selector_modifier,
arbitrary_back_selector_modifier,
arbitrary_at_supports_rule_modifier,
arbitrary_at_media_rule_modifier,
predefined_modifier,
))(input)
}
Expand Down

0 comments on commit 439d591

Please sign in to comment.