Skip to content

Commit 8db2b29

Browse files
committed
deprecate theme.mixins.gutters()
1 parent 07943fb commit 8db2b29

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

packages/material-ui/src/styles/createMixins.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
11
export default function createMixins(breakpoints, spacing, mixins) {
22
return {
33
gutters: (styles = {}) => {
4-
// To deprecate in v4.1
5-
// warning(
6-
// false,
7-
// [
8-
// 'Material-UI: Theme.mixins.gutters() is deprecated.',
9-
// 'You can use the source of the mixin directly:',
10-
// `
11-
// paddingLeft: theme.spacing(2),
12-
// paddingRight: theme.spacing(2),
13-
// [theme.breakpoints.up('sm')]: {
14-
// paddingLeft: theme.spacing(3),
15-
// paddingRight: theme.spacing(3),
16-
// },
17-
// `,
18-
// ].join('\n'),
19-
// );
4+
console.warn(
5+
[
6+
'Material-UI: Theme.mixins.gutters() is deprecated.',
7+
'You can use the source of the mixin directly:',
8+
`
9+
paddingLeft: theme.spacing(2),
10+
paddingRight: theme.spacing(2),
11+
[theme.breakpoints.up('sm')]: {
12+
paddingLeft: theme.spacing(3),
13+
paddingRight: theme.spacing(3),
14+
},
15+
`,
16+
].join('\n'),
17+
);
2018

2119
return {
2220
paddingLeft: spacing(2),
Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
import { expect } from 'chai';
2+
import { consoleWarnMock } from 'test/utils/consoleErrorMock';
23
import createMixins from './createMixins';
34
import createMuiTheme from './createMuiTheme';
45

56
describe('createMixins', () => {
67
it('should be able to override the breakpoint', () => {
78
const theme = createMuiTheme();
8-
const mixins = createMixins(theme.breakpoints, theme.spacing, {});
9+
const mixins = createMixins(theme.breakpoints, theme.spacing, { test: { display: 'block' } });
910

10-
const mixin = mixins.gutters({
11-
display: 'flex',
12-
[theme.breakpoints.up('sm')]: {
13-
paddingLeft: 1,
14-
},
11+
expect(mixins.test).to.deep.equal({ display: 'block' });
12+
});
13+
14+
describe('v5 deprecations', () => {
15+
beforeEach(() => {
16+
consoleWarnMock.spy();
1517
});
16-
expect(mixin).to.deep.equal({
17-
'@media (min-width:600px)': {
18-
paddingLeft: 1,
19-
paddingRight: 24,
20-
},
21-
display: 'flex',
22-
paddingLeft: 16,
23-
paddingRight: 16,
18+
19+
afterEach(() => {
20+
consoleWarnMock.reset();
21+
});
22+
23+
it('issues a warning for theme.mixins.gutters', () => {
24+
const theme = createMuiTheme();
25+
theme.mixins.gutters();
26+
expect(consoleWarnMock.callCount()).to.equal(1);
27+
expect(consoleWarnMock.messages()[0]).to.include('theme.mixins.gutters() is deprecated.');
2428
});
2529
});
2630
});

0 commit comments

Comments
 (0)