[slider] General cleanup and add classes prop for unstyled#23569
Conversation
|
@material-ui/lab: parsed: -0.13% 😍, gzip: -0.09% 😍 |
| prettierConfigPath, | ||
| }); | ||
|
|
||
| if (!nonJSSComponent) { |
There was a problem hiding this comment.
For the components generated with withStyled the info and descriptions are gathered from the component's static styles field. However, for the unstyled & the components generated with styled() this info does not exists, but is taken from the ts definition of the classes prop. That is why we do not need to update the annotation for the classes definition for these components.
| // styled components does not have the options static | ||
| const styledComponent = !component?.default?.options; | ||
| if (styledComponent) { | ||
| const nonJSSComponent = !component?.default?.options; |
There was a problem hiding this comment.
This name better reflects the condition as it is true for both components generated with the styled utility, as well as the unstyled components
oliviertassinari
left a comment
There was a problem hiding this comment.
Great! Much better with a different pull request :)
|
|
||
| | Rule name | Global class | Description | | ||
| |:-----|:-------------|:------------| | ||
| | <span class="prop-name">root</span> | <span class="prop-name">.root-1</span> | Class name applied to the root element. |
There was a problem hiding this comment.
Good catch! The reason for it is that we don't have name for the SliderUnstyled :( (MuiSlider). We have few options of how to solve this
- generate this name from the component name for the unstyled components -> ComponentNameUnstyled -> MuiComponentName
- bring back the json only for this prop
- add a static field on the component for it.
I would vote for the first option.
There was a problem hiding this comment.
I guess it depends. If we export a classes object will all the default global class names, then the problem is solved, we can read it. Otherwise 1. sounds better.
There was a problem hiding this comment.
I think it's the best if the description are kept with the types definition, as they are for the other props. Exporting classes object can be complementary in my opinion.
| } catch (err) { | ||
| // Do nothing for now if the file doesn't exist | ||
| // This is still not supported for all components | ||
| // If the JSON file doesn't exists try extracting the info from the TS definition |
There was a problem hiding this comment.
Is the JSON file still necessary?
There was a problem hiding this comment.
We won't after I add the classes prop on the SliderStyled too. Wanted to do the changes step by step. That will be my next PR (with that one we can drop this section and remove the JSON files
There was a problem hiding this comment.
My bad, the prop already exists there, will do the necessary updates with this PR
There was a problem hiding this comment.
Creating follow up PR for removing the JSON files
There was a problem hiding this comment.
I've decided to include the changes as part of this PR - b254b2c as it wasn't related to the styled component.
There was a problem hiding this comment.
Fixed whitespaces too - ec98f8d Seems like this is solid and we can remove the JSON files. The only info there left required was the name which can be generated easily by the filename.
Co-authored-by: Olivier Tassinari <[email protected]>
eps1lon
left a comment
There was a problem hiding this comment.
docs-components-slider-styled/CustomizedSlider.png looks off: https://deploy-preview-23569--material-ui.netlify.app/components/slider-styled/#customized-sliders
The label container isn't even visible for me on Chrome 86 Ubuntu 20.04:

Isn't it suppose to look like that? I don't see difference with the v4 CustomizedSlider |
Just saw it and pished a fix for it - 1174a6b Let me know what you think We cannot rely on slot components to define custom selectors, as if we are styling the core component it's not predictable which ones will be written first. I moved these selectors to the root component so this can be always correct. Not sure if it is the best fix, but the only one I see that makes sense.. This would open questions as to whether these slots should also be exposed, but I wouldn't go that far.. |


This PR extracts some changes from #23308. The following changes are being made:
classesprop to theSliderUnstyledbuildAPIto reflect the definition in theclassesfor theCSSsection in the api pageunstyledpackageValueLabelStyledand moved the styles to theValueLabelStyled"slot" component.ValueLabelUnstyledtoSliderValueLabelUnstyledand reverted back some changes from the original implementation