Skip to content

Commit

Permalink
deprecate theme.mixins.gutters()
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding committed Aug 16, 2020
1 parent 07943fb commit 8db2b29
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
30 changes: 14 additions & 16 deletions packages/material-ui/src/styles/createMixins.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
export default function createMixins(breakpoints, spacing, mixins) {
return {
gutters: (styles = {}) => {
// To deprecate in v4.1
// warning(
// false,
// [
// 'Material-UI: Theme.mixins.gutters() is deprecated.',
// 'You can use the source of the mixin directly:',
// `
// paddingLeft: theme.spacing(2),
// paddingRight: theme.spacing(2),
// [theme.breakpoints.up('sm')]: {
// paddingLeft: theme.spacing(3),
// paddingRight: theme.spacing(3),
// },
// `,
// ].join('\n'),
// );
console.warn(
[
'Material-UI: Theme.mixins.gutters() is deprecated.',
'You can use the source of the mixin directly:',
`
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
[theme.breakpoints.up('sm')]: {
paddingLeft: theme.spacing(3),
paddingRight: theme.spacing(3),
},
`,
].join('\n'),
);

return {
paddingLeft: spacing(2),
Expand Down
32 changes: 18 additions & 14 deletions packages/material-ui/src/styles/createMixins.test.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
import { expect } from 'chai';
import { consoleWarnMock } from 'test/utils/consoleErrorMock';
import createMixins from './createMixins';
import createMuiTheme from './createMuiTheme';

describe('createMixins', () => {
it('should be able to override the breakpoint', () => {
const theme = createMuiTheme();
const mixins = createMixins(theme.breakpoints, theme.spacing, {});
const mixins = createMixins(theme.breakpoints, theme.spacing, { test: { display: 'block' } });

const mixin = mixins.gutters({
display: 'flex',
[theme.breakpoints.up('sm')]: {
paddingLeft: 1,
},
expect(mixins.test).to.deep.equal({ display: 'block' });
});

describe('v5 deprecations', () => {
beforeEach(() => {
consoleWarnMock.spy();
});
expect(mixin).to.deep.equal({
'@media (min-width:600px)': {
paddingLeft: 1,
paddingRight: 24,
},
display: 'flex',
paddingLeft: 16,
paddingRight: 16,

afterEach(() => {
consoleWarnMock.reset();
});

it('issues a warning for theme.mixins.gutters', () => {
const theme = createMuiTheme();
theme.mixins.gutters();
expect(consoleWarnMock.callCount()).to.equal(1);
expect(consoleWarnMock.messages()[0]).to.include('theme.mixins.gutters() is deprecated.');
});
});
});

0 comments on commit 8db2b29

Please sign in to comment.