Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
[muiStyled] Support default theme when none is available #22791
[muiStyled] Support default theme when none is available #22791
Changes from 12 commits
c2d31cc
5ae933f
18b0668
f0ef95c
c7bebb8
92b2d6e
76256f1
8661306
61d7fac
c9fcdc1
48305e9
1c04d40
27d9f73
b149da5
05217a7
3bf96aa
551157f
a03252c
179a6e2
9878176
17ce5d4
b7ccb20
72398c8
58a1fb9
aac9e83
5774c19
8016f92
6bc05c1
9757a00
bb880fe
73d6589
6e2b480
0c8be58
a001588
e676780
0298222
c96062d
3e419ac
4fccc26
dcc97fa
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
We should specify what we need in case
emotion-theming
adds new modules that we don't need.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.
What problem does
emotion-theming
solve?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.
By adding the emotion's/styled-components'
ThemeProvider
in ourThemeProvider
component, developers no longer need to specifyThemeProvider
from emotion/styled component together with ours. Also, in thestyled
utility when custom theme is used, it will automatically be available onprops.theme
. In addition to this, when noThemeProvider
is used, thestyled
utility uses thedefaultTheme
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.
What if they already use
emotion-theming
?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.
I think that using a different ThemeProvider (enforcing the usage of two) makes incremental adoption easier. Developers don't have to worry about conflicts of theme structure with existing usage of emotion/sc.
However, for using the css prop, it seems required https://emotion.sh/docs/theming#css-prop.
It seems that theme-ui imports the ThemeContext of emotion directly (without emotion-theming), https://github.com/system-ui/theme-ui/blob/af57d4ce97c0e8a3289115f33cef1d17bc65adad/packages/core/src/index.ts#L3. They also have emotion as a direct dependency.
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.
Just a clarification, for our components, like
Slider
,Button
,muiStyled
+ ourThemeProvider
is working, it won't work for the scenarios of usingmuiStyled
+div
,span
or other primitive elements as we do not have access to change the behavior there.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.
Oh, I see, thanks for the clarification. +1 for including the styled-engine theme provider in Material-UI's ThemeProvider component. It's simpler. For the theme structure conflict, developers can workaround the issue by nesting
<MuiThemeProvider> > <Emotion ThemeProvider>
.The only point I would suggest to explore is: Using the ThemeContext exported from
@emotion/core
vs.emotion-theming
.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, let me spend some time on this, just to make sure I am not missing something 👍
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.
Refactored to use only the ThemeContext (both emotion & styled-components expose this). Tested with both engines, tests are passing, so I think everything is covered. No new dependencies added with this 👍
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.
Nice :).