Skip to content
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] Add sx prop in SliderStyled #23205

Merged
merged 89 commits into from
Oct 23, 2020
Merged

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Oct 22, 2020

This PR adds the sx prop on the SliderStyled component.

Example usage:

<Slider
  defaultValue={30}
  aria-labelledby="disabled-slider"
  sx={{
    m: 2,
    color: 'secondary.main',
    bgcolor: 'primary.light',
  }}
/>

Related to #15561

@eps1lon
Copy link
Member

eps1lon commented Oct 22, 2020

I'm not really following how this prop is useful for complex components. Could you share a real-world use case?

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 22, 2020

Could you share a real-world use case?

@eps1lon In https://next.material-ui.com/system/basics/#real-world-use-case, it allows removing the Box with the clone prop. It basically allows closing #13100 with a composition demo or Button & Typography. Even complex components can leverage from the layout props (margin, max-width, etc.). Considering the prop was added to the styled() helper, simple or complex, all components can benefit from it, only paying the performance cost when used.
In the case of the Slider, because the color inherits.

I have added the issue we aim to close in the PR's description: #15561.

@oliviertassinari oliviertassinari added component: slider This is the name of the generic UI component, not the React module! new feature New feature or request labels Oct 22, 2020
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.

Great!

Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@oliviertassinari oliviertassinari changed the title [SliderStyled] Add sx prop [Slider] Add sx prop in SliderStyled Oct 22, 2020
@mnajdova
Copy link
Member Author

I wouldn't recommend adding examples for this per component. Next step will be to introduce a documentation for the sx prop. We will need to re-think the whole system guide, I plan to work on that next week.

mnajdova and others added 2 commits October 22, 2020 21:06
Co-authored-by: Olivier Tassinari <olivier.tassinari@gmail.com>
@mnajdova mnajdova merged commit 19439b4 into mui:next Oct 23, 2020
mbrookes pushed a commit to mbrookes/material-ui that referenced this pull request Oct 23, 2020
mbrookes pushed a commit to mbrookes/material-ui that referenced this pull request Oct 24, 2020
@eps1lon
Copy link
Member

eps1lon commented Oct 26, 2020

Could somebody summarize for me what the real-world use case is now? The PR body still has the styling that I wouldn't expect to find anywhere.

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 31, 2020

I wonder, did we drop the SliderProps type? Should we do?

diff --git a/packages/material-ui-lab/src/SliderStyled/SliderStyled.d.ts b/packages/material-ui-lab/src/SliderStyled/SliderStyled.d.ts
index 3b80b4c843..3cc143142c 100644
--- a/packages/material-ui-lab/src/SliderStyled/SliderStyled.d.ts
+++ b/packages/material-ui-lab/src/SliderStyled/SliderStyled.d.ts
@@ -36,6 +36,8 @@ export const SliderTrack: React.FC<SliderTrackProps>;
 export const SliderThumb: React.FC<SliderThumbProps>;
 export const SliderValueLabel: React.FC<SliderValueLabel>;

+export type SliderProps = SliderStyledTypeMap['props'];
+
 /**
  *
  * Demos:

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! new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants