Skip to content

[Box] Add back system props#24485

Merged
mnajdova merged 18 commits into
mui:nextfrom
mnajdova:feat/box-props
Jan 19, 2021
Merged

[Box] Add back system props#24485
mnajdova merged 18 commits into
mui:nextfrom
mnajdova:feat/box-props

Conversation

@mnajdova

@mnajdova mnajdova commented Jan 18, 2021

Copy link
Copy Markdown
Member

This PR adds back the system props in the Box component. However ,the implementation is a bit different than the previous one. For it to work, I am just extending the value of the sx prop, by adding all system props at the start of the sx object. This means that the value of the sx prop will override these props consistently, which is what we want I believe.

TODO:

  • Update perf benchmarks
  • Add tests

@mui-pr-bot

mui-pr-bot commented Jan 18, 2021

Copy link
Copy Markdown

@material-ui/core: parsed: +0.08% , gzip: +0.10%
@material-ui/system: parsed: +3.26% , gzip: +3.47%

Details of bundle changes

Generated by 🚫 dangerJS against 5f9a509

@mnajdova

mnajdova commented Jan 18, 2021

Copy link
Copy Markdown
Member Author

@mnajdova
mnajdova marked this pull request as ready for review January 18, 2021 14:31
@mnajdova

Copy link
Copy Markdown
Member Author

After the PR is merged, I'll add more benchmarks for the system props too.

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

Will we use the same approach to implement the props on the Typography or Grid component?

@mnajdova

Copy link
Copy Markdown
Member Author

Will we use the same approach to implement the props on the Typography or Grid component?

That's the plan, that's why I've added the extendSxProp utility, it should be pretty much straight forward to add it on any component we may need in the future.

Comment thread packages/material-ui-system/src/styleFunctionSx/extendSxProp.js Outdated
Comment thread packages/material-ui/src/Box/Box.d.ts Outdated
@oliviertassinari oliviertassinari added the component: Box The React component. label Jan 18, 2021
@eps1lon
eps1lon removed their request for review January 18, 2021 17:31
Comment thread packages/material-ui-system/src/styleFunctionSx/extendSxProp.js Outdated
Comment thread packages/material-ui-system/src/styleFunctionSx/extendSxProp.js Outdated
* @ignore - do not document.
*/
const Box = React.forwardRef(function Box(props, ref) {
const BoxInner = React.forwardRef((props, ref) => {

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 assume we will be able to remove this inner component later down the road.

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.

Hopefully yes. I had it inlined first, but I needed to add propTypes on it, that’s why I’ve extracted it..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: Box The React component.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants