Skip to content

Commit

Permalink
Support arbitrary contetnt with arrows
Browse files Browse the repository at this point in the history
  • Loading branch information
Oyelowo committed Oct 11, 2023
1 parent c1754a7 commit 822b81c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tailwind/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ fn main() {
after:content-['*'] after:ml-0.5 after:text-red-500 block text-sm font-medium text-slate-700
before:content-[''] before:block
content-[>]
content-[<]
bg-black/75 supports-[backdrop-filter]:bg-black/25 supports-[backdrop-filter]:backdrop-blur
aria-[sort=ascending]:bg-[url('/img/down-arrow.svg')] aria-[sort=descending]:bg-[url('/img/up-arrow.svg')]
Expand Down Expand Up @@ -91,6 +92,26 @@ aria-[sort=ascending]:bg-[url('/img/down-arrow.svg')] aria-[sort=descending]:bg-
"#
);
// 'content-[>]',
// // ^
// 'content-[<]',
// // ^
//
// // With functions and math expressions
// 'px-[calc(100%-1rem)]',
// 'px-[theme(spacing.1)]',
// 'px-[theme(spacing[1.5])]',
//
// // With spaces (replaced by `_`)
// 'bg-[rgb(255_0_0)]',
//
// // Examples with combinations
// 'w-[calc(100%_-_theme("spacing[1.5]))"]',
// 'fill-[oklab(59.69%_0.1007_0.1191_/_0.5)]/[33.7%]',
// 'fill-[color:oklab(59.69%_0.1007_0.1191_/_0.5)]/[33.7%]',
// 'shadow-[inset_0_-3em_3em_rgba(0,_0,_0,_0.1),_0_0_0_2px_rgb(255,_255,_255),_0.3em_0.3em_1em_rgba(0,_0,_0,_0.3)]'
//

// let test =
// tw!("peer[.is-dirty]:peer-required:block hidden hidden peer-[:nth-of-type(3)_&]:block");
println!("TEXT - {}", test);
Expand Down
12 changes: 12 additions & 0 deletions tw-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ fn arbitrary_content(input: &str) -> IResult<&str, ()> {
Ok((input, ()))
}

// content-[>] content-[<]
fn arbitrary_with_arrow(input: &str) -> IResult<&str, ()> {
let (input, _) = take_while1(is_ident_char)(input)?;
let (input, _) = tag("[")(input)?;
let (input, _) = alt((tag(">"), tag("<")))(input)?;
let (input, _) = take_until("]")(input)?;
let (input, _) = tag("]")(input)?;
Ok((input, ()))
}

// bg-black/25
fn predefined_colorful_opacity(input: &str) -> IResult<&str, ()> {
let input = if COLORFUL_BASECLASSES
Expand Down Expand Up @@ -506,6 +516,8 @@ fn parse_single_tw_classname(input: &str) -> IResult<&str, ()> {
colorful_arbitrary_baseclass,
// before:content-['Festivus']
arbitrary_content,
// content-[>] content-[<]
arbitrary_with_arrow,
// bg-[--my-color]
arbitrary_css_var,
// text-[var(--my-var)]
Expand Down

0 comments on commit 822b81c

Please sign in to comment.