Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[theme] Deprecate theme.mixins.gutters #22245

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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