Skip to content

Commit

Permalink
Revert "[theme] Deprecate theme.mixins.gutters (#22245)"
Browse files Browse the repository at this point in the history
This reverts commit c5c6f5d.
  • Loading branch information
oliviertassinari committed Nov 24, 2020
1 parent 80fc767 commit fb1679c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 32 deletions.
30 changes: 16 additions & 14 deletions packages/material-ui/src/styles/createMixins.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
export default function createMixins(breakpoints, spacing, mixins) {
return {
gutters: (styles = {}) => {
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'),
);
// 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'),
// );

return {
paddingLeft: spacing(2),
Expand Down
32 changes: 14 additions & 18 deletions packages/material-ui/src/styles/createMixins.test.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,26 @@
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, { test: { display: 'block' } });
const mixins = createMixins(theme.breakpoints, theme.spacing, {});

expect(mixins.test).to.deep.equal({ display: 'block' });
});

describe('v5 deprecations', () => {
beforeEach(() => {
consoleWarnMock.spy();
const mixin = mixins.gutters({
display: 'flex',
[theme.breakpoints.up('sm')]: {
paddingLeft: 1,
},
});

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.');
expect(mixin).to.deep.equal({
'@media (min-width:600px)': {
paddingLeft: 1,
paddingRight: 24,
},
display: 'flex',
paddingLeft: 16,
paddingRight: 16,
});
});
});
6 changes: 6 additions & 0 deletions packages/material-ui/src/styles/createMuiTheme.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ 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 fb1679c

Please sign in to comment.