Skip to content

Commit

Permalink
[IconButton] Add missing color classes (#33820)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zetta56 authored Nov 28, 2022
1 parent 91ad7e8 commit 73889d0
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/pages/material-ui/api/icon-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
"colorInherit",
"colorPrimary",
"colorSecondary",
"colorError",
"colorInfo",
"colorSuccess",
"colorWarning",
"disabled",
"sizeSmall",
"sizeMedium",
Expand Down
20 changes: 20 additions & 0 deletions docs/translations/api-docs/icon-button/icon-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@
"nodeName": "the root element",
"conditions": "<code>color=\"secondary\"</code>"
},
"colorError": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"error\"</code>"
},
"colorInfo": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"info\"</code>"
},
"colorSuccess": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"success\"</code>"
},
"colorWarning": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>color=\"warning\"</code>"
},
"disabled": {
"description": "State class applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
Expand Down
11 changes: 11 additions & 0 deletions packages/mui-material/src/IconButton/IconButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
import { createRenderer, describeConformance } from 'test/utils';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import IconButton, { iconButtonClasses as classes } from '@mui/material/IconButton';
import { unstable_capitalize as capitalize } from '@mui/utils';
import Icon from '@mui/material/Icon';
import ButtonBase from '@mui/material/ButtonBase';

Expand Down Expand Up @@ -91,6 +92,16 @@ describe('<IconButton />', () => {
});
});

describe('prop: color', () => {
['primary', 'secondary', 'error', 'info', 'success', 'warning'].forEach((color) => {
it(`should render the ${color} class`, () => {
const { getByRole } = render(<IconButton color={color}>Hello World</IconButton>);
const button = getByRole('button');
expect(button).to.have.class(classes[`color${capitalize(color)}`]);
});
});
});

it('should raise a warning about onClick in children because of Firefox', () => {
expect(() => {
PropTypes.checkPropTypes(
Expand Down
12 changes: 12 additions & 0 deletions packages/mui-material/src/IconButton/iconButtonClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ export interface IconButtonClasses {
colorPrimary: string;
/** Styles applied to the root element if `color="secondary"`. */
colorSecondary: string;
/** Styles applied to the root element if `color="error"`. */
colorError: string;
/** Styles applied to the root element if `color="info"`. */
colorInfo: string;
/** Styles applied to the root element if `color="success"`. */
colorSuccess: string;
/** Styles applied to the root element if `color="warning"`. */
colorWarning: string;
/** State class applied to the root element if `disabled={true}`. */
disabled: string;
/** Styles applied to the root element if `size="small"`. */
Expand All @@ -36,6 +44,10 @@ const iconButtonClasses: IconButtonClasses = generateUtilityClasses('MuiIconButt
'colorInherit',
'colorPrimary',
'colorSecondary',
'colorError',
'colorInfo',
'colorSuccess',
'colorWarning',
'edgeStart',
'edgeEnd',
'sizeSmall',
Expand Down

0 comments on commit 73889d0

Please sign in to comment.