diff --git a/docs/pages/api-docs/icon.md b/docs/pages/api-docs/icon.md index 0a595c2b4c0969..30d7f836af3f6a 100644 --- a/docs/pages/api-docs/icon.md +++ b/docs/pages/api-docs/icon.md @@ -32,7 +32,7 @@ The `MuiIcon` name can be used for providing [default props](/customization/glob | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | color | 'inherit'
| 'primary'
| 'secondary'
| 'action'
| 'error'
| 'disabled'
| 'inherit' | The color of the component. It supports those theme colors that make sense for this component. | | component | elementType | 'span' | The component used for the root node. Either a string to use a HTML element or a component. | -| fontSize | 'inherit'
| 'default'
| 'small'
| 'large'
| 'default' | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. | +| fontSize | 'inherit'
| 'large'
| 'medium'
| 'small'
| 'medium' | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. | The `ref` is forwarded to the root element. diff --git a/docs/pages/api-docs/svg-icon.md b/docs/pages/api-docs/svg-icon.md index fe77312427e7d1..6536456496d9cf 100644 --- a/docs/pages/api-docs/svg-icon.md +++ b/docs/pages/api-docs/svg-icon.md @@ -32,7 +32,7 @@ The `MuiSvgIcon` name can be used for providing [default props](/customization/g | classes | object | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. | | color | 'action'
| 'disabled'
| 'error'
| 'inherit'
| 'primary'
| 'secondary'
| 'inherit' | The color of the component. It supports those theme colors that make sense for this component. You can use the `htmlColor` prop to apply a color attribute to the SVG element. | | component | elementType | 'svg' | The component used for the root node. Either a string to use a HTML element or a component. | -| fontSize | 'default'
| 'inherit'
| 'large'
| 'small'
| 'default' | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. | +| fontSize | 'inherit'
| 'large'
| 'medium'
| 'small'
| 'medium' | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. | | htmlColor | string | | Applies a color attribute to the SVG element. | | shapeRendering | string | | The shape-rendering attribute. The behavior of the different options is described on the [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering). If you are having issues with blurry icons you should investigate this property. | | titleAccess | string | | Provides a human-readable title for the element that contains it. https://www.w3.org/TR/SVG-access/#Equivalent | diff --git a/packages/material-ui/src/Icon/Icon.d.ts b/packages/material-ui/src/Icon/Icon.d.ts index b2d176b41014b2..a0c4c9443141ff 100644 --- a/packages/material-ui/src/Icon/Icon.d.ts +++ b/packages/material-ui/src/Icon/Icon.d.ts @@ -5,7 +5,7 @@ import { OverridableComponent, OverrideProps } from '../OverridableComponent'; export interface IconTypeMap

{ props: P & { color?: PropTypes.Color | 'action' | 'disabled' | 'error'; - fontSize?: 'inherit' | 'default' | 'small' | 'large'; + fontSize?: 'inherit' | 'large' | 'medium' | 'small'; }; defaultComponent: D; classKey: IconClassKey; diff --git a/packages/material-ui/src/Icon/Icon.js b/packages/material-ui/src/Icon/Icon.js index c2a91c420d7c35..c2fef53a6ceb00 100644 --- a/packages/material-ui/src/Icon/Icon.js +++ b/packages/material-ui/src/Icon/Icon.js @@ -1,8 +1,9 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import withStyles from '../styles/withStyles'; +import { chainPropTypes } from '@material-ui/utils'; import capitalize from '../utils/capitalize'; +import withStyles from '../styles/withStyles'; export const styles = (theme) => ({ /* Styles applied to the root element. */ @@ -56,7 +57,7 @@ const Icon = React.forwardRef(function Icon(props, ref) { className, color = 'inherit', component: Component = 'span', - fontSize = 'default', + fontSize = 'medium', ...other } = props; @@ -67,7 +68,7 @@ const Icon = React.forwardRef(function Icon(props, ref) { classes.root, { [classes[`color${capitalize(color)}`]]: color !== 'inherit', - [classes[`fontSize${capitalize(fontSize)}`]]: fontSize !== 'default', + [classes[`fontSize${capitalize(fontSize)}`]]: fontSize !== 'medium', }, className, )} @@ -104,7 +105,17 @@ Icon.propTypes = { /** * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. */ - fontSize: PropTypes.oneOf(['inherit', 'default', 'small', 'large']), + fontSize: chainPropTypes(PropTypes.oneOf(['inherit', 'large', 'medium', 'small']), (props) => { + const { fontSize } = props; + + if (fontSize === 'default') { + throw new Error( + 'Material-UI: `fontSize="default"` is deprecated. Use `fontSize="medium"` instead.', + ); + } + + return null; + }), }; Icon.muiName = 'Icon'; diff --git a/packages/material-ui/src/Radio/Radio.js b/packages/material-ui/src/Radio/Radio.js index d4c855d7f8b080..c403b8976903d8 100644 --- a/packages/material-ui/src/Radio/Radio.js +++ b/packages/material-ui/src/Radio/Radio.js @@ -85,9 +85,9 @@ const Radio = React.forwardRef(function Radio(props, ref) { { /** * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. */ - fontSize?: 'inherit' | 'default' | 'small' | 'large'; + fontSize?: 'inherit' | 'large' | 'medium' | 'small'; /** * Applies a color attribute to the SVG element. */ diff --git a/packages/material-ui/src/SvgIcon/SvgIcon.js b/packages/material-ui/src/SvgIcon/SvgIcon.js index d3e264963cc53a..e9ab0e228f550c 100644 --- a/packages/material-ui/src/SvgIcon/SvgIcon.js +++ b/packages/material-ui/src/SvgIcon/SvgIcon.js @@ -1,8 +1,9 @@ import * as React from 'react'; import PropTypes from 'prop-types'; import clsx from 'clsx'; -import withStyles from '../styles/withStyles'; +import { chainPropTypes } from '@material-ui/utils'; import capitalize from '../utils/capitalize'; +import withStyles from '../styles/withStyles'; export const styles = (theme) => ({ /* Styles applied to the root element. */ @@ -59,7 +60,7 @@ const SvgIcon = React.forwardRef(function SvgIcon(props, ref) { className, color = 'inherit', component: Component = 'svg', - fontSize = 'default', + fontSize = 'medium', htmlColor, titleAccess, viewBox = '0 0 24 24', @@ -72,7 +73,7 @@ const SvgIcon = React.forwardRef(function SvgIcon(props, ref) { classes.root, { [classes[`color${capitalize(color)}`]]: color !== 'inherit', - [classes[`fontSize${capitalize(fontSize)}`]]: fontSize !== 'default', + [classes[`fontSize${capitalize(fontSize)}`]]: fontSize !== 'medium', }, className, )} @@ -121,7 +122,18 @@ SvgIcon.propTypes = { /** * The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. */ - fontSize: PropTypes.oneOf(['default', 'inherit', 'large', 'small']), + fontSize: chainPropTypes(PropTypes.oneOf(['inherit', 'large', 'medium', 'small']), (props) => { + const { fontSize } = props; + + if (variant === 'default') { + throw new Error( + 'Material-UI: `variant="default"` is deprecated. Use `variant="medium"` instead.', + ); + } + + return null; + }), + /** * Applies a color attribute to the SVG element. */