styled-components / xstyled

A utility-first CSS-in-JS framework built for React. 💅👩‍🎤⚡️
https://xstyled.dev
MIT License
2.28k stars 105 forks source link

fix(emotion): broken getCreateStyle #254

Closed agriffis closed 3 years ago

agriffis commented 3 years ago

Summary

I misunderstood how xstyled's css function interacts with emotion's css function, so I added this complicated code in c400c70775be09033c65cb3626ce1a683198546d.

More recently, while working on #250, I discovered that it's also broken, because it converts a function argument into an array.

This simpler code does the one thing it needs to do: concat string separators to the tagged template literal corresponding to the number of generators.

It also produces a slightly more efficient result, because it does more work up front (testing generators.length and concatting arrays) before the resulting function, rather than every time the function runs.

Test plan

Updated styled.test.tsx to run some tests in common between styled.div and styled.box. Without this fix, the test "works with css as object and function prop" fails for styled.box

gregberge commented 3 years ago

@agriffis thanks for this!