Skip to content

Commit e1457a8

Browse files
[Avatar] Remove circular variant deprecation (mui#25543)
1 parent 0c7d8ce commit e1457a8

File tree

2 files changed

+3
-75
lines changed

2 files changed

+3
-75
lines changed

packages/material-ui/src/Avatar/Avatar.js

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as React from 'react';
22
import PropTypes from 'prop-types';
33
import clsx from 'clsx';
4-
import { chainPropTypes } from '@material-ui/utils';
54
import withStyles from '../styles/withStyles';
65
import Person from '../internal/svg-icons/Person';
76

@@ -173,24 +172,7 @@ Avatar.propTypes = {
173172
* Override or extend the styles applied to the component.
174173
* See [CSS API](#css) below for more details.
175174
*/
176-
classes: chainPropTypes(PropTypes.object, (props) => {
177-
const { classes } = props;
178-
if (classes == null) {
179-
return null;
180-
}
181-
182-
if (
183-
classes.circle != null &&
184-
// 2 classnames? one from withStyles the other must be custom
185-
classes.circle.split(' ').length > 1
186-
) {
187-
throw new Error(
188-
`Material-UI: The \`circle\` class was deprecated. Use \`circular\` instead.`,
189-
);
190-
}
191-
192-
return null;
193-
}),
175+
classes: PropTypes.object,
194176
/**
195177
* @ignore
196178
*/
@@ -221,17 +203,7 @@ Avatar.propTypes = {
221203
/**
222204
* The shape of the avatar.
223205
*/
224-
variant: chainPropTypes(PropTypes.oneOf(['circle', 'circular', 'rounded', 'square']), (props) => {
225-
const { variant } = props;
226-
227-
if (variant === 'circle') {
228-
throw new Error(
229-
'Material-UI: `variant="circle"` was deprecated. Use `variant="circular"` instead.',
230-
);
231-
}
232-
233-
return null;
234-
}),
206+
variant: PropTypes.oneOf(['circle', 'circular', 'rounded', 'square']),
235207
};
236208

237209
export default withStyles(styles, { name: 'MuiAvatar' })(Avatar);

packages/material-ui/src/Avatar/Avatar.test.js

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import * as React from 'react';
22
import { expect } from 'chai';
3-
import * as PropTypes from 'prop-types';
43
import { createClientRender, fireEvent } from 'test/utils/createClientRender';
54
import { getClasses } from '@material-ui/core/test-utils';
65
import createMount from 'test/utils/createMount';
7-
import { spy, stub } from 'sinon';
6+
import { spy } from 'sinon';
87
import CancelIcon from '../internal/svg-icons/Cancel';
98
import describeConformance from '../test-utils/describeConformance';
109
import Avatar from './Avatar';
@@ -196,47 +195,4 @@ describe('<Avatar />', () => {
196195
expect(avatar).to.have.class(classes.colorDefault);
197196
});
198197
});
199-
200-
describe('v5 deprecations', () => {
201-
beforeEach(() => {
202-
PropTypes.resetWarningCache();
203-
stub(console, 'error');
204-
});
205-
206-
afterEach(() => {
207-
console.error.restore();
208-
});
209-
210-
it('issues a warning for variant="circle"', () => {
211-
PropTypes.checkPropTypes(
212-
Avatar.Naked.propTypes,
213-
{
214-
variant: 'circle',
215-
},
216-
'props',
217-
'Avatar',
218-
);
219-
220-
expect(console.error.callCount).to.equal(1);
221-
expect(console.error.firstCall.args[0]).to.equal(
222-
'Warning: Failed props type: Material-UI: `variant="circle"` was deprecated. Use `variant="circular"` instead.',
223-
);
224-
});
225-
226-
it('issues a warning for the `circle` class', () => {
227-
PropTypes.checkPropTypes(
228-
Avatar.Naked.propTypes,
229-
{
230-
classes: { circle: 'mui-class my-class' },
231-
},
232-
'props',
233-
'Badge',
234-
);
235-
236-
expect(console.error.callCount).to.equal(1);
237-
expect(console.error.firstCall.args[0]).to.equal(
238-
'Warning: Failed props type: Material-UI: The `circle` class was deprecated. Use `circular` instead.',
239-
);
240-
});
241-
});
242198
});

0 commit comments

Comments
 (0)