-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[material-ui] Add DefaultPropsProvider
for Pigment CSS integration
#42638
Conversation
PropsProvider
for Pigment CSSPropsProvider
for Pigment CSS integration
Netlify deploy previewhttps://deploy-preview-42638--material-ui.netlify.app/ DefaultPropsProvider: parsed: +Infinity% , gzip: +Infinity% Bundle size reportDetails of bundle changes (Toolpad) |
9e6f101
to
4b89434
Compare
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 have a bit of misalignment in the names:
PropsProvider
vsuseDefaultProps
- we should either haveDefaultPropsProvider
anduseDefaultProps
, orPropsProvider
anduseProps
I like that the API is identical as before, but in ideal scenario this API in my opinion should be:
<DefaultPropsProvider
value={{
MuiButton: { disableRipple: true }, // note that I removed the defaultProps key
}}
>
I would prefer this API ☝️
PropsProvider
for Pigment CSS integrationDefaultPropsProvider
for Pigment CSS integration
Changed to |
@@ -1,3 +1,4 @@ | |||
.MuiTab-root .MuiTab-icon { | |||
color: red; | |||
} | |||
|
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.
This is not related to this PR. I have no idea how this passed the check before merging to next
.
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.
Fixed in #42686
} | ||
|
||
if (!config.styleOverrides && !config.variants) { | ||
// v6 signature, no property 'defaultProps' |
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.
Good call for adding both APIs 👌
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 work, let's merge this before the beta 🎉 This was the last missing part for interoperability, right?
No. There are 2 more, left over components and Pigment layout components (need decision on mui/pigment-css#144 (comment)) |
import PropTypes from 'prop-types'; | ||
import resolveProps from '@mui/utils/resolveProps'; | ||
|
||
const PropsContext = React.createContext<Record<string, any> | undefined>(undefined); |
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 are missing the codebase guideline for React context here:
const PropsContext = React.createContext<Record<string, any> | undefined>(undefined); | |
const PropsContext = React.createContext<Record<string, any> | undefined>(undefined); | |
if (process.env.NODE_ENV !== 'production') { | |
PropsContext.displayName = 'DefaultProps'; |
It's for the dev tools.
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.
Also, the name of the variable looks inaccurate:
const PropsContext = React.createContext<Record<string, any> | undefined>(undefined); | |
const DefaultPropsContext = React.createContext<Record<string, any> | undefined>(undefined); |
closes #42635
The gist is https://github.com/mui/material-ui/pull/42638/files#diff-532de7437125015b5ab87338e5e5950bc513e99fc7d987838a0f3755ee01408b, the rests are replacing
createUseThemeProps
withuseDefaultProps
.The signature changes but still support v5:
Testing
Only the spec is added because the logic is already tested by
describeConformance
from all the components.