Skip to content

Commit 3e685db

Browse files
Multiple arity
1 parent 90e7e91 commit 3e685db

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+148
-103
lines changed

.size-limit.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = [
2828
name: 'The size of the @material-ui/core modules',
2929
webpack: true,
3030
path: 'packages/material-ui/build/index.js',
31-
limit: '92.3 KB',
31+
limit: '92.4 KB',
3232
},
3333
{
3434
name: 'The theme object',
@@ -66,7 +66,7 @@ module.exports = [
6666
name: 'The size of the @material-ui/core/Modal component',
6767
webpack: true,
6868
path: 'packages/material-ui/build/esm/Modal/index.js',
69-
limit: '24.0 KB',
69+
limit: '24.1 KB',
7070
},
7171
{
7272
// vs https://bundlephobia.com/result?p=react-popper

docs/src/modules/components/AppSearch.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ const styles = theme => ({
153153
color: 'inherit',
154154
},
155155
inputInput: {
156-
padding: `${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(
157-
9,
158-
)}px`,
156+
padding: theme.spacing(1, 1, 1, 9),
159157
},
160158
});
161159

docs/src/modules/components/AppTableOfContents.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const styles = theme => ({
7171
},
7272
item: {
7373
fontSize: 13,
74-
padding: `${theme.spacing(0.5)}px 0`,
74+
padding: theme.spacing(0.5, 0),
7575
},
7676
});
7777

docs/src/modules/components/Demo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const styles = theme => ({
4343
marginLeft: -theme.spacing(2),
4444
marginRight: -theme.spacing(2),
4545
[theme.breakpoints.up('sm')]: {
46-
padding: `0 ${theme.spacing(1)}px`,
46+
padding: theme.spacing(0, 1),
4747
marginLeft: 0,
4848
marginRight: 0,
4949
},

docs/src/modules/components/HomeFooter.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ const styles = theme => ({
1111
root: {
1212
maxWidth: theme.spacing(110),
1313
margin: 'auto',
14-
padding: `${theme.spacing(3)}px ${theme.spacing(2)}px`,
14+
padding: theme.spacing(3, 2),
1515
[theme.breakpoints.up('sm')]: {
16-
padding: `${theme.spacing(6)}px ${theme.spacing(2)}px`,
16+
padding: theme.spacing(6, 2),
1717
},
1818
},
1919
list: {

docs/src/modules/components/HomeSteps.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import Link from 'docs/src/modules/components/Link';
1818
const styles = theme => ({
1919
step: {
2020
border: `12px solid ${theme.palette.background.paper}`,
21-
padding: `${theme.spacing(3)}px ${theme.spacing(2)}px`,
21+
padding: theme.spacing(3, 2),
2222
borderRightWidth: 0,
2323
borderLeftWidth: 0,
2424
[theme.breakpoints.up('sm')]: {
25-
padding: `${theme.spacing(5)}px ${theme.spacing(4)}px`,
25+
padding: theme.spacing(5, 4),
2626
},
2727
[theme.breakpoints.up('md')]: {
2828
borderRightWidth: 12,

docs/src/modules/components/MarkdownDocs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const styles = theme => ({
3434
markdownElement: {
3535
marginTop: theme.spacing(2),
3636
marginBottom: theme.spacing(2),
37-
padding: `0 ${theme.spacing(1)}px`,
37+
padding: theme.spacing(0, 1),
3838
},
3939
});
4040

docs/src/modules/components/Tidelift.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import compose from 'recompose/compose';
99

1010
const styles = theme => ({
1111
root: {
12-
padding: `${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(
13-
2,
14-
)}px`,
12+
padding: theme.spacing(1, 1, 1, 2),
1513
right: 0,
1614
left: 0,
1715
display: 'flex',
@@ -32,7 +30,7 @@ const styles = theme => ({
3230
content: '""',
3331
width: 20,
3432
height: 20,
35-
margin: `0 ${theme.spacing(1)}px 0 0`,
33+
margin: theme.spacing(0, 1, 0, 0),
3634
},
3735
});
3836

docs/src/pages/customization/themes/WithTheme.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ function WithTheme(props) {
1111
const styles = {
1212
primaryText: {
1313
backgroundColor: theme.palette.background.default,
14-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
14+
padding: theme.spacing(1, 2),
1515
color: primaryText,
1616
},
1717
primaryColor: {
1818
backgroundColor: primaryColor,
19-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
19+
padding: theme.spacing(1, 2),
2020
color: theme.palette.common.white,
2121
},
2222
};

docs/src/pages/customization/themes/themes.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,21 @@ theme.spacing(2) // = 4 * 2
319319

320320
```js
321321
const theme = createMuiTheme({
322-
spacing: x => `${0.25 * x}rem`, // (Bootstrap strategy)
322+
spacing: factor => `${0.25 * factor}rem`, // (Bootstrap strategy)
323323
});
324324

325325
theme.spacing(2) // = 0.5rem = 8px
326326
```
327327

328+
#### Multiple arity
329+
330+
The `theme.spacing()` helper accepts up to 4 arguments.
331+
You can use the arguments to reduce the boilerplate:
332+
```diff
333+
- padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
334+
+ padding: theme.spacing(1, 2), // '8px 16px'
335+
```
336+
328337
### Other variables
329338

330339
In addition to the palette, dark and light types, and typography, the theme normalizes implementation by providing many more default values, such as breakpoints, shadows, transitions, etc.

docs/src/pages/demos/autocomplete/IntegrationDownshift.hooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const useStyles = makeStyles(theme => ({
214214
right: 0,
215215
},
216216
chip: {
217-
margin: `${theme.spacing(0.5)}px ${2}px`,
217+
margin: theme.spacing(0.5, 2),
218218
},
219219
inputRoot: {
220220
flexWrap: 'wrap',

docs/src/pages/demos/autocomplete/IntegrationDownshift.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ const styles = theme => ({
229229
right: 0,
230230
},
231231
chip: {
232-
margin: `${theme.spacing(0.5)}px ${2}px`,
232+
margin: theme.spacing(0.5, 2),
233233
},
234234
inputRoot: {
235235
flexWrap: 'wrap',

docs/src/pages/demos/autocomplete/IntegrationReactSelect.hooks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ const useStyles = makeStyles(theme => ({
7070
overflow: 'hidden',
7171
},
7272
chip: {
73-
margin: `${theme.spacing(0.5)}px ${2}px`,
73+
margin: theme.spacing(0.5, 2),
7474
},
7575
chipFocused: {
7676
backgroundColor: emphasize(
@@ -79,7 +79,7 @@ const useStyles = makeStyles(theme => ({
7979
),
8080
},
8181
noOptionsMessage: {
82-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
82+
padding: theme.spacing(1, 2),
8383
},
8484
singleValue: {
8585
fontSize: 16,

docs/src/pages/demos/autocomplete/IntegrationReactSelect.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ const styles = theme => ({
7171
overflow: 'hidden',
7272
},
7373
chip: {
74-
margin: `${theme.spacing(0.5)}px ${2}px`,
74+
margin: theme.spacing(0.5, 2),
7575
},
7676
chipFocused: {
7777
backgroundColor: emphasize(
@@ -80,7 +80,7 @@ const styles = theme => ({
8080
),
8181
},
8282
noOptionsMessage: {
83-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
83+
padding: theme.spacing(1, 2),
8484
},
8585
singleValue: {
8686
fontSize: 16,

docs/src/pages/demos/badges/SimpleBadge.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const styles = theme => ({
1515
margin: theme.spacing(2),
1616
},
1717
padding: {
18-
padding: `0 ${theme.spacing(2)}px`,
18+
padding: theme.spacing(0, 2),
1919
},
2020
});
2121

docs/src/pages/demos/breadcrumbs/CollapsedBreadcrumbs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const styles = theme => ({
1414
flexWrap: 'wrap',
1515
},
1616
paper: {
17-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
17+
padding: theme.spacing(1, 2),
1818
},
1919
});
2020

docs/src/pages/demos/breadcrumbs/CustomSeparator.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const styles = theme => ({
1313
flexWrap: 'wrap',
1414
},
1515
paper: {
16-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
16+
padding: theme.spacing(1, 2),
1717
},
1818
});
1919

docs/src/pages/demos/breadcrumbs/IconBreadcrumbs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import GrainIcon from '@material-ui/icons/Grain';
1111

1212
const styles = theme => ({
1313
root: {
14-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
14+
padding: theme.spacing(1, 2),
1515
},
1616
link: {
1717
display: 'flex',

docs/src/pages/demos/breadcrumbs/SimpleBreadcrumbs.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const styles = theme => ({
1212
flexWrap: 'wrap',
1313
},
1414
paper: {
15-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
15+
padding: theme.spacing(1, 2),
1616
},
1717
});
1818

docs/src/pages/demos/dividers/MiddleDividers.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ const styles = theme => ({
1717
marginRight: theme.spacing(1),
1818
},
1919
section1: {
20-
margin: `${theme.spacing(3)}px ${theme.spacing(2)}px`,
20+
margin: theme.spacing(3, 2),
2121
},
2222
section2: {
2323
margin: theme.spacing(2),
2424
},
2525
section3: {
26-
margin: `${theme.spacing(6)}px ${theme.spacing(2)}px ${theme.spacing(2)}px`,
26+
margin: theme.spacing(6, 2, 2),
2727
},
2828
});
2929

docs/src/pages/demos/expansion-panels/DetailedExpansionPanel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const styles = theme => ({
3636
},
3737
helper: {
3838
borderLeft: `2px solid ${theme.palette.divider}`,
39-
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
39+
padding: theme.spacing(1, 2),
4040
},
4141
link: {
4242
color: theme.palette.primary.main,

docs/src/pages/demos/lists/InteractiveList.hooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const useStyles = makeStyles(theme => ({
2525
backgroundColor: theme.palette.background.paper,
2626
},
2727
title: {
28-
margin: `${theme.spacing(4)}px 0 ${theme.spacing(2)}px`,
28+
margin: theme.spacing(4, 0, 2),
2929
},
3030
}));
3131

docs/src/pages/demos/lists/InteractiveList.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const styles = theme => ({
2626
backgroundColor: theme.palette.background.paper,
2727
},
2828
title: {
29-
margin: `${theme.spacing(4)}px 0 ${theme.spacing(2)}px`,
29+
margin: theme.spacing(4, 0, 2),
3030
},
3131
});
3232

docs/src/pages/demos/selection-controls/RadioButtonsGroup.hooks.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const useStyles = makeStyles(theme => ({
1515
margin: theme.spacing(3),
1616
},
1717
group: {
18-
margin: `${theme.spacing(1)}px 0`,
18+
margin: theme.spacing(1, 0),
1919
},
2020
}));
2121

docs/src/pages/demos/selection-controls/RadioButtonsGroup.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const styles = theme => ({
1616
margin: theme.spacing(3),
1717
},
1818
group: {
19-
margin: `${theme.spacing(1)}px 0`,
19+
margin: theme.spacing(1, 0),
2020
},
2121
});
2222

docs/src/pages/discover-more/team/Team.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const members = [
8989

9090
const styles = theme => ({
9191
details: {
92-
margin: `${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(1)}px 0`,
92+
margin: theme.spacing(1, 1, 1, 0),
9393
},
9494
cover: {
9595
width: theme.spacing(10),

docs/src/pages/getting-started/page-layout-examples/album/Album.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const styles = theme => ({
2727
heroContent: {
2828
maxWidth: 600,
2929
margin: '0 auto',
30-
padding: `${theme.spacing(8)}px 0 ${theme.spacing(6)}px`,
30+
padding: theme.spacing(8, 0, 6),
3131
},
3232
heroButtons: {
3333
marginTop: theme.spacing(4),
@@ -43,7 +43,7 @@ const styles = theme => ({
4343
},
4444
},
4545
cardGrid: {
46-
padding: `${theme.spacing(8)}px 0`,
46+
padding: theme.spacing(8, 0),
4747
},
4848
card: {
4949
height: '100%',

docs/src/pages/getting-started/page-layout-examples/blog/Blog.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const styles = theme => ({
4545
marginBottom: theme.spacing(4),
4646
},
4747
mainFeaturedPostContent: {
48-
padding: `${theme.spacing(6)}px`,
48+
padding: theme.spacing(6),
4949
[theme.breakpoints.up('md')]: {
5050
paddingRight: 0,
5151
},
@@ -63,7 +63,7 @@ const styles = theme => ({
6363
width: 160,
6464
},
6565
markdown: {
66-
padding: `${theme.spacing(3)}px 0`,
66+
padding: theme.spacing(3, 0),
6767
},
6868
sidebarAboutBox: {
6969
padding: theme.spacing(2),
@@ -75,7 +75,7 @@ const styles = theme => ({
7575
footer: {
7676
backgroundColor: theme.palette.background.paper,
7777
marginTop: theme.spacing(8),
78-
padding: `${theme.spacing(6)}px 0`,
78+
padding: theme.spacing(6, 0),
7979
},
8080
});
8181

docs/src/pages/getting-started/page-layout-examples/checkout/Checkout.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const styles = theme => ({
3939
},
4040
},
4141
stepper: {
42-
padding: `${theme.spacing(3)}px 0 ${theme.spacing(5)}px`,
42+
padding: theme.spacing(3, 0, 5),
4343
},
4444
buttons: {
4545
display: 'flex',

docs/src/pages/getting-started/page-layout-examples/checkout/Review.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const payments = [
2424

2525
const styles = theme => ({
2626
listItem: {
27-
padding: `${theme.spacing(1)}px 0`,
27+
padding: theme.spacing(1, 0),
2828
},
2929
total: {
3030
fontWeight: '700',

docs/src/pages/getting-started/page-layout-examples/pricing/Pricing.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const styles = theme => ({
3939
heroContent: {
4040
maxWidth: 600,
4141
margin: '0 auto',
42-
padding: `${theme.spacing(8)}px 0 ${theme.spacing(6)}px`,
42+
padding: theme.spacing(8, 0, 6),
4343
},
4444
cardHeader: {
4545
backgroundColor: theme.palette.grey[200],
@@ -58,7 +58,7 @@ const styles = theme => ({
5858
footer: {
5959
marginTop: theme.spacing(8),
6060
borderTop: `1px solid ${theme.palette.divider}`,
61-
padding: `${theme.spacing(6)}px 0`,
61+
padding: theme.spacing(6, 0),
6262
},
6363
});
6464

docs/src/pages/getting-started/page-layout-examples/sign-in/SignIn.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const styles = theme => ({
3030
display: 'flex',
3131
flexDirection: 'column',
3232
alignItems: 'center',
33-
padding: `${theme.spacing(2)}px ${theme.spacing(3)}px ${theme.spacing(3)}px`,
33+
padding: theme.spacing(2, 3, 3),
3434
},
3535
avatar: {
3636
margin: theme.spacing(1),

0 commit comments

Comments
 (0)