-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Core] Removes mergeAndPrefix(), refactor uses mergeStyles() and prepareStyles() #2886
Conversation
@alitaheri @oliviertassinari Please take your time on this one and review/test very carefully. I want to start refactoring I think removing Related to #2852 |
@newoga I will review it. That's a very good first step 👍. |
@oliviertassinari @alitaheri What are your thoughts on switching I think it's more explicit to use function merge(...args) {
// impl
}
function prepare(muiTheme, style) {
// impl
}
// If you want to merge themes while preparing, do:
prepare(muiTheme, merge(styleA, styleB)); We don't have to do in in this PR, but wanted to get your feedback on it either way. |
@newoga Good work 👍 Thank you ^_^
I like this idea very much! Yeah I think this is how it should be. |
|
||
let children = React.Children.map(this.props.children, (child) => { | ||
return React.cloneElement(child, {style: this.prepareStyles(styles.mediaChild, child.props.style)}); | ||
return React.cloneElement(child, {style: this.mergeStyles(styles.mediaChild, child.props.style)}); |
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.
CardMedia
doesn't seem to take Material Ui component. Shouldn't we use prepareStyles
?
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 I think you're right, my mistake!
Thanks for catching. 😄
@newoga Nice work, I have checked every components of the docs, looking for |
@oliviertassinari @alitaheri Thanks much for your review! This is just the first step, if everything looks good with just the overall removal of I'm going to squash the couple of small merge and prepare fixes that we found now. |
@newoga Thank you. This is certainly a great step toward better code quality 👍 👍 👍 |
…tyles() This commit removes all instances of `mergeAndPrefix()` in our internal codebase. It also deprecates use of the `mergeAndPrefix()` method from the `style-propable` mixin. It also changes our use of `mergeStyles()` and `prepareStyles()` accross src in a more consistent manner. All uses of `mergeAndPrefix()` were switched to `mergeStyles()` OR `prepareStyles()` based on the following condition: - If the computed style is passed directly to a html tag's style attribute (ie. div, span, li, etc.) OR to an externally managed component's style prop (such as `ReactTransitionGroup`), use `prepareStyles()` - If the computed style is passed to an internal component's style prop, or any related style props, use `mergeStyles()` This prevents any top level/parent components from prematurely preparing styles (styles should only be prepared when attaching to a DOM node). I did searches accross src and found places where that pattern were not followed and switched them as well.
d6da0e3
to
bb008a6
Compare
@alitaheri No problem, slowly but surely we will get there! 😄 @alitaheri @oliviertassinari |
👍 👍 Thank you @newoga |
[Core] Removes mergeAndPrefix(), refactor uses mergeStyles() and prepareStyles()
This commit removes all instances of
mergeAndPrefix
. It also aims to usemergeStyles
andprepareStyles
in a more consistent manner. All uses ofmergeAndPrefix
were switched tomergeStyles
ORprepareStyles
depending on the following condition:ReactTransitionGroup
), useprepareStyles
mergeStyles
This prevents any top level/parent components from prematurely preparing styles (styles should only be prepared when attaching to a DOM node).
I did searches across src and found places where that pattern were not followed and switched them as well.