-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
export emotion-theming from react-emotion #475
Conversation
@tkh44 @mitchellhamilton hey folks, any comments on this? |
From a somewhat selfish standpoint, this is a soft blocker on an internal migration away from styled-components at my company... trying to make the switch as painless as possible. Out of curiosity, why the hesitation to merge this based on our previous twitter convo @tkh44? |
Sorry, I've been on vacation for the last few weeks. @mitchellhamilton and I have talked about this about a week ago and we both were leaning on not merging. After some thought I think this might make sense just from a developer experience pov. Let's remove as much friction as possible for devs onboarding with emotion. @mitchellhamilton when we talked you mentioned some concerns with the preact build. Can you elaborate here? What are the other cons? |
Very much agree. When I was refactoring it felt weird to consume theming from a separate package — like it was disconnected in some way. But that really isn’t the case since it relies on certain static variables being available, etc. |
I think what we could do is make |
I could just revise emotion-theming. Children.only is essentially just a
check to prevent an array of children, so shouldn’t be challenging to
replace that check with a simpler alternative.
|
@@ -77,8 +77,18 @@ class ThemeProvider extends Component { | |||
render() { | |||
if (!this.props.children) { | |||
return null | |||
} else if (Array.isArray(this.props.children)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One trick I stole from preact-compat is to coerce it into an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is to just not worry about it except for a warning. For React > 16 it wouldn't matter anyway, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah for 16+ it wouldn’t matter.
I went ahead and updated the impl to be simpler :) along the lines of your suggestion
Any more notes? |
In my comment before, I should have made it more clear that this would mean preact-emotion requires an alias from |
Gotcha. Okay I’ll work on this over the next few days 👍 |
Codecov Report
|
While refactoring for a proof of concept, it quickly became cumbersome to have to split up the import just to pull in theming imports. Since theming functionality is partially built-in by default in emotion v8 via supporting `p => p.theme` etc, I think it makes sense to go the rest of the way and re-export `emotion-theming` for ease of use. update snapshots since the file contents changed
@mitchellhamilton okay, I converted withTheme and ThemeProvider into factory functions... but I don't really understand how babel-macro works. Mind giving some guidance on how to get the Preact part done? |
@probablyup babel-macros isn't related to this. First, could you remove UPDATE: instances is now on master |
I'm not going to be able to work on this for a while, so just going to close. |
While refactoring for a proof of concept, it quickly became cumbersome to have to split up the import just to pull in theming HOCs.
Since theming functionality is partially built-in by default in emotion v8 via supporting
p => p.theme
etc, I think it makes sense to go the rest of the way and re-export emotion-theming for ease of use.The package itself should probably go away for emotion v9.
Checklist: