Skip to content

[Slider][material-next] Add Slider component with Material You design #37520

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

Merged
merged 30 commits into from
Jun 15, 2023

Conversation

DiegoAndai
Copy link
Member

@DiegoAndai DiegoAndai commented Jun 6, 2023

Slider issue: #37527
Material You umbrella issue: #29345

Changes

Preview: https://deploy-preview-37520--material-ui.netlify.app/material-ui/react-slider/#experimental-api

Add Slider component implementing Material You style specifications:

Todo

Playground

You can try out the deploy preview playground to see the component.

Screen.Recording.2023-06-05.at.16.59.17.mov

@mui-bot
Copy link

mui-bot commented Jun 6, 2023

Netlify deploy preview

@mui/material-next: parsed: +0.22% , gzip: +0.19%

Bundle size report

Details of bundle changes

Generated by 🚫 dangerJS against 4b3de78

@DiegoAndai DiegoAndai added design: material you component: slider This is the name of the generic UI component, not the React module! labels Jun 6, 2023
@DiegoAndai DiegoAndai changed the title [Material You] Add Slider component [Slider][material-next] Add Slider component with Material You design Jun 6, 2023
@DiegoAndai DiegoAndai self-assigned this Jun 6, 2023
@oliviertassinari oliviertassinari added design: material This is about Material Design, please involve a visual or UX designer in the process package: material-ui Specific to @mui/material v6.x labels Jun 6, 2023
Copy link
Member

@oliviertassinari oliviertassinari left a comment

Choose a reason for hiding this comment

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

I see that we started to use #29345 for splitting the work into smaller chunks under "Progress", great.


export { SliderThumb };

const StyledSliderValueLabel = styled(SliderValueLabel, {
Copy link
Member

Choose a reason for hiding this comment

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

Interesting, did you copy the implementation of Material UI v4 https://github.com/mui/material-ui/blob/v4.x/packages/material-ui/src/Slider/ValueLabel.js#L5 https://v4.mui.com/components/slider/#discrete-sliders or from somewhere else? To see if there aren't things to copy from there.

It seems that with MD v3, they decided to revert the value label of MD v2 https://m2.material.io/components/sliders#usage back to MD v1 https://m1.material.io/components/sliders.html#sliders-discrete-slider 🙃.

Copy link
Member Author

@DiegoAndai DiegoAndai Jun 7, 2023

Choose a reason for hiding this comment

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

Didn't know MD v1 had the same value label 😅. I copied everything from Material UI v5, and then modified the styles. For the value label, I actually used this Base UI example as a guide as it has the same type of value label.

@mnajdova
Copy link
Member

mnajdova commented Jun 7, 2023

For the proptypes generation, I created #37533.

@@ -280,14 +280,17 @@ const customPalette = {
neutral: {
'0': '#000000',
'10': '#201a1c',
'17': '#2e282a',
Copy link
Member

Choose a reason for hiding this comment

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

We will need to update the types too. Are these values coming from the specs?

Copy link
Member Author

@DiegoAndai DiegoAndai Jun 7, 2023

Choose a reason for hiding this comment

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

Updated them here 😊:

neutral: MD3Tones & { 17: string; 22: string; 92: string };

Yes, they come from the specs. Here are the values for the MD3 default theme, and here I added them to our palette:

For this experiment file, I noticed that it didn't use the default MD3 colors so I created the tones based on the existing neutral tones, altering the light value as explained in: https://m3.material.io/styles/color/the-color-system/key-colors-tones#a828e350-1551-45e5-8430-eb643e6a7713

These are used for the surfaceContainerHigh and surfaceContainerHighest tokens:

Screenshot 2023-06-07 at 08 19 31

const ValueLabelComponent = valueLabelDisplay === 'off' ? Forward : ValueLabelSlot;

return (
/* TODO v6: Change component structure. It will help in avoiding the complicated React.cloneElement API added in SliderValueLabel component. Should be: Thumb -> Input, ValueLabel. Follow Joy UI's Slider structure. */
Copy link
Member

Choose a reason for hiding this comment

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

We likely want to address this in a follow up PR soon after this one is merged :)

@DiegoAndai DiegoAndai linked an issue Jun 7, 2023 that may be closed by this pull request
8 tasks
@DiegoAndai DiegoAndai requested a review from michaldudak June 13, 2023 13:33
@DiegoAndai DiegoAndai requested a review from michaldudak June 15, 2023 15:10
Copy link
Member

@michaldudak michaldudak left a comment

Choose a reason for hiding this comment

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

All right, this looks good! Great job!

@DiegoAndai DiegoAndai merged commit f459539 into mui:master Jun 15, 2023
@DiegoAndai DiegoAndai deleted the material-you-slider branch June 19, 2023 17:00
@DiegoAndai DiegoAndai added v7.x and removed v6.x labels Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: slider This is the name of the generic UI component, not the React module! design: material you design: material This is about Material Design, please involve a visual or UX designer in the process package: material-ui Specific to @mui/material v7.x
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants