-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Box] Add sx prop #23053
Merged
Merged
[Box] Add sx prop #23053
Changes from 71 commits
Commits
Show all changes
74 commits
Select commit
Hold shift + click to select a range
c2d31cc
add emotion peer dependencies
mnajdova 5ae933f
fixed types & tests
mnajdova 18b0668
prettier
mnajdova f0ef95c
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova c7bebb8
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova 92b2d6e
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova 13da531
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova cf5d9a5
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova b8d1291
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova a9d8690
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova 74dc451
wip
mnajdova 688d13a
fixed typo
mnajdova 497830a
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova d50ea1e
Merge branch 'next' of https://github.com/mui-org/material-ui into next
mnajdova a1da207
added cross-env
mnajdova 6ff31f9
yarn lock
mnajdova 9fd7f7b
version
mnajdova e561135
Merge branch 'feat/benchmark-window-fix' into feat/update-box-to-use-…
mnajdova 2a71a6e
fixes
mnajdova 77d6017
prettier
mnajdova a3beed3
removed cross-env dependency
mnajdova 0b2d503
removed unused theme
mnajdova eddfa14
reversed style fn
mnajdova 83e0ea2
sx wip
mnajdova ff2d4c3
Updated box filterProps
mnajdova f7a74e9
prettier
mnajdova bc55cdb
Merge remote-tracking branch 'origin/feat/update-box-to-use-emotion' …
mnajdova 72893a9
merge conflicts
mnajdova d596058
cleanup
mnajdova 94c905d
Update docs/src/pages/components/slider-styled/ContinuousSlider.js
mnajdova f179fb9
Update docs/src/pages/components/slider-styled/ContinuousSlider.tsx
mnajdova 0373182
updated scenarios to be in the correct benchmark
mnajdova 6021478
cleaned up benchmark scenarios
mnajdova 5a70cf2
Merge branch 'feat/box-sx-prop' of https://github.com/mnajdova/materi…
mnajdova 92847d7
Merge branch 'next' into feat/box-sx-prop
mnajdova d438191
fixed typings, updated box page
mnajdova 7bab4bd
moved styleFunction to Box
mnajdova d966402
Update docs/src/pages/components/box/box.md
mnajdova 76c0f7e
Update packages/material-ui-system/src/palette.js
mnajdova 448bc82
Update packages/material-ui/src/Box/Box.js
mnajdova a7b690d
Update docs/src/pages/components/box/box.md
mnajdova 59461b3
added support for functions for the values
mnajdova f6faf73
prettier
mnajdova c53c4bd
fixed sizing filterProps
mnajdova ed02098
support sx as function
mnajdova f1ae038
prettier
mnajdova d2756c7
implemented breakpoints, fixed types, removed theme function callback
mnajdova 0f64e53
added theme-ui benchmark + sx prop benchmark for the box
mnajdova b32dd5a
fixed custom breakpoints support
mnajdova 79af939
Update docs/src/pages/components/box/box.md
mnajdova 64174a6
added theme-ui div scenario benchmark
mnajdova 70c1d51
Merge branch 'feat/box-sx-prop' of https://github.com/mnajdova/materi…
mnajdova 502733e
improved examples, added chakra-ui box & added results in readme
mnajdova 49641ac
added tests, fixes
mnajdova 15b118b
breakpoints more tests and fixes
mnajdova b386b29
improved breakpoints checks
mnajdova e200326
added more examples
mnajdova e12c35f
Added Box examples
mnajdova d32da87
temporarly removed dependency
mnajdova 2d4c5c9
Merge branch 'next' into feat/box-sx-prop
mnajdova 80682d1
reverted yarn.lock changes
mnajdova 6533c27
reverted benchmark changes
mnajdova 5df2f8c
Merge branch 'next' into feat/box-sx-prop
mnajdova 3767add
Update benchmark/browser/README.md
mnajdova dce99bc
reverted some changes
mnajdova 9671da1
Merge branch 'feat/box-sx-prop' of https://github.com/mnajdova/materi…
mnajdova b0cc366
fixed lint & tests
mnajdova 0b1ecd5
Merge branch 'next' into feat/box-sx-prop
mnajdova 9e3ad18
fixed breakpoints merging
mnajdova 2e557d4
prettier
mnajdova f00fd05
lint
mnajdova 43b629d
Update benchmark/browser/scenarios/sx-prop-box-material-ui/index.js
mnajdova 0d57b2d
Update benchmark/browser/scripts/benchmark.js
mnajdova 861d4f6
removed render function code snippet in favor of example
mnajdova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
benchmark/browser/scenarios/sx-prop-box-material-ui/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as React from 'react'; | ||
import Box from '@material-ui/core/Box'; | ||
|
||
export default function BasicStyledComponents() { | ||
mnajdova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return ( | ||
<React.Fragment> | ||
{new Array(1000).fill().map(() => ( | ||
<Box | ||
sx={{ | ||
width: 200, | ||
height: 200, | ||
backgroundColor: [undefined, 'primary.light', 'primary.main', 'primary.dark'], | ||
borderWidth: '3px', | ||
borderColor: 'white', | ||
borderStyle: [undefined, 'dashed', 'solid', 'dotted'], | ||
':hover': { | ||
backgroundColor: (theme) => theme.palette.secondary.dark, | ||
}, | ||
}} | ||
> | ||
material-ui | ||
</Box> | ||
))} | ||
</React.Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Box from '@material-ui/core/Box'; | ||
|
||
export default function BoxClone() { | ||
return ( | ||
<Box border="1px dashed grey" clone> | ||
<Button>Save</Button> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Box from '@material-ui/core/Box'; | ||
|
||
export default function BoxClone() { | ||
return ( | ||
<Box border="1px dashed grey" clone> | ||
<Button>Save</Button> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import Box from '@material-ui/core/Box'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
export default function BoxComponent() { | ||
return ( | ||
<Box component="span" p={2} border="1px dashed grey"> | ||
<Button>Save</Button> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import Box from '@material-ui/core/Box'; | ||
import Button from '@material-ui/core/Button'; | ||
|
||
export default function BoxComponent() { | ||
return ( | ||
<Box component="span" p={2} border="1px dashed grey"> | ||
<Button>Save</Button> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Box from '@material-ui/core/Box'; | ||
|
||
export default function BoxClone() { | ||
return ( | ||
<Box border="1px dashed grey"> | ||
{(props) => <Button {...props}>Save</Button>} | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import * as React from 'react'; | ||
import Button from '@material-ui/core/Button'; | ||
import Box from '@material-ui/core/Box'; | ||
|
||
export default function BoxClone() { | ||
return ( | ||
<Box border="1px dashed grey"> | ||
{(props: { className: string }) => <Button {...props}>Save</Button>} | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as React from 'react'; | ||
import Box from '@material-ui/core/Box'; | ||
|
||
export default function BoxSx() { | ||
return ( | ||
<Box | ||
sx={{ | ||
width: 300, | ||
height: 300, | ||
bgcolor: 'primary.dark', | ||
':hover': { | ||
backgroundColor: 'primary.main', | ||
opacity: [0.9, 0.8, 0.7], | ||
}, | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as React from 'react'; | ||
import Box from '@material-ui/core/Box'; | ||
|
||
export default function BoxSx() { | ||
return ( | ||
<Box | ||
sx={{ | ||
width: 300, | ||
height: 300, | ||
bgcolor: 'primary.dark', | ||
':hover': { | ||
backgroundColor: 'primary.main', | ||
opacity: [0.9, 0.8, 0.7], | ||
}, | ||
}} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,9 @@ | ||
import * as React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { | ||
borders, | ||
compose, | ||
display, | ||
flexbox, | ||
grid, | ||
palette, | ||
positions, | ||
shadows, | ||
sizing, | ||
spacing, | ||
typography, | ||
css, | ||
} from '@material-ui/system'; | ||
import clsx from 'clsx'; | ||
import styleFunction from './styleFunction'; | ||
import styled from '../styles/experimentalStyled'; | ||
|
||
export const styleFunction = css( | ||
compose( | ||
borders, | ||
display, | ||
flexbox, | ||
grid, | ||
positions, | ||
palette, | ||
shadows, | ||
sizing, | ||
spacing, | ||
typography, | ||
), | ||
); | ||
|
||
function omit(input, fields) { | ||
const output = {}; | ||
|
||
|
@@ -71,7 +43,7 @@ const BoxRoot = React.forwardRef(function StyledComponent(props, ref) { | |
}); | ||
|
||
BoxRoot.propTypes = { | ||
children: PropTypes.node, | ||
children: PropTypes.oneOfType([PropTypes.node, PropTypes.func]), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we get this change moved into a different pull request? It solves #22982. I also think that it depends on #18496 (comment). |
||
className: PropTypes.string, | ||
clone: PropTypes.bool, | ||
component: PropTypes.elementType, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
export { default } from './Box'; | ||
export * from './Box'; | ||
export { default as styleFunction } from './styleFunction'; | ||
export * from './styleFunction'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default, styleFunction } from './Box'; | ||
export { default } from './Box'; | ||
export { default as styleFunction } from './styleFunction'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { BoxStyleFunction } from './Box'; | ||
|
||
declare const styleFunction: BoxStyleFunction; | ||
export default styleFunction; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should use a generic name to avoid having to come up with a good name 🤷♂️. It has been a common source of review in the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add
App
everywhere orScenario
if that's ok :)