Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IconButton] Add size large and update styles #26748

Merged
merged 14 commits into from
Jun 17, 2021
4 changes: 3 additions & 1 deletion docs/pages/api-docs/icon-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"size": {
"type": {
"name": "union",
"description": "'medium'<br>&#124;&nbsp;'small'<br>&#124;&nbsp;string"
"description": "'small'<br>&#124;&nbsp;'medium'<br>&#124;&nbsp;'large'<br>&#124;&nbsp;string"
},
"default": "'medium'"
},
Expand All @@ -39,6 +39,8 @@
"colorSecondary",
"disabled",
"sizeSmall",
"sizeMedium",
siriwatknp marked this conversation as resolved.
Show resolved Hide resolved
"sizeLarge",
"label"
],
"globalClasses": { "disabled": "Mui-disabled" },
Expand Down
6 changes: 6 additions & 0 deletions docs/src/pages/components/buttons/ButtonSizes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export default function ButtonSizes() {
<IconButton aria-label="delete">
<DeleteIcon />
</IconButton>
<IconButton aria-label="delete" size="large">
<DeleteIcon />
</IconButton>
<IconButton aria-label="delete" size="large">
<DeleteIcon fontSize="inherit" />
</IconButton>
<IconButton aria-label="delete">
<DeleteIcon fontSize="large" />
</IconButton>
Expand Down
10 changes: 10 additions & 0 deletions docs/translations/api-docs/icon-button/icon-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@
"nodeName": "the root element",
"conditions": "<code>size=\"small\"</code>"
},
"sizeMedium": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>size=\"medium\"</code>"
},
"sizeLarge": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>size=\"large\"</code>"
},
"label": {
"description": "Styles applied to {{nodeName}}.",
"nodeName": "the children container element"
Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/IconButton/IconButton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export type IconButtonTypeMap<
* `small` is equivalent to the dense button styling.
* @default 'medium'
*/
size?: OverridableStringUnion<'small' | 'medium', IconButtonPropsSizeOverrides>;
size?: OverridableStringUnion<'small' | 'medium' | 'large', IconButtonPropsSizeOverrides>;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
Expand Down
11 changes: 8 additions & 3 deletions packages/material-ui/src/IconButton/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const IconButtonRoot = styled(ButtonBase, {
textAlign: 'center',
flex: '0 0 auto',
fontSize: theme.typography.pxToRem(24),
padding: 12,
padding: 8,
borderRadius: '50%',
overflow: 'visible', // Explicitly set the default value to solve a bug on IE11.
color: theme.palette.action.active,
Expand Down Expand Up @@ -98,9 +98,14 @@ const IconButtonRoot = styled(ButtonBase, {
}),
/* Styles applied to the root element if `size="small"`. */
...(styleProps.size === 'small' && {
padding: 3,
padding: 6,
fontSize: theme.typography.pxToRem(18),
}),
/* Styles applied to the root element if `size="small"`. */
siriwatknp marked this conversation as resolved.
Show resolved Hide resolved
...(styleProps.size === 'large' && {
padding: 12,
fontSize: theme.typography.pxToRem(28),
}),
/* Styles applied to the root element if `disabled={true}`. */
[`&.${iconButtonClasses.disabled}`]: {
backgroundColor: 'transparent',
Expand Down Expand Up @@ -239,7 +244,7 @@ IconButton.propTypes /* remove-proptypes */ = {
* @default 'medium'
*/
size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([
PropTypes.oneOf(['medium', 'small']),
PropTypes.oneOf(['small', 'medium', 'large']),
PropTypes.string,
]),
/**
Expand Down
4 changes: 4 additions & 0 deletions packages/material-ui/src/IconButton/IconButton.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,12 @@ describe('<IconButton />', () => {
root = render(<IconButton size="medium">book</IconButton>).container.firstChild;
expect(root).not.to.have.class(classes.sizeSmall);

root = render(<IconButton size="large">book</IconButton>).container.firstChild;
expect(root).to.have.class(classes.sizeLarge);

root = render(<IconButton>book</IconButton>).container.firstChild;
expect(root).not.to.have.class(classes.sizeSmall);
expect(root).not.to.have.class(classes.sizeLarge);
});
});

Expand Down
5 changes: 5 additions & 0 deletions packages/material-ui/src/IconButton/iconButtonClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export interface IconButtonClasses {
disabled: string;
/** Styles applied to the root element if `size="small"`. */
sizeSmall: string;
/** Styles applied to the root element if `size="medium"`. */
sizeMedium: string;
/** Styles applied to the root element if `size="large"`. */
sizeLarge: string;
/** Styles applied to the children container element. */
label: string;
}
Expand All @@ -37,6 +41,7 @@ const iconButtonClasses: IconButtonClasses = generateUtilityClasses('MuiIconButt
'edgeEnd',
'sizeSmall',
'sizeMedium',
'sizeLarge',
'label',
]);

Expand Down