Skip to content

Commit cd92c76

Browse files
authored
fix(ui): centered toggle switch vertically (#1413)
* fix(ui): centered toggle switch vertically * fix(ui): encapsulated mat-slide-toggle in a div * fix(style): added align-items center property * fix(code): fixed linting
1 parent b8fc4dc commit cd92c76

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

projects/components/src/toggle-switch/toggle-switch.component.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
@import 'color-palette';
22
@import 'font';
33

4-
:host {
4+
.toggle-switch {
5+
display: flex;
6+
align-items: center;
7+
58
::ng-deep {
69
.mat-slide-toggle {
710
&.disabled {

projects/components/src/toggle-switch/toggle-switch.component.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@ import { ToggleSwitchSize } from './toggle-switch-size';
77
styleUrls: ['./toggle-switch.component.scss'],
88
changeDetection: ChangeDetectionStrategy.OnPush,
99
template: `
10-
<mat-slide-toggle
11-
color="primary"
12-
[checked]="this.checked"
13-
[ngClass]="{ 'small-slide-toggle': this.size === '${ToggleSwitchSize.Small}', disabled: this.disabled }"
14-
[disabled]="this.disabled"
15-
(change)="this.onToggle($event)"
16-
>
17-
<div class="label">{{ this.label }}</div>
18-
</mat-slide-toggle>
10+
<div class="toggle-switch">
11+
<mat-slide-toggle
12+
color="primary"
13+
[checked]="this.checked"
14+
[ngClass]="{ 'small-slide-toggle': this.size === '${ToggleSwitchSize.Small}', disabled: this.disabled }"
15+
[disabled]="this.disabled"
16+
(change)="this.onToggle($event)"
17+
>
18+
<div class="label">{{ this.label }}</div>
19+
</mat-slide-toggle>
20+
</div>
1921
`
2022
})
2123
export class ToggleSwitchComponent {

0 commit comments

Comments
 (0)