Skip to content

[slider] General cleanup and add classes prop for unstyled#23569

Merged
mnajdova merged 23 commits into
mui:nextfrom
mnajdova:feat/slider-unstyled-cleanup
Nov 17, 2020
Merged

[slider] General cleanup and add classes prop for unstyled#23569
mnajdova merged 23 commits into
mui:nextfrom
mnajdova:feat/slider-unstyled-cleanup

Conversation

@mnajdova

Copy link
Copy Markdown
Member

This PR extracts some changes from #23308. The following changes are being made:

  • add classes prop to the SliderUnstyled
  • updated buildAPI to reflect the definition in the classes for the CSS section in the api page
  • adds helper tests for the unstyled package
  • removed unnecessary component ValueLabelStyled and moved the styles to the ValueLabelStyled "slot" component.
  • renamed ValueLabelUnstyled to SliderValueLabelUnstyled and reverted back some changes from the original implementation

@mui-pr-bot

mui-pr-bot commented Nov 16, 2020

Copy link
Copy Markdown

@material-ui/lab: parsed: -0.13% 😍, gzip: -0.09% 😍

Details of bundle changes

Generated by 🚫 dangerJS against 8067cb8

Comment thread docs/scripts/buildApi.ts Outdated
prettierConfigPath,
});

if (!nonJSSComponent) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/scripts/buildApi.ts Outdated
// styled components does not have the options static
const styledComponent = !component?.default?.options;
if (styledComponent) {
const nonJSSComponent = !component?.default?.options;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 oliviertassinari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Much better with a different pull request :)

Comment thread docs/pages/api-docs/slider-unstyled.md Outdated

| 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.

@oliviertassinari oliviertassinari Nov 16, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ .root-1

@mnajdova mnajdova Nov 16, 2020

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. generate this name from the component name for the unstyled components -> ComponentNameUnstyled -> MuiComponentName
  2. bring back the json only for this prop
  3. add a static field on the component for it.

I would vote for the first option.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are the changes - 11e29df Let me know if you'd like this solved some other way, but I think this should be fine. Cc @eps1lon you may have an opinion on this too

@oliviertassinari oliviertassinari Nov 16, 2020

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread docs/scripts/buildApi.ts
Comment thread docs/scripts/buildApi.ts
} 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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the JSON file still necessary?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, the prop already exists there, will do the necessary updates with this PR

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating follow up PR for removing the JSON files

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've decided to include the changes as part of this PR - b254b2c as it wasn't related to the styled component.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@oliviertassinari oliviertassinari added scope: slider Changes related to the slider. package: @mui/base Specific to @mui/base (legacy). labels Nov 16, 2020
Co-authored-by: Olivier Tassinari <[email protected]>
@oliviertassinari oliviertassinari changed the title [SliderUnstyled] General cleanup and add classes prop [Slider] General cleanup and add classes prop for unstyled Nov 16, 2020
Comment thread packages/material-ui-lab/src/SliderStyled/SliderStyled.test.js Outdated

@eps1lon eps1lon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Screenshot from 2020-11-16 17-37-35-1

@mnajdova

mnajdova commented Nov 16, 2020

Copy link
Copy Markdown
Member Author

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?
image

I don't see difference with the v4 CustomizedSlider
https://material-ui.com/components/slider/#customized-sliders

@mnajdova
mnajdova requested a review from eps1lon November 16, 2020 16:45
@oliviertassinari

oliviertassinari commented Nov 16, 2020

Copy link
Copy Markdown
Member

It looks OK in the demos, but not so much in the visual regression tests:

Capture d’écran 2020-11-16 à 17 59 54

@mnajdova

Copy link
Copy Markdown
Member Author

It looks OK in the demos, but not so much in the visual regression tests:

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..

@github-actions github-actions Bot added the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 16, 2020
@github-actions github-actions Bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged. label Nov 16, 2020
Comment thread docs/scripts/buildApi.ts Outdated
@mnajdova
mnajdova merged commit 8fd056e into mui:next Nov 17, 2020
@oliviertassinari oliviertassinari changed the title [Slider] General cleanup and add classes prop for unstyled [slider] General cleanup and add classes prop for unstyled May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: @mui/base Specific to @mui/base (legacy). scope: slider Changes related to the slider.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants