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

The great "rewrite to lean more on tailwind" PR #739

Closed ben-rogerson closed 2 years ago

ben-rogerson commented 2 years ago

Previously each time tailwindcss released a new feature, twin matched that feature the "twin way". Aside from requiring a huge amount of time and investment to do this, it also meant users needed to wait until the same features land in twin.

So in this PR I made some big changes...

Here's what's now roughly happening under the hood:

  1. Twin grabs your classes with babel
  2. Twin converts the classes into tailwindcss valid syntax
  3. Classes are given to tailwindcss for matching (and for ordering if we supply a set of classes)
  4. Twin checks and converts the result into css-in-js valid syntax
  5. Twin replaces your classes with the new styles using babel

Previously twin would perform all of the matching and all of the ordering. Tailwind was only used for interpreting parts of your tailwind config and providing back a bunch of raw data after being run through PostCSS.

I've rewritten and rearranged the codebase - in TypeScript now too - and we now have these awesome features:

This work contains most of the rc4 version and shortly after it'll all be pushed into the big twin.macro@v3 release! ๐ŸŒฎ ๐ŸŽ‰