Closed agriffis closed 3 years ago
@gregberge After a couple rounds of reworking, this is ready. Want to take a look?
@gregberge Note there is a refactoring commit before the functional commit. It's a little easier to review as two separate commits, instead of the full set of changes at once.
Thanks @agriffis it is awesome! For API change, yeah it is better to keep it separated.
Summary
Fixes #240 with rule ordering instead of specificity.
It works like this:
which applies the generator at the conclusion of the given styles, so that props can override styles:
Notes
My first attempt at this PR changed the signature of the
styled
function to add optional generators, so for styled-components it becamestyled(component, ...generators)
and for emotion it becamestyled(component, options, ...generators)
. But for now I think it's better to refrain from changing the signature, so instead we have a new internal API:styledWithGenerator
so the existingstyled
export remains unmodified.That also means we don't have to monkey with types.
Test plan
Existing tests pass, and I added a couple new tests to make sure that props overriding works as expected.
I've also been using a local implementation of this same setup for a production app, and it's working well.