Skip to content

Commit fc78c4c

Browse files
alexismoZeeshanTamboli
authored andcommitted
[material-ui][Stepper] Generate class for nonLinear prop (#42620)
Signed-off-by: Alexis Morin <[email protected]> Co-authored-by: ZeeshanTamboli <[email protected]>
1 parent 1357ee8 commit fc78c4c

File tree

5 files changed

+31
-2
lines changed

5 files changed

+31
-2
lines changed

docs/pages/material-ui/api/stepper.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@
3737
"description": "Styles applied to the root element if `orientation=\"horizontal\"`.",
3838
"isGlobal": false
3939
},
40+
{
41+
"key": "nonLinear",
42+
"className": "MuiStepper-nonLinear",
43+
"description": "Styles applied to the root element if `nonLinear={true}`.",
44+
"isGlobal": false
45+
},
4046
{
4147
"key": "root",
4248
"className": "MuiStepper-root",

docs/translations/api-docs/stepper/stepper.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@
3232
"nodeName": "the root element",
3333
"conditions": "<code>orientation=\"horizontal\"</code>"
3434
},
35+
"nonLinear": {
36+
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
37+
"nodeName": "the root element",
38+
"conditions": "<code>nonLinear={true}</code>"
39+
},
3540
"root": { "description": "Styles applied to the root element." },
3641
"vertical": {
3742
"description": "Styles applied to {{nodeName}} if {{conditions}}.",

packages/mui-material/src/Stepper/Stepper.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import StepConnector from '../StepConnector';
1111
import StepperContext from './StepperContext';
1212

1313
const useUtilityClasses = (ownerState) => {
14-
const { orientation, alternativeLabel, classes } = ownerState;
14+
const { orientation, nonLinear, alternativeLabel, classes } = ownerState;
1515
const slots = {
16-
root: ['root', orientation, alternativeLabel && 'alternativeLabel'],
16+
root: ['root', orientation, nonLinear && 'nonLinear', alternativeLabel && 'alternativeLabel'],
1717
};
1818

1919
return composeClasses(slots, getStepperUtilityClass, classes);
@@ -28,6 +28,7 @@ const StepperRoot = styled('div', {
2828
styles.root,
2929
styles[ownerState.orientation],
3030
ownerState.alternativeLabel && styles.alternativeLabel,
31+
ownerState.nonLinear && styles.nonLinear,
3132
];
3233
},
3334
})(({ ownerState }) => ({
@@ -62,6 +63,7 @@ const Stepper = React.forwardRef(function Stepper(inProps, ref) {
6263

6364
const ownerState = {
6465
...props,
66+
nonLinear,
6567
alternativeLabel,
6668
orientation,
6769
component,

packages/mui-material/src/Stepper/Stepper.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,17 @@ describe('<Stepper />', () => {
258258
expect(stepContent[0]).not.to.have.class(stepContentClasses.last);
259259
expect(stepContent[1]).to.have.class(stepContentClasses.last);
260260
});
261+
262+
it('should apply non-linear class', () => {
263+
const { container } = render(
264+
<Stepper nonLinear activeStep={0}>
265+
<Step />
266+
<Step />
267+
<Step />
268+
</Stepper>,
269+
);
270+
271+
const stepper = container.querySelector(`.${classes.root}`);
272+
expect(stepper).to.have.class(classes.nonLinear);
273+
});
261274
});

packages/mui-material/src/Stepper/stepperClasses.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export interface StepperClasses {
88
horizontal: string;
99
/** Styles applied to the root element if `orientation="vertical"`. */
1010
vertical: string;
11+
/** Styles applied to the root element if `nonLinear={true}`. */
12+
nonLinear: string;
1113
/** Styles applied to the root element if `alternativeLabel={true}`. */
1214
alternativeLabel: string;
1315
}
@@ -22,6 +24,7 @@ const stepperClasses: StepperClasses = generateUtilityClasses('MuiStepper', [
2224
'root',
2325
'horizontal',
2426
'vertical',
27+
'nonLinear',
2528
'alternativeLabel',
2629
]);
2730

0 commit comments

Comments
 (0)