Skip to content

Commit 7263762

Browse files
sebastian review
1 parent 9fee76c commit 7263762

File tree

6 files changed

+30
-6
lines changed

6 files changed

+30
-6
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface IconProps
55
extends StandardProps<React.HTMLAttributes<HTMLSpanElement>, IconClassKey> {
66
color?: PropTypes.Color | 'action' | 'disabled' | 'error';
77
component?: React.ElementType<IconProps>;
8-
fontSize?: 'inherit' | 'medium' | 'small' | 'large';
8+
fontSize?: 'inherit' | 'medium' | 'small' | 'large' | 'default';
99
}
1010

1111
export type IconClassKey =

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 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 { capitalize } from '../utils/helpers';
67

@@ -98,7 +99,18 @@ Icon.propTypes = {
9899
/**
99100
* The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.
100101
*/
101-
fontSize: PropTypes.oneOf(['inherit', 'medium', 'small', 'large']),
102+
fontSize: chainPropTypes(
103+
PropTypes.oneOf(['inherit', 'medium', 'small', 'large', 'default']),
104+
props => {
105+
if (props.fontSize === 'default') {
106+
return new Error(
107+
`The prop \`fontSize="default"\` of the \`Icon\` component is deprecated. Use fontSize="medium" instead.`,
108+
);
109+
}
110+
111+
return null;
112+
},
113+
),
102114
};
103115

104116
Icon.defaultProps = {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export interface SvgIconProps
55
extends StandardProps<React.SVGProps<SVGSVGElement>, SvgIconClassKey> {
66
color?: PropTypes.Color | 'action' | 'disabled' | 'error';
77
component?: React.ElementType<SvgIconProps>;
8-
fontSize?: 'inherit' | 'medium' | 'small' | 'large';
8+
fontSize?: 'inherit' | 'medium' | 'small' | 'large' | 'default';
99
htmlColor?: string;
1010
shapeRendering?: string;
1111
titleAccess?: string;

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 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 { capitalize } from '../utils/helpers';
67

@@ -117,7 +118,18 @@ SvgIcon.propTypes = {
117118
/**
118119
* The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size.
119120
*/
120-
fontSize: PropTypes.oneOf(['inherit', 'medium', 'small', 'large']),
121+
fontSize: chainPropTypes(
122+
PropTypes.oneOf(['inherit', 'medium', 'small', 'large', 'default']),
123+
props => {
124+
if (props.fontSize === 'default') {
125+
return new Error(
126+
`The prop \`fontSize="default"\` of the \`SvgIcon\` component is deprecated. Use fontSize="medium" instead.`,
127+
);
128+
}
129+
130+
return null;
131+
},
132+
),
121133
/**
122134
* Applies a color attribute to the SVG element.
123135
*/

pages/api/icon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Icon from '@material-ui/core/Icon';
2222
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> |   | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
2323
| <span class="prop-name">color</span> | <span class="prop-type">enum:&nbsp;'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'<br></span> | <span class="prop-default">'inherit'</span> | The color of the component. It supports those theme colors that make sense for this component. |
2424
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> | <span class="prop-default">'span'</span> | The component used for the root node. Either a string to use a DOM element or a component. |
25-
| <span class="prop-name">fontSize</span> | <span class="prop-type">enum:&nbsp;'inherit'&nbsp;&#124;<br>&nbsp;'medium'&nbsp;&#124;<br>&nbsp;'small'&nbsp;&#124;<br>&nbsp;'large'<br></span> | <span class="prop-default">'medium'</span> | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. |
25+
| <span class="prop-name">fontSize</span> | <span class="prop-type">enum:&nbsp;'inherit', 'medium', 'small', 'large', 'default'<br></span> | <span class="prop-default">'medium'</span> | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. |
2626

2727
Any other properties supplied will be spread to the root element (native element).
2828

pages/api/svg-icon.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import SvgIcon from '@material-ui/core/SvgIcon';
2222
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> |   | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
2323
| <span class="prop-name">color</span> | <span class="prop-type">enum:&nbsp;'inherit', 'primary', 'secondary', 'action', 'error', 'disabled'<br></span> | <span class="prop-default">'inherit'</span> | The color of the component. It supports those theme colors that make sense for this component. You can use the `htmlColor` property to apply a color attribute to the SVG element. |
2424
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> | <span class="prop-default">'svg'</span> | The component used for the root node. Either a string to use a DOM element or a component. |
25-
| <span class="prop-name">fontSize</span> | <span class="prop-type">enum:&nbsp;'inherit'&nbsp;&#124;<br>&nbsp;'medium'&nbsp;&#124;<br>&nbsp;'small'&nbsp;&#124;<br>&nbsp;'large'<br></span> | <span class="prop-default">'medium'</span> | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. |
25+
| <span class="prop-name">fontSize</span> | <span class="prop-type">enum:&nbsp;'inherit', 'medium', 'small', 'large', 'default'<br></span> | <span class="prop-default">'medium'</span> | The fontSize applied to the icon. Defaults to 24px, but can be configure to inherit font size. |
2626
| <span class="prop-name">htmlColor</span> | <span class="prop-type">string</span> |   | Applies a color attribute to the SVG element. |
2727
| <span class="prop-name">shapeRendering</span> | <span class="prop-type">string</span> |   | 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. |
2828
| <span class="prop-name">titleAccess</span> | <span class="prop-type">string</span> |   | Provides a human-readable title for the element that contains it. https://www.w3.org/TR/SVG-access/#Equivalent |

0 commit comments

Comments
 (0)