Skip to content

Commit a3ce82a

Browse files
authored
[Box] Add sx prop (#23053)
1 parent d0c2a16 commit a3ce82a

File tree

22 files changed

+526
-47
lines changed

22 files changed

+526
-47
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import * as React from 'react';
2+
import Box from '@material-ui/core/Box';
3+
4+
export default function BoxSxPropMaterialUI() {
5+
return (
6+
<React.Fragment>
7+
{new Array(1000).fill().map(() => (
8+
<Box
9+
sx={{
10+
width: 200,
11+
height: 200,
12+
backgroundColor: [undefined, 'primary.light', 'primary.main', 'primary.dark'],
13+
borderWidth: '3px',
14+
borderColor: 'white',
15+
borderStyle: [undefined, 'dashed', 'solid', 'dotted'],
16+
':hover': {
17+
backgroundColor: (theme) => theme.palette.secondary.dark,
18+
},
19+
}}
20+
>
21+
material-ui
22+
</Box>
23+
))}
24+
</React.Fragment>
25+
);
26+
}

benchmark/browser/scripts/benchmark.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ async function run() {
120120
await runMeasures(browser, 'Chakra-UI box component', './box-chakra-ui/index.js', 10);
121121
await runMeasures(browser, 'Theme-UI box sx prop', './sx-prop-box-theme-ui/index.js', 10);
122122
await runMeasures(browser, 'Theme-UI div sx prop', './sx-prop-div-theme-ui/index.js', 10);
123+
await runMeasures(browser, 'Material-UI box sx prop', './sx-prop-box-material-ui/index.js', 10);
123124
} finally {
124125
await Promise.all([browser.close(), server.close()]);
125126
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import Button from '@material-ui/core/Button';
3+
import Box from '@material-ui/core/Box';
4+
5+
export default function BoxClone() {
6+
return (
7+
<Box border="1px dashed grey" clone>
8+
<Button>Save</Button>
9+
</Box>
10+
);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import Button from '@material-ui/core/Button';
3+
import Box from '@material-ui/core/Box';
4+
5+
export default function BoxClone() {
6+
return (
7+
<Box border="1px dashed grey" clone>
8+
<Button>Save</Button>
9+
</Box>
10+
);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import Box from '@material-ui/core/Box';
3+
import Button from '@material-ui/core/Button';
4+
5+
export default function BoxComponent() {
6+
return (
7+
<Box component="span" p={2} border="1px dashed grey">
8+
<Button>Save</Button>
9+
</Box>
10+
);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import Box from '@material-ui/core/Box';
3+
import Button from '@material-ui/core/Button';
4+
5+
export default function BoxComponent() {
6+
return (
7+
<Box component="span" p={2} border="1px dashed grey">
8+
<Button>Save</Button>
9+
</Box>
10+
);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import Button from '@material-ui/core/Button';
3+
import Box from '@material-ui/core/Box';
4+
5+
export default function BoxClone() {
6+
return (
7+
<Box border="1px dashed grey">
8+
{(props) => <Button {...props}>Save</Button>}
9+
</Box>
10+
);
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from 'react';
2+
import Button from '@material-ui/core/Button';
3+
import Box from '@material-ui/core/Box';
4+
5+
export default function BoxClone() {
6+
return (
7+
<Box border="1px dashed grey">
8+
{(props: { className: string }) => <Button {...props}>Save</Button>}
9+
</Box>
10+
);
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as React from 'react';
2+
import Box from '@material-ui/core/Box';
3+
4+
export default function BoxSx() {
5+
return (
6+
<Box
7+
sx={{
8+
width: 300,
9+
height: 300,
10+
bgcolor: 'primary.dark',
11+
':hover': {
12+
backgroundColor: 'primary.main',
13+
opacity: [0.9, 0.8, 0.7],
14+
},
15+
}}
16+
/>
17+
);
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as React from 'react';
2+
import Box from '@material-ui/core/Box';
3+
4+
export default function BoxSx() {
5+
return (
6+
<Box
7+
sx={{
8+
width: 300,
9+
height: 300,
10+
bgcolor: 'primary.dark',
11+
':hover': {
12+
backgroundColor: 'primary.main',
13+
opacity: [0.9, 0.8, 0.7],
14+
},
15+
}}
16+
/>
17+
);
18+
}

0 commit comments

Comments
 (0)