Skip to content

Commit 0ee3c59

Browse files
committed
refactor(stepper): rename useGuidelines to displayDefaultIndicatorType, add spacing in scss, and use .first function in tests
1 parent 73e9d9c commit 0ee3c59

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

src/cdk/stepper/stepper.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ export interface StepperOptions {
9090
showError?: boolean;
9191

9292
/**
93-
* Whether the stepper should use the Material UI guidelines when
94-
* displaying the icons or not.
95-
* Default behavior is assumed to be false.
93+
* Whether the stepper should display the default indicator type
94+
* or not.
95+
* Default behavior is assumed to be true.
9696
*/
97-
useGuidelines?: boolean;
97+
displayDefaultIndicatorType?: boolean;
9898
}
9999

100100
@Component({
@@ -108,7 +108,7 @@ export interface StepperOptions {
108108
export class CdkStep implements OnChanges {
109109
private _stepperOptions: StepperOptions;
110110
_showError: boolean;
111-
_useGuidelines: boolean;
111+
_displayDefaultIndicatorType: boolean;
112112

113113
/** Template for step label if it exists. */
114114
@ContentChild(CdkStepLabel) stepLabel: CdkStepLabel;
@@ -189,7 +189,7 @@ export class CdkStep implements OnChanges {
189189
@Optional() @Inject(MAT_STEPPER_GLOBAL_OPTIONS) stepperOptions: StepperOptions) {
190190
this._stepperOptions = stepperOptions ? stepperOptions : {};
191191
this._showError = !!this._stepperOptions.showError;
192-
this._useGuidelines = !!this._stepperOptions.useGuidelines;
192+
this._displayDefaultIndicatorType = this._stepperOptions.displayDefaultIndicatorType !== false;
193193
}
194194

195195
/** Selects this step component. */
@@ -365,11 +365,9 @@ export class CdkStepper implements AfterViewInit, OnDestroy {
365365
const step = this._steps.toArray()[index];
366366
const isCurrentStep = this._isCurrentStep(index);
367367

368-
if (step._useGuidelines) {
369-
return this._getGuidelineLogic(step, isCurrentStep, state);
370-
} else {
371-
return this._getDefaultIndicatorLogic(step, isCurrentStep);
372-
}
368+
return step._displayDefaultIndicatorType
369+
? this._getDefaultIndicatorLogic(step, isCurrentStep)
370+
: this._getGuidelineLogic(step, isCurrentStep, state);
373371
}
374372

375373
private _getDefaultIndicatorLogic(step: CdkStep, isCurrentStep: boolean): StepState {

src/lib/stepper/step-header.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ $mat-step-header-icon-size: 16px !default;
3939
}
4040

4141
.mat-step-icon-error .mat-icon {
42-
font-size: $mat-step-header-icon-size+8;
43-
height: $mat-step-header-icon-size+8;
44-
width: $mat-step-header-icon-size+8;
42+
font-size: $mat-step-header-icon-size + 8;
43+
height: $mat-step-header-icon-size + 8;
44+
width: $mat-step-header-icon-size + 8;
4545
}
4646

4747
.mat-step-label {

src/lib/stepper/stepper.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ You can set the state of a step to whatever you want. The given state by default
188188
</mat-horizontal-stepper>
189189
```
190190

191-
In order to use the custom step states, you must add the `useGuidelines` option to the global default stepper options which can be specified by providing a value for
191+
In order to use the custom step states, you must add the `displayDefaultIndicatorType` option to the global default stepper options which can be specified by providing a value for
192192
`MAT_STEPPER_GLOBAL_OPTIONS` in your application's root module.
193193

194194
```ts
195195
@NgModule({
196196
providers: [
197197
{
198198
provide: MAT_STEPPER_GLOBAL_OPTIONS,
199-
useValue: { useGuidelines: true }
199+
useValue: { displayDefaultIndicatorType: false }
200200
}
201201
]
202202
})

src/lib/stepper/stepper.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ describe('MatStepper', () => {
905905
.queryAll(By.directive(MatStepperNext))[0].nativeElement;
906906

907907
stepper.selectedIndex = 1;
908-
stepper._steps.toArray()[0].hasError = true;
908+
stepper._steps.first.hasError = true;
909909
nextButtonNativeEl.click();
910910
fixture.detectChanges();
911911

@@ -922,7 +922,7 @@ describe('MatStepper', () => {
922922
MatHorizontalStepperWithErrorsApp,
923923
[{
924924
provide: MAT_STEPPER_GLOBAL_OPTIONS,
925-
useValue: {useGuidelines: true}
925+
useValue: {displayDefaultIndicatorType: false}
926926
}],
927927
[MatFormFieldModule, MatInputModule]
928928
);
@@ -936,7 +936,7 @@ describe('MatStepper', () => {
936936
.queryAll(By.directive(MatStepperNext))[0].nativeElement;
937937

938938
stepper.selectedIndex = 1;
939-
stepper._steps.toArray()[0].completed = true;
939+
stepper._steps.first.completed = true;
940940
nextButtonNativeEl.click();
941941
fixture.detectChanges();
942942

0 commit comments

Comments
 (0)