-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Slider] Extract slots as standalone components #22893
[Slider] Extract slots as standalone components #22893
Conversation
@material-ui/lab: parsed: +0.21% , gzip: +0.17% |
Closing, as it was done for experiment only |
I'll need to update the |
Playground for testing |
…github.com/mnajdova/material-ui into feat/slider-experiment-multiple-components
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 trade-off is tough. Initially, we have started to work in this pull request in order to evaluate the performance implication. We shared the results in #22342 (comment), then started to engage with the community about it. To summarize we have:
pros for dropping classes
:
- the API was meant for JSS, there aren't any real use cases outside of it. Assuming JSS is here to fade, the prop is, long term, extra weight with no value.
jQuery UI added the prop and justified it for global .css file switch. Same rationale in react-autosuggest. Does it really make sense? - each extra
styled
component slows things down. For instance, take the Button, we will need one for the root and one for the label. We have measured a 20% performance decrease with the slider ([RFC] v5 styling solution 💅 #22342 (comment)). The slider has 7 intermediary elements. For the data grid, it's highly unlikely that we can accept this degradation, at least, for the grid viewport. - early feedback from the community on the discussion were: -20% of performance? drop it.
pros for keeping classes
:
- makes the migration from v4 to v5 easier. Without, developers that customize the components will need to rewrite.
- specificity if flatten usually, it means simpler customizations.
- When there are multiple intermediary components. emotion CSS injection priority only works if the styles are applied to the same component. If you target a different one, you need to increase specificity to win. Having a specificity of one by default help. I think that it also helps SASS users as they don't need to nest selectors, they can write them flat.
Happy to go in this direction
packages/material-ui-unstyled/src/SliderUnstyled/SliderUnstyled.js
Outdated
Show resolved
Hide resolved
packages/material-ui-unstyled/src/SliderUnstyled/SliderUnstyled.test.js
Outdated
Show resolved
Hide resolved
packages/material-ui-unstyled/src/SliderUnstyled/SliderUnstyled.test.js
Outdated
Show resolved
Hide resolved
packages/material-ui-unstyled/src/SliderUnstyled/SliderUnstyled.test.js
Outdated
Show resolved
Hide resolved
}; | ||
|
||
return utilityClasses; | ||
}; | ||
|
||
const isComponent = (element) => typeof element !== 'string'; | ||
const isHostComponent = (element) => typeof element === 'string'; |
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.
A note for the second component we will migrate, we might want to abstract this helper, we will need it everywhere
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, makes sense, probably there will be other things that can be abstracted, but for the thing I wasn't sure I just added them inline for now :)
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, better until we know for sure :)
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 discussion reminds me of something 🤔
(something wet... 😉 )
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.
It was too fresh not to use it 😅
I am merging this one so I can update #23308 I can address any additional comments there. |
This PR transforms the slots inside the Slider as standalone styled components. This will allow us to support back the
classes
prop on this component. Plaground for testing theclasses
prop here -https://codesandbox.io/s/continuousslider-material-demo-forked-40y7u?file=/demo.js