Skip to content

Commit 6abf72a

Browse files
[Fab] Deprecate variant="round" (#24080)
1 parent a0f2b0f commit 6abf72a

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

docs/pages/api-docs/fab.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The `MuiFab` name can be used for providing [default props](/customization/globa
3737
| <span class="prop-name">disableRipple</span> | <span class="prop-type">bool</span> | | If `true`, the ripple effect will be disabled. |
3838
| <span class="prop-name">href</span> | <span class="prop-type">string</span> | | The URL to link to when the button is clicked. If defined, an `a` element will be used as the root node. |
3939
| <span class="prop-name">size</span> | <span class="prop-type">'large'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'small'</span> | <span class="prop-default">'large'</span> | The size of the button. `small` is equivalent to the dense button styling. |
40-
| <span class="prop-name">variant</span> | <span class="prop-type">'extended'<br>&#124;&nbsp;'round'</span> | <span class="prop-default">'round'</span> | The variant to use. |
40+
| <span class="prop-name">variant</span> | <span class="prop-type">'extended'<br>&#124;&nbsp;'circular'<br>&#124;&nbsp;'round'</span> | <span class="prop-default">'circular'</span> | The variant to use. 'round' is deprecated, use 'circular' instead. |
4141

4242
The `ref` is forwarded to the root element.
4343

framer/Material-UI.framerfx/code/Fab.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Props {
1010
disabled?: boolean;
1111
href?: string;
1212
size?: 'small' | 'medium' | 'large';
13-
variant?: 'round' | 'extended';
13+
variant?: 'circular' | 'extended';
1414
icon?: string;
1515
iconTheme?: 'Filled' | 'Outlined' | 'Rounded' | 'TwoTone' | 'Sharp';
1616
label?: string;
@@ -22,7 +22,7 @@ const defaultProps: Props = {
2222
color: 'default',
2323
disabled: false,
2424
size: 'large',
25-
variant: 'round',
25+
variant: 'circular',
2626
icon: 'add',
2727
iconTheme: 'Filled',
2828
label: 'extended',
@@ -70,7 +70,7 @@ addPropertyControls(Fab, {
7070
variant: {
7171
type: ControlType.Enum,
7272
title: 'Variant',
73-
options: ['round', 'extended'],
73+
options: ['circular', 'extended'],
7474
},
7575
icon: {
7676
type: ControlType.String,

packages/material-ui/src/Fab/Fab.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export type FabTypeMap<P = {}, D extends React.ElementType = 'button'> = ExtendB
3636
size?: 'small' | 'medium' | 'large';
3737
/**
3838
* The variant to use.
39+
* 'round' is deprecated, use 'circular' instead.
3940
*/
40-
variant?: 'round' | 'extended';
41+
variant?: 'circular' | 'extended' | 'round';
4142
};
4243
defaultComponent: D;
4344
classKey: FabClassKey;

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as React from 'react';
22
import PropTypes from 'prop-types';
33
import clsx from 'clsx';
4+
import { chainPropTypes } from '@material-ui/utils';
45
import withStyles from '../styles/withStyles';
56
import ButtonBase from '../ButtonBase';
67
import capitalize from '../utils/capitalize';
@@ -130,7 +131,7 @@ const Fab = React.forwardRef(function Fab(props, ref) {
130131
disableFocusRipple = false,
131132
focusVisibleClassName,
132133
size = 'large',
133-
variant = 'round',
134+
variant = 'circular',
134135
...other
135136
} = props;
136137

@@ -215,8 +216,17 @@ Fab.propTypes = {
215216
size: PropTypes.oneOf(['large', 'medium', 'small']),
216217
/**
217218
* The variant to use.
219+
* 'round' is deprecated, use 'circular' instead.
218220
*/
219-
variant: PropTypes.oneOf(['extended', 'round']),
221+
variant: chainPropTypes(PropTypes.oneOf(['extended', 'circular', 'round']), (props) => {
222+
if (props.variant === 'round') {
223+
throw new Error(
224+
'Material-UI: variant="round" was renamed variant="circular" for consistency.',
225+
);
226+
}
227+
228+
return null;
229+
}),
220230
};
221231

222232
export default withStyles(styles, { name: 'MuiFab' })(Fab);

0 commit comments

Comments
 (0)