Skip to content

Commit edfaadc

Browse files
authored
[Button] Remove label span (#26666)
1 parent 329614f commit edfaadc

File tree

13 files changed

+42
-74
lines changed

13 files changed

+42
-74
lines changed

docs/pages/api-docs/button.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"styles": {
3939
"classes": [
4040
"root",
41-
"label",
4241
"text",
4342
"textInherit",
4443
"textPrimary",

docs/pages/api-docs/loading-button.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"styles": {
2222
"classes": [
2323
"root",
24-
"label",
2524
"text",
2625
"textInherit",
2726
"textPrimary",
@@ -62,8 +61,7 @@
6261
"loadingIndicatorStart",
6362
"loadingIndicatorEnd",
6463
"endIconLoadingEnd",
65-
"startIconLoadingStart",
66-
"labelLoadingCenter"
64+
"startIconLoadingStart"
6765
],
6866
"globalClasses": { "focusVisible": "Mui-focusVisible", "disabled": "Mui-disabled" },
6967
"name": "MuiLoadingButton"

docs/src/pages/guides/migration-v4/migration-v4.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,16 @@ You can use the [`moved-lab-modules` codemod](https://github.com/mui-org/materia
598598

599599
You can use the [`button-color-prop` codemod](https://github.com/mui-org/material-ui/tree/HEAD/packages/material-ui-codemod#button-color-prop) for automatic migration.
600600

601+
- `span` element that wraps children has been removed. `label` classKey is also removed.
602+
603+
```diff
604+
<button class="MuiButton-root">
605+
- <span class="MuiButton-label">
606+
children
607+
- </span>
608+
</button>
609+
```
610+
601611
### Chip
602612

603613
- Rename `default` variant to `filled` for consistency.

docs/src/pages/premium-themes/paperbase/Paperbase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ theme = {
6666
},
6767
MuiButton: {
6868
styleOverrides: {
69-
label: {
69+
root: {
7070
textTransform: 'none',
7171
},
7272
contained: {

docs/src/pages/premium-themes/paperbase/Paperbase.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ theme = {
6565
},
6666
MuiButton: {
6767
styleOverrides: {
68-
label: {
68+
root: {
6969
textTransform: 'none',
7070
},
7171
contained: {

docs/translations/api-docs/button/button.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
},
2020
"classDescriptions": {
2121
"root": { "description": "Styles applied to the root element." },
22-
"label": {
23-
"description": "Styles applied to {{nodeName}}.",
24-
"nodeName": "the span element that wraps the children"
25-
},
2622
"text": {
2723
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
2824
"nodeName": "the root element",

docs/translations/api-docs/loading-button/loading-button.json

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
},
1212
"classDescriptions": {
1313
"root": { "description": "Styles applied to the root element." },
14-
"label": {
15-
"description": "Styles applied to {{nodeName}}.",
16-
"nodeName": "the span element that wraps the children"
17-
},
1814
"text": {
1915
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
2016
"nodeName": "the root element",
@@ -218,11 +214,6 @@
218214
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
219215
"nodeName": "the startIcon element",
220216
"conditions": "<code>loading={true}</code> and <code>loadingPosition=\"start\"</code>"
221-
},
222-
"labelLoadingCenter": {
223-
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
224-
"nodeName": "the label element",
225-
"conditions": "<code>loading={true}</code> and <code>loadingPosition=\"center\"</code>"
226217
}
227218
}
228219
}

packages/material-ui-lab/src/LoadingButton/LoadingButton.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export type LoadingButtonTypeMap<
2828
endIconLoadingEnd?: string;
2929
/** Styles applied to the startIcon element if `loading={true}` and `loadingPosition="start"`. */
3030
startIconLoadingStart?: string;
31-
/** Styles applied to the label element if `loading={true}` and `loadingPosition="center"`. */
32-
labelLoadingCenter?: string;
3331
};
3432
/**
3533
* If `true`, the loading indicator is shown.

packages/material-ui-lab/src/LoadingButton/LoadingButton.js

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { chainPropTypes } from '@material-ui/utils';
44
import { capitalize } from '@material-ui/core/utils';
55
import { unstable_composeClasses as composeClasses } from '@material-ui/unstyled';
66
import { styled, unstable_useThemeProps as useThemeProps } from '@material-ui/core/styles';
7-
import Button from '@material-ui/core/Button';
7+
import Button, { buttonClasses } from '@material-ui/core/Button';
88
import CircularProgress from '@material-ui/core/CircularProgress';
99
import loadingButtonClasses, { getLoadingButtonUtilityClass } from './loadingButtonClasses';
1010

@@ -15,7 +15,6 @@ const useUtilityClasses = (styleProps) => {
1515
root: ['root', loading && 'loading'],
1616
startIcon: [loading && `startIconLoading${capitalize(loadingPosition)}`],
1717
endIcon: [loading && `endIconLoading${capitalize(loadingPosition)}`],
18-
label: [loading && `labelLoading${capitalize(loadingPosition)}`],
1918
loadingIndicator: [
2019
'loadingIndicator',
2120
loading && `loadingIndicator${capitalize(loadingPosition)}`,
@@ -51,22 +50,25 @@ const LoadingButtonRoot = styled(Button, {
5150
...(styles.endIconLoadingEnd && {
5251
[`& .${loadingButtonClasses.endIconLoadingEnd}`]: styles.endIconLoadingEnd,
5352
}),
54-
...(styles.labelLoadingCenter && {
55-
[`& .${loadingButtonClasses.labelLoadingCenter}`]: styles.labelLoadingCenter,
56-
}),
5753
};
5854
},
59-
})({
60-
[`& .${loadingButtonClasses.startIconLoadingStart}`]: {
61-
visibility: 'hidden',
62-
},
63-
[`& .${loadingButtonClasses.endIconLoadingEnd}`]: {
64-
visibility: 'hidden',
65-
},
66-
[`& .${loadingButtonClasses.labelLoadingCenter}`]: {
67-
visibility: 'hidden',
68-
},
69-
});
55+
})(({ styleProps, theme }) => ({
56+
[`& .${loadingButtonClasses.startIconLoadingStart}, & .${loadingButtonClasses.endIconLoadingEnd}`]:
57+
{
58+
transition: theme.transitions.create(['opacity'], {
59+
duration: theme.transitions.duration.short,
60+
}),
61+
opacity: 0,
62+
},
63+
...(styleProps.loadingPosition === 'center' && {
64+
transition: theme.transitions.create(['background-color', 'box-shadow', 'border-color'], {
65+
duration: theme.transitions.duration.short,
66+
}),
67+
[`&.${buttonClasses.disabled}`]: {
68+
color: 'transparent',
69+
},
70+
}),
71+
}));
7072

7173
const LoadingButtonLoadingIndicator = styled('div', {
7274
name: 'MuiLoadingButton',
@@ -78,7 +80,7 @@ const LoadingButtonLoadingIndicator = styled('div', {
7880
...styles[`loadingIndicator${capitalize(styleProps.loadingPosition)}`],
7981
};
8082
},
81-
})(({ styleProps }) => ({
83+
})(({ theme, styleProps }) => ({
8284
position: 'absolute',
8385
visibility: 'visible',
8486
display: 'flex',
@@ -88,6 +90,7 @@ const LoadingButtonLoadingIndicator = styled('div', {
8890
...(styleProps.loadingPosition === 'center' && {
8991
left: '50%',
9092
transform: 'translate(-50%)',
93+
color: theme.palette.action.disabled,
9194
}),
9295
...(styleProps.loadingPosition === 'end' && {
9396
right: 14,

packages/material-ui-lab/src/LoadingButton/loadingButtonClasses.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export interface LoadingButtonClasses {
1717
endIconLoadingEnd: string;
1818
/** Styles applied to the startIcon element if `loading={true}` and `loadingPosition="start"`. */
1919
startIconLoadingStart: string;
20-
/** Styles applied to the label element if `loading={true}` and `loadingPosition="center"`. */
21-
labelLoadingCenter: string;
2220
}
2321

2422
export type LoadingButtonClassKey = keyof LoadingButtonClasses;
@@ -36,7 +34,6 @@ const loadingButtonClasses: LoadingButtonClasses = generateUtilityClasses('MuiLo
3634
'loadingIndicatorEnd',
3735
'endIconLoadingEnd',
3836
'startIconLoadingStart',
39-
'labelLoadingCenter',
4037
]);
4138

4239
export default loadingButtonClasses;

0 commit comments

Comments
 (0)