Skip to content

Commit

Permalink
fix(stepper): improved alignment for step icons (#12703)
Browse files Browse the repository at this point in the history
Switches to using absolute positioning to center the stepper icons. This works better with the text-based icons.

Fixes #12696.
  • Loading branch information
crisbeto authored and jelbourn committed Aug 24, 2018
1 parent 8e49388 commit 37a7056
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lib/stepper/step-header.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@
*ngSwitchCase="true"
[ngTemplateOutlet]="iconOverrides.number"
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
<span *ngSwitchDefault>{{index + 1}}</span>
<span class="mat-step-icon-content" *ngSwitchDefault>{{index + 1}}</span>
</ng-container>

<ng-container *ngSwitchCase="'edit'" [ngSwitch]="!!(iconOverrides && iconOverrides.edit)">
<ng-container
*ngSwitchCase="true"
[ngTemplateOutlet]="iconOverrides.edit"
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
<mat-icon *ngSwitchDefault>create</mat-icon>
<mat-icon class="mat-step-icon-content" *ngSwitchDefault>create</mat-icon>
</ng-container>

<ng-container *ngSwitchCase="'done'" [ngSwitch]="!!(iconOverrides && iconOverrides.done)">
<ng-container
*ngSwitchCase="true"
[ngTemplateOutlet]="iconOverrides.done"
[ngTemplateOutletContext]="_getIconContext()"></ng-container>
<mat-icon *ngSwitchDefault>done</mat-icon>
<mat-icon class="mat-step-icon-content" *ngSwitchDefault>done</mat-icon>
</ng-container>
</div>
<div class="mat-step-label"
Expand Down
12 changes: 9 additions & 3 deletions src/lib/stepper/step-header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,16 @@ $mat-step-header-icon-size: 16px !default;
border-radius: 50%;
height: $mat-stepper-label-header-height;
width: $mat-stepper-label-header-height;
align-items: center;
justify-content: center;
display: flex;
flex-shrink: 0;
position: relative;
}

.mat-step-icon-content {
// Use absolute positioning to center the content, because it works better with text.
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.mat-step-icon .mat-icon {
Expand Down

0 comments on commit 37a7056

Please sign in to comment.