-
-
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
[actions] Rename disableActionSpacing to disableSpacing #15355
[actions] Rename disableActionSpacing to disableSpacing #15355
Conversation
15fef14
to
da2c768
Compare
@material-ui/core: parsed: -0.11% 😍, gzip: -0.12% 😍 Details of bundle changes.Comparing: 4e4a2ed...2cf169d
|
da2c768
to
e6ec572
Compare
That "[CardActions] Rename the (I used to override the children of MuiCardActions in the theme overrides, as it was an easy way to override all the buttons inside CardActions, but now it doesn't work any more. *sigh* Well, I'll go now and override them in all the contexts instead or create a themed button for it.) |
@synchronos-t Have you tried to do something like this? .MuiCardActions-root > * {
background-color: red;
} |
@oliviertassinari I was actually gonna use |
@NMinhNguyen |
@oliviertassinari Do you mean because people often forget to forward the props? Or for another reason? Makes sense overall though. Do you think that context-based class propagation would be better than |
Yes, people have to know they need to forward the props, they forget it. Using the context has an overhead, it's better to rely on CSS where possible. |
I'm not aware of that. What's the overhead compared to |
@eps1lon It has an overhead vs using CSS. The pros of CSS for this case is that it targets any possible DOM node (less room for mistakes), it's fast to run (no JavaScript) and it's fast to write (you don't need to export a module or touch multiple files). |
@eps1lon @oliviertassinari I actually remembered a nasty caveat with a context-based solution. At work, we also had a use case where a Parent component wanted to influence how a Child is styled. Now, since both the Parent and Child were defining a style using a single className, then specificity-wise it came down to source order, i.e. which component in JS is executed first (essentially whose import Parent from './Parent';
import Child from './Child';
// or
import Child from './Child';
import Parent from './Parent'; This was annoying, and the only way to make the order more deterministic was for the Parent to import the child: // Parent.js
// Side-effecting import - the Parent doesn't render the Child :(
import './Child'; This approach seemed somewhat brittle and kinda relied on the fact that bundlers don't try to tree shake the unused Child import |
@NMinhNguyen That's an issue with cloneElement right? (not context) |
@oliviertassinari the issue I described above was when we used Context :) We had the Child component render a static class e.g. function Child() {
return <span className="static-class" />
}
const parentStyles = {
root: {
'&.static-class': {} // higher specificity because of root container + descendant selector
}
} And we wanted to remove this dependency on static classes.. So we introduced context to implicitly pass down |
marginLeft: 8, | ||
/* Styles applied to the root element if `disableSpacing={false}`. */ | ||
spacing: { | ||
'& > * + *': { |
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 css skills @oliviertassinari
Uses the same core solution for
ExpansionPanelActions
,CardActions
andDialogActions
.Breaking changes
disableActionSpacing
propdisableSpacing
.disableActionSpacing
CSS class.action
CSS classspacing
.disableActionSpacing
propdisableSpacing
.action
CSS classspacing
.action
CSS classspacing
.This change in the bundle size is interesting: