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

Add support for emotion 10 #44

Merged
merged 1 commit into from
Dec 28, 2018
Merged

Add support for emotion 10 #44

merged 1 commit into from
Dec 28, 2018

Conversation

abalmos
Copy link
Contributor

@abalmos abalmos commented Dec 28, 2018

This adds support for emotion 10. I would love to see this out quickly and would be happy to make edits. The new features are:

Enable template literal and non css prop object styles

Changes:

  1. Add @emotion/core and @emotion/styled to supports object. These are the new imports for emotion 10. From postcss-jsx's perspective everything else is the same.

Enable object style for css prop

This is not straight forward anymore. Due to emotion 10's "magic" surrounding React.createElement, the component's namespace does not obviously reference emotion. Template literals in the css prop works because the literal itself can be traced back emotion. Object styles can not. The strategy used here (for lack of a better idea) is to assume all css props are styles when @emotion/core is imported. This seems reasonable because @emotion/core also treats css props this way.

Changes:

  1. Add cssPropsImpliesStyle object and cssPropsIsStyle flag. I wrote this to be generic like the supports object in anticipation others will follow emotion 10's lead.

This fixes #43

@codecov
Copy link

codecov bot commented Dec 28, 2018

Codecov Report

Merging #44 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #44   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          20     20           
  Lines         486    490    +4     
=====================================
+ Hits          486    490    +4
Impacted Files Coverage Δ
extract.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 860808b...bd3f44d. Read the comment docs.

@ianvieira
Copy link

Was this change reverted? I some changes were removed at #45

@gucong3000
Copy link
Owner

Was this change reverted?

Updated, but test cases are preserved here: https://github.com/gucong3000/postcss-jsx/blob/master/test/fixtures/emotion-10.jsx

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.

Support emotion 10?
3 participants