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 system prop #22819

Closed
wants to merge 19 commits into from
Closed

[Slider] Add system prop #22819

wants to merge 19 commits into from

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Sep 30, 2020

This PR adds system prop on the SliderStyled component

Related to #15561.

@mui-pr-bot
Copy link

mui-pr-bot commented Sep 30, 2020

@material-ui/core: parsed: +0.07% , gzip: +0.11%
@material-ui/lab: parsed: +2.49% , gzip: +1.90%

Details of bundle changes

Generated by 🚫 dangerJS against 0822e62

/**
* Common system props.
*/
system: PropTypes.object,
Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably come up with better name here... But I would definitely vote for defining all system props under one prop instead of spreading them on each component, mainly because of the following reasons:

  • we are already specifying all styles props under one prop - stylesProps
  • we would avoid props explosion
  • all system props would be easily discoverable

Copy link
Member

Choose a reason for hiding this comment

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

systemProps for consistency?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking more of a prop like styles, or css (css will conflict with emotion's css), but even systemProps sounds better :)

Copy link
Member

Choose a reason for hiding this comment

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

Let's get some other feedback before changing it.

Copy link
Member

@oliviertassinari oliviertassinari Sep 30, 2020

Choose a reason for hiding this comment

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

Should we have a 📊 on Twitter about the best API for the system? styled-system pushes for flattening; theme-ui.com pushes for isolation under one prop, well they have props too. Both have the same author.

A benchmark: https://trello.com/c/IUve1J6o/1577-system-core-component

Copy link
Member

@eps1lon eps1lon Oct 5, 2020

Choose a reason for hiding this comment

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

and well known

We need to be careful with that statement and consider audiences. A very large portion have a backend background. So far I've only heard of it in the context of Theme-UI.

Copy link
Member

Choose a reason for hiding this comment

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

So system > sx > css?

Copy link
Member

Choose a reason for hiding this comment

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

Regarding the flatten vs prop tradeoff. Any thoughts on it? The summarized version:

  • Box component: subset of CSS, flattened system props + superset of CSS, system prop
  • Most core components: superset of CSS, system prop only
  • Some core components that are responsible for accessing design tokens or doing layout have flattened system prop: Grid, Stack, Typography (e.g. fontWeight).

Copy link
Member Author

Choose a reason for hiding this comment

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

So system > sx > css?

Yep, and I am saying system in case if we are going to use it as a simply collection of system props, if we are going to treat is as a superset of CSS, then I would rather use a prop like styles or sx for it... In my opinion there is a big difference between these two use-cases

Regarding the flatten vs prop tradeoff. Any thoughts on it? The summarized version:

Box component: subset of CSS, flattened system props + superset of CSS, system prop

Agree, again if we are using the system props as superset of CSS I am revoking the system prop as a name, as it is not system anymore is more styles/css. 😄

Most core components: superset of CSS, system prop only

Agree 👍

Some core components that are responsible for accessing design tokens or doing layout have flattened system prop: Grid, Stack, Typography (e.g. fontWeight).

These should basically be the same as Box then, both flattened system prop + sx or styles. If that is the case I agree, and we should make sure we document all these components under the same section, so it would make sense to people why some components have them flattened and other don't...

Copy link
Member

Choose a reason for hiding this comment

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

Yep, and I am saying system in case if we are going to use it as a simply collection of system props, if we are going to treat is as a superset of CSS

From my perspective, we should go with the superset of CSS for the standalone property. We would gain an improved version of the CSS prop without the limitations of the Box. I can't think of any real downside.

@@ -31,6 +31,7 @@ export default function ContinuousSlider() {
</Grid>
<Grid item xs>
<Slider
system={{ color: 'secondary.main' }}
Copy link
Member Author

Choose a reason for hiding this comment

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

Changes will be reverted before merging

@mnajdova mnajdova marked this pull request as ready for review September 30, 2020 13:55
/**
* Common system props.
*/
system: PropTypes.object,
Copy link
Member

Choose a reason for hiding this comment

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

systemProps for consistency?

packages/material-ui-lab/src/SliderStyled/SliderStyled.js Outdated Show resolved Hide resolved
Copy link
Member

@eps1lon eps1lon left a comment

Choose a reason for hiding this comment

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

Forgot to submit

packages/material-ui-lab/src/SliderStyled/SliderStyled.js Outdated Show resolved Hide resolved
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 2, 2020
@oliviertassinari oliviertassinari added new feature New feature or request package: system Specific to @mui/system labels Oct 3, 2020
@oliviertassinari
Copy link
Member

On a related note, we might want to reimplement the system, maybe from scratch. There are a couple of elements to taken into accounts:

  • The existing issues.
  • I'm not sure about the performance. We have a benchmark, styled-system is x2 faster since the introduced the helper. As far as I know, the system is in the hot path but not contributing to a significant part of the rendering-time (to be confirmed). However, it's architectured to loop through each transformation function, one after the other. We could inverse it, to loop through each style property.

@mnajdova
Copy link
Member Author

Closing in favor of #23205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature New feature or request package: system Specific to @mui/system PR: out-of-date The pull request has merge conflicts and can't be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants