ben-rogerson / twin.macro

🦹‍♂️ Twin blends the magic of Tailwind with the flexibility of css-in-js (emotion, styled-components, solid-styled-components, stitches and goober) at build time.
MIT License
7.92k stars 183 forks source link

Improved variant ordering #759

Closed ben-rogerson closed 1 year ago

ben-rogerson commented 1 year ago

This PR fixes the ordering of variants on multi-variant classes:

tw`hover:[svg]:block`

// ↓ ↓ ↓ ↓ ↓ ↓

// Before
({ "svg:hover": { "display": "block" } });

// Now
({ ":hover svg": { "display": "block" } });

Thanks @u3u for the report which led me to look into this issue again - turned out an easy fix this time 🎉

The auto-parent selector then needed a couple tweaks:

I also fixed an error when non-media at-rules were used in arbitrary variants. (eg: [@page]:m-0)