Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain css + tw prop ordering in jsx #208

Merged
merged 1 commit into from
Nov 25, 2020

Conversation

ben-rogerson
Copy link
Owner

Possible breaking change

This PR gives twin the ability to maintain the ordering for the tw and css props added on jsx elements:

// New behaviour
<div tw="bg-blue-100" css={[tw`bg-red-100`]}/> // bg will be red

// Old behaviour
<div tw="bg-blue-100" css={[tw`bg-red-100`]}/> // bg will be blue

Chances are you never stumbled across this issue as we normally remove the tw prop after adding the css prop.

@ben-rogerson ben-rogerson merged commit dcca8b7 into master Nov 25, 2020
@ben-rogerson ben-rogerson deleted the feature/maintain-tw-css-prop-ordering branch November 25, 2020 20:36
@ben-rogerson
Copy link
Owner Author

ben-rogerson commented Nov 29, 2020

This PR actually only addressed the ordering when using arrays within the css prop (yes this was weird) so I fixed it properly to also address:

TemplateLiterals
<div css={...} tw="..." />

ObjectExpressions
<div css={{ ... }} tw="..." />

and ArrowFunctionExpressions / FunctionExpressions
<div css={() => ([ ... ])} tw="..." />
<div css={function() { return [ ... ] }} tw="..." />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant