Skip to content

Commit

Permalink
[theme] Deprecate theme.mixins.gutters (#22245)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwooding authored and oliviertassinari committed Nov 24, 2020
1 parent a4a6b3d commit a3df136
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 36 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.');
});
});
});
6 changes: 0 additions & 6 deletions packages/material-ui/src/styles/createMuiTheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ describe('createMuiTheme', () => {
expect(muiTheme.transitions.duration.shorter).to.not.equal(undefined);
});

it('should use the defined spacing for the gutters mixin', () => {
const spacing = 100;
const muiTheme = createMuiTheme({ spacing });
expect(muiTheme.mixins.gutters().paddingLeft).to.equal(spacing * 2);
});

describe('shadows', () => {
it('should provide the default array', () => {
const muiTheme = createMuiTheme();
Expand Down

0 comments on commit a3df136

Please sign in to comment.