Skip to content

Commit d0740e8

Browse files
committed
address feedback
1 parent 62cbaf2 commit d0740e8

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

src/lib/stepper/step-header.html

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
<div class="mat-step-header-ripple" mat-ripple [matRippleTrigger]="_getHostElement()"></div>
2-
<div class="mat-step-icon-state-{{state}} mat-step-icon" [class.mat-step-icon-selected]="selected"
3-
[ngSwitch]="state">
4-
5-
<div class="mat-step-icon-content">
6-
<ng-container *ngSwitchDefault [ngSwitch]="!!(iconOverrides && iconOverrides[state])">
7-
<ng-container
8-
*ngSwitchCase="true"
9-
[ngTemplateOutlet]="iconOverrides[state]"
10-
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
11-
<mat-icon *ngSwitchDefault>{{_getDefaultIconForState(state)}}</mat-icon>
12-
</ng-container>
2+
<div class="mat-step-icon-state-{{state}} mat-step-icon" [class.mat-step-icon-selected]="selected">
3+
<div class="mat-step-icon-content" [ngSwitch]="!!(iconOverrides && iconOverrides[state])">
4+
<ng-container
5+
*ngSwitchCase="true"
6+
[ngTemplateOutlet]="iconOverrides[state]"
7+
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
8+
<mat-icon *ngSwitchDefault>{{_getDefaultIconForState(state)}}</mat-icon>
139
</div>
1410
</div>
1511
<div class="mat-step-label"

src/lib/stepper/step-header.ts

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* found in the LICENSE file at https://angular.io/license
77
*/
88

9-
import {FocusMonitor} from '@angular/cdk/a11y';
9+
import { FocusMonitor } from '@angular/cdk/a11y';
1010
import {
1111
ChangeDetectionStrategy,
1212
ChangeDetectorRef,
@@ -15,26 +15,25 @@ import {
1515
Input,
1616
OnDestroy,
1717
ViewEncapsulation,
18-
TemplateRef,
18+
TemplateRef
1919
} from '@angular/core';
20-
import {Subscription} from 'rxjs';
21-
import {MatStepLabel} from './step-label';
22-
import {MatStepperIntl} from './stepper-intl';
23-
import {MatStepperIconContext} from './stepper-icon';
24-
import {CdkStepHeader, StepState} from '@angular/cdk/stepper';
25-
20+
import { Subscription } from 'rxjs';
21+
import { MatStepLabel } from './step-label';
22+
import { MatStepperIntl } from './stepper-intl';
23+
import { MatStepperIconContext } from './stepper-icon';
24+
import { CdkStepHeader, StepState } from '@angular/cdk/stepper';
2625

2726
@Component({
2827
moduleId: module.id,
2928
selector: 'mat-step-header',
3029
templateUrl: 'step-header.html',
3130
styleUrls: ['step-header.css'],
3231
host: {
33-
'class': 'mat-step-header',
34-
'role': 'tab',
32+
class: 'mat-step-header',
33+
role: 'tab'
3534
},
3635
encapsulation: ViewEncapsulation.None,
37-
changeDetection: ChangeDetectionStrategy.OnPush,
36+
changeDetection: ChangeDetectionStrategy.OnPush
3837
})
3938
export class MatStepHeader extends CdkStepHeader implements OnDestroy {
4039
private _intlSubscription: Subscription;
@@ -49,7 +48,7 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy {
4948
@Input() errorMessage: string;
5049

5150
/** Overrides for the header icons, passed in via the stepper. */
52-
@Input() iconOverrides: {[key: string]: TemplateRef<MatStepperIconContext>};
51+
@Input() iconOverrides: { [key: string]: TemplateRef<MatStepperIconContext> };
5352

5453
/** Index of the given step. */
5554
@Input() index: number;
@@ -67,10 +66,13 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy {
6766
public _intl: MatStepperIntl,
6867
private _focusMonitor: FocusMonitor,
6968
_elementRef: ElementRef<HTMLElement>,
70-
changeDetectorRef: ChangeDetectorRef) {
69+
changeDetectorRef: ChangeDetectorRef
70+
) {
7171
super(_elementRef);
7272
_focusMonitor.monitor(_elementRef, true);
73-
this._intlSubscription = _intl.changes.subscribe(() => changeDetectorRef.markForCheck());
73+
this._intlSubscription = _intl.changes.subscribe(() =>
74+
changeDetectorRef.markForCheck()
75+
);
7476
}
7577

7678
ngOnDestroy() {
@@ -102,13 +104,16 @@ export class MatStepHeader extends CdkStepHeader implements OnDestroy {
102104
};
103105
}
104106

105-
_getDefaultIconForState(state: string): string {
107+
_getDefaultIconForState(state: StepState): string {
106108
if (state == 'number') {
107109
return `${this.index + 1}`;
108110
}
109-
return ({
110-
'edit': 'create',
111-
'error': 'warning',
112-
} as {[key: string]: string})[state] || state;
111+
if (state == 'edit') {
112+
return 'create';
113+
}
114+
if (state == 'error') {
115+
return 'warning';
116+
}
117+
return state;
113118
}
114119
}

0 commit comments

Comments
 (0)