From 439d591a0725992d083ff11f49c5efb6cce906cc Mon Sep 17 00:00:00 2001 From: oyelowo Date: Mon, 9 Oct 2023 20:20:44 -0600 Subject: [PATCH] Supports arbitrary @media modifier --- tailwind/src/main.rs | 4 ++++ tw-macro/src/lib.rs | 13 +++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tailwind/src/main.rs b/tailwind/src/main.rs index 0592397..0673700 100644 --- a/tailwind/src/main.rs +++ b/tailwind/src/main.rs @@ -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); diff --git a/tw-macro/src/lib.rs b/tw-macro/src/lib.rs index 2466e14..812b3d6 100644 --- a/tw-macro/src/lib.rs +++ b/tw-macro/src/lib.rs @@ -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, @@ -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 @@ -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) }