Skip to content

Commit

Permalink
Multiple arity
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Feb 7, 2019
1 parent 90e7e91 commit 9604acf
Show file tree
Hide file tree
Showing 47 changed files with 149 additions and 104 deletions.
6 changes: 3 additions & 3 deletions .size-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = [
name: 'The size of the @material-ui/core modules',
webpack: true,
path: 'packages/material-ui/build/index.js',
limit: '92.3 KB',
limit: '92.4 KB',
},
{
name: 'The theme object',
Expand Down Expand Up @@ -59,14 +59,14 @@ module.exports = [
name: 'The size of the @material-ui/core/Button component',
webpack: true,
path: 'packages/material-ui/build/esm/Button/index.js',
limit: '24.5 KB',
limit: '24.6 KB',
},
{
// vs https://bundlephobia.com/result?p=react-modal
name: 'The size of the @material-ui/core/Modal component',
webpack: true,
path: 'packages/material-ui/build/esm/Modal/index.js',
limit: '24.0 KB',
limit: '24.1 KB',
},
{
// vs https://bundlephobia.com/result?p=react-popper
Expand Down
4 changes: 1 addition & 3 deletions docs/src/modules/components/AppSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ const styles = theme => ({
color: 'inherit',
},
inputInput: {
padding: `${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(
9,
)}px`,
padding: theme.spacing(1, 1, 1, 9),
},
});

Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/AppTableOfContents.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const styles = theme => ({
},
item: {
fontSize: 13,
padding: `${theme.spacing(0.5)}px 0`,
padding: theme.spacing(0.5, 0),
},
});

Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const styles = theme => ({
marginLeft: -theme.spacing(2),
marginRight: -theme.spacing(2),
[theme.breakpoints.up('sm')]: {
padding: `0 ${theme.spacing(1)}px`,
padding: theme.spacing(0, 1),
marginLeft: 0,
marginRight: 0,
},
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/HomeFooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const styles = theme => ({
root: {
maxWidth: theme.spacing(110),
margin: 'auto',
padding: `${theme.spacing(3)}px ${theme.spacing(2)}px`,
padding: theme.spacing(3, 2),
[theme.breakpoints.up('sm')]: {
padding: `${theme.spacing(6)}px ${theme.spacing(2)}px`,
padding: theme.spacing(6, 2),
},
},
list: {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/HomeSteps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ import Link from 'docs/src/modules/components/Link';
const styles = theme => ({
step: {
border: `12px solid ${theme.palette.background.paper}`,
padding: `${theme.spacing(3)}px ${theme.spacing(2)}px`,
padding: theme.spacing(3, 2),
borderRightWidth: 0,
borderLeftWidth: 0,
[theme.breakpoints.up('sm')]: {
padding: `${theme.spacing(5)}px ${theme.spacing(4)}px`,
padding: theme.spacing(5, 4),
},
[theme.breakpoints.up('md')]: {
borderRightWidth: 12,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/MarkdownDocs.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const styles = theme => ({
markdownElement: {
marginTop: theme.spacing(2),
marginBottom: theme.spacing(2),
padding: `0 ${theme.spacing(1)}px`,
padding: theme.spacing(0, 1),
},
});

Expand Down
6 changes: 2 additions & 4 deletions docs/src/modules/components/Tidelift.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import compose from 'recompose/compose';

const styles = theme => ({
root: {
padding: `${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(
2,
)}px`,
padding: theme.spacing(1, 1, 1, 2),
right: 0,
left: 0,
display: 'flex',
Expand All @@ -32,7 +30,7 @@ const styles = theme => ({
content: '""',
width: 20,
height: 20,
margin: `0 ${theme.spacing(1)}px 0 0`,
margin: theme.spacing(0, 1, 0, 0),
},
});

Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/customization/themes/WithTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function WithTheme(props) {
const styles = {
primaryText: {
backgroundColor: theme.palette.background.default,
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
color: primaryText,
},
primaryColor: {
backgroundColor: primaryColor,
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
color: theme.palette.common.white,
},
};
Expand Down
11 changes: 10 additions & 1 deletion docs/src/pages/customization/themes/themes.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,21 @@ theme.spacing(2) // = 4 * 2

```js
const theme = createMuiTheme({
spacing: x => `${0.25 * x}rem`, // (Bootstrap strategy)
spacing: factor => `${0.25 * factor}rem`, // (Bootstrap strategy)
});

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

#### Multiple arity

The `theme.spacing()` helper accepts up to 4 arguments.
You can use the arguments to reduce the boilerplate:
```diff
- padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
+ padding: theme.spacing(1, 2), // '8px 16px'
```

### Other variables

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ const useStyles = makeStyles(theme => ({
right: 0,
},
chip: {
margin: `${theme.spacing(0.5)}px ${2}px`,
margin: theme.spacing(0.5, 2),
},
inputRoot: {
flexWrap: 'wrap',
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/autocomplete/IntegrationDownshift.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const styles = theme => ({
right: 0,
},
chip: {
margin: `${theme.spacing(0.5)}px ${2}px`,
margin: theme.spacing(0.5, 2),
},
inputRoot: {
flexWrap: 'wrap',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const useStyles = makeStyles(theme => ({
overflow: 'hidden',
},
chip: {
margin: `${theme.spacing(0.5)}px ${2}px`,
margin: theme.spacing(0.5, 2),
},
chipFocused: {
backgroundColor: emphasize(
Expand All @@ -79,7 +79,7 @@ const useStyles = makeStyles(theme => ({
),
},
noOptionsMessage: {
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
},
singleValue: {
fontSize: 16,
Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/demos/autocomplete/IntegrationReactSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const styles = theme => ({
overflow: 'hidden',
},
chip: {
margin: `${theme.spacing(0.5)}px ${2}px`,
margin: theme.spacing(0.5, 2),
},
chipFocused: {
backgroundColor: emphasize(
Expand All @@ -80,7 +80,7 @@ const styles = theme => ({
),
},
noOptionsMessage: {
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
},
singleValue: {
fontSize: 16,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/badges/SimpleBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const styles = theme => ({
margin: theme.spacing(2),
},
padding: {
padding: `0 ${theme.spacing(2)}px`,
padding: theme.spacing(0, 2),
},
});

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/breadcrumbs/CollapsedBreadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const styles = theme => ({
flexWrap: 'wrap',
},
paper: {
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
},
});

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/breadcrumbs/CustomSeparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const styles = theme => ({
flexWrap: 'wrap',
},
paper: {
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
},
});

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/breadcrumbs/IconBreadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import GrainIcon from '@material-ui/icons/Grain';

const styles = theme => ({
root: {
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
},
link: {
display: 'flex',
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/breadcrumbs/SimpleBreadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const styles = theme => ({
flexWrap: 'wrap',
},
paper: {
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
},
});

Expand Down
4 changes: 2 additions & 2 deletions docs/src/pages/demos/dividers/MiddleDividers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const styles = theme => ({
marginRight: theme.spacing(1),
},
section1: {
margin: `${theme.spacing(3)}px ${theme.spacing(2)}px`,
margin: theme.spacing(3, 2),
},
section2: {
margin: theme.spacing(2),
},
section3: {
margin: `${theme.spacing(6)}px ${theme.spacing(2)}px ${theme.spacing(2)}px`,
margin: theme.spacing(6, 2, 2),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const styles = theme => ({
},
helper: {
borderLeft: `2px solid ${theme.palette.divider}`,
padding: `${theme.spacing(1)}px ${theme.spacing(2)}px`,
padding: theme.spacing(1, 2),
},
link: {
color: theme.palette.primary.main,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/lists/InteractiveList.hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const useStyles = makeStyles(theme => ({
backgroundColor: theme.palette.background.paper,
},
title: {
margin: `${theme.spacing(4)}px 0 ${theme.spacing(2)}px`,
margin: theme.spacing(4, 0, 2),
},
}));

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/lists/InteractiveList.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const styles = theme => ({
backgroundColor: theme.palette.background.paper,
},
title: {
margin: `${theme.spacing(4)}px 0 ${theme.spacing(2)}px`,
margin: theme.spacing(4, 0, 2),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const useStyles = makeStyles(theme => ({
margin: theme.spacing(3),
},
group: {
margin: `${theme.spacing(1)}px 0`,
margin: theme.spacing(1, 0),
},
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const styles = theme => ({
margin: theme.spacing(3),
},
group: {
margin: `${theme.spacing(1)}px 0`,
margin: theme.spacing(1, 0),
},
});

Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/discover-more/team/Team.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const members = [

const styles = theme => ({
details: {
margin: `${theme.spacing(1)}px ${theme.spacing(1)}px ${theme.spacing(1)}px 0`,
margin: theme.spacing(1, 1, 1, 0),
},
cover: {
width: theme.spacing(10),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const styles = theme => ({
heroContent: {
maxWidth: 600,
margin: '0 auto',
padding: `${theme.spacing(8)}px 0 ${theme.spacing(6)}px`,
padding: theme.spacing(8, 0, 6),
},
heroButtons: {
marginTop: theme.spacing(4),
Expand All @@ -43,7 +43,7 @@ const styles = theme => ({
},
},
cardGrid: {
padding: `${theme.spacing(8)}px 0`,
padding: theme.spacing(8, 0),
},
card: {
height: '100%',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const styles = theme => ({
marginBottom: theme.spacing(4),
},
mainFeaturedPostContent: {
padding: `${theme.spacing(6)}px`,
padding: theme.spacing(6),
[theme.breakpoints.up('md')]: {
paddingRight: 0,
},
Expand All @@ -63,7 +63,7 @@ const styles = theme => ({
width: 160,
},
markdown: {
padding: `${theme.spacing(3)}px 0`,
padding: theme.spacing(3, 0),
},
sidebarAboutBox: {
padding: theme.spacing(2),
Expand All @@ -75,7 +75,7 @@ const styles = theme => ({
footer: {
backgroundColor: theme.palette.background.paper,
marginTop: theme.spacing(8),
padding: `${theme.spacing(6)}px 0`,
padding: theme.spacing(6, 0),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const styles = theme => ({
},
},
stepper: {
padding: `${theme.spacing(3)}px 0 ${theme.spacing(5)}px`,
padding: theme.spacing(3, 0, 5),
},
buttons: {
display: 'flex',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const payments = [

const styles = theme => ({
listItem: {
padding: `${theme.spacing(1)}px 0`,
padding: theme.spacing(1, 0),
},
total: {
fontWeight: '700',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const styles = theme => ({
heroContent: {
maxWidth: 600,
margin: '0 auto',
padding: `${theme.spacing(8)}px 0 ${theme.spacing(6)}px`,
padding: theme.spacing(8, 0, 6),
},
cardHeader: {
backgroundColor: theme.palette.grey[200],
Expand All @@ -58,7 +58,7 @@ const styles = theme => ({
footer: {
marginTop: theme.spacing(8),
borderTop: `1px solid ${theme.palette.divider}`,
padding: `${theme.spacing(6)}px 0`,
padding: theme.spacing(6, 0),
},
});

Expand Down
Loading

0 comments on commit 9604acf

Please sign in to comment.