[styles] Remove the old styles modules#14560
Conversation
a4ef194 to
5375f96
Compare
5375f96 to
be4b7c6
Compare
4d5fe17 to
ceb8276
Compare
77971a7 to
a82d8dc
Compare
The whole community is using hoist-non-react-statics, let's go for it. We should be able to remove the yarn version lock at some point. *This change is taken from #14560 as an effort not to merge too big pull requests.*
fd6b76b to
0fe2fdf
Compare
|
@material-ui/core: parsed: -2.51% 😍, gzip: +0.12% Details of bundle changes.Comparing: 7a49f80...cea8cb8
|
56e6093 to
2564e45
Compare
2564e45 to
08ac17f
Compare
eps1lon
left a comment
There was a problem hiding this comment.
Main objection is about bundle names. Other things are mainly about clarifying the @material-ui/core/styles vs. @material-ui/styles difference
| import { create } from 'jss'; | ||
| import { withStyles, jssPreset } from '@material-ui/core/styles'; | ||
| import { StylesProvider } from '@material-ui/styles'; | ||
| import { withStyles } from '@material-ui/core/styles'; |
There was a problem hiding this comment.
I thought the old module was removed and we use
- import { withStyles } from '@material-ui/core/styles';
+ import { withStyles } from '@material-ui/styles';There was a problem hiding this comment.
You made me think that I have forgotten the hook demos. I have done the following change:
-import { makeStyles } from '@material-ui/styles';
+import { makeStyles } from '@material-ui/core/styles';So people can copy & paste the demos directly.
|
|
||
| return (props = {}) => { | ||
| const theme = listenToTheme ? React.useContext(ThemeContext) || defaultTheme : defaultTheme; | ||
| const theme = (listenToTheme ? useTheme() : null) || defaultTheme; |
There was a problem hiding this comment.
I would go with the pattern suggested from the react issue and call a custom hook unconditionally that was created in the outer scope. That whole statement looks really scary.
| return <Component ref={innerRef || ref} classes={classes} {...more} />; | ||
| }); | ||
|
|
||
| if (process.env.NODE_ENV === 'test' && !ponyfillGlobal.disableShallowSupport) { |
There was a problem hiding this comment.
This removes the need for migrating all the tests away from the shallow API. We can consider killing this code branch once we have removed all the shallow tests :). It has a second advantage, it makes the class names deterministic in the test environment. Related to #14358.
There was a problem hiding this comment.
it makes the class names deterministic in the test environment
That is a lot of redundant code for behavior that is only required for a single testing pattern that is already solvable. Emotion and styled-components agree with me here. I hope this gets removed once we figure out shallow testing.
There was a problem hiding this comment.
Yes, I think that this whole code branch should get removed. Now the tradeoff was:
remove install() step > this extra logic, (> as more important)
| withTheme, | ||
| WithTheme, | ||
| } from './styles'; | ||
| export { createMuiTheme, Theme, withStyles, WithStyles, withTheme, WithTheme } from './styles'; |
There was a problem hiding this comment.
This doesn't match packages/material-ui/src/index.js
| } | ||
|
|
||
| export default ponyfillGlobal.__MUI_STYLES__.MuiThemeProvider; | ||
| export default ThemeProvider; |
There was a problem hiding this comment.
If it still exists we should include the types.
There was a problem hiding this comment.
It's only here until I figure out how to handle the CDN demo.
| { | ||
| // vs https://bundlephobia.com/result?p=react-popper | ||
| name: '@material-ui/core/Popper', | ||
| name: 'Popper', |
There was a problem hiding this comment.
diffs are tracked via name. Should've named this id instead to make its purpose clear.
We can introduce a human label in another PR.
There was a problem hiding this comment.
We shouldn't have any collision (or few exceptions) between the modules we are exporting. How is this an issue?
1f2791f to
cea8cb8
Compare
moved to #14767.