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

[system] Allow values to use shorter string when the prop name is contained in the value #23635

Merged
merged 9 commits into from
Nov 24, 2020

Conversation

mnajdova
Copy link
Member

@mnajdova mnajdova commented Nov 20, 2020

Currently, the API for some of the system props looks awkward as you need to the type the prop name as part of the value.

For example:

<Box sx={{ fontWeight: 'fontWeightRegular', fontFamily: 'fontFamily'}} />

This PR proposes solution for this, so that the definition could look like:

<Box sx={{ fontWeight: 'regular', fontFamily: 'default'}} />

The implementation is done in the following manner. First, the value is looked upon as it was before. If there is no value found, we are trying to prepend the prop name to the value and look for that. If the value was default we are simply looking for the prop name.

This is currently done automatically for all system values. We may add a flag for it and use it whenever we think necessary, but I would say this is good default behavior.

Regarding the naming of the default as it is already a value for some CSS properties, like cursor we may try to think of a different name. However, for the properties we have so far in the system I don't think it will be an issue.

Closes #23192
Closes #17615

@mui-pr-bot
Copy link

mui-pr-bot commented Nov 20, 2020

@material-ui/system: parsed: +2.19% , gzip: +3.18%

Details of bundle changes

Generated by 🚫 dangerJS against 554aba0

@oliviertassinari oliviertassinari added breaking change new feature New feature or request package: system Specific to @mui/system labels Nov 20, 2020
@mnajdova mnajdova requested review from oliviertassinari and removed request for oliviertassinari November 21, 2020 14:27
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 22, 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 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change new feature New feature or request package: system Specific to @mui/system
Projects
None yet
3 participants