Skip to content

Commit da0ac13

Browse files
authored
fix: override toggle colors when disabled (#898)
1 parent 58d265c commit da0ac13

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,17 @@
44
:host {
55
::ng-deep {
66
.mat-slide-toggle {
7-
&.small-slide-toogle {
7+
&.disabled {
8+
.mat-slide-toggle-thumb {
9+
background: $gray-7;
10+
}
11+
12+
.mat-slide-toggle-bar {
13+
background: $gray-3;
14+
}
15+
}
16+
17+
&.small-slide-toggle {
818
height: 20px;
919
line-height: 20px;
1020

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('Toggle Switch Component', () => {
3636
expect(matToggleComponent?.checked).toBeTruthy();
3737
expect(matToggleComponent?.disabled).toBeFalsy();
3838
expect(spectator.query('.label')).toHaveText('label');
39-
expect(spectator.query('mat-slide-toggle')).toHaveClass('small-slide-toogle');
39+
expect(spectator.query('mat-slide-toggle')).toHaveClass('small-slide-toggle');
4040

4141
spectator.triggerEventHandler(MatSlideToggle, 'change', new MatSlideToggleChange(matToggleComponent!, false));
4242
expect(onCheckedChangeSpy).toHaveBeenCalledWith(false);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { ToggleSwitchSize } from './toggle-switch-size';
1010
<mat-slide-toggle
1111
color="primary"
1212
[(ngModel)]="this.checked"
13-
[ngClass]="{ 'small-slide-toogle': this.size === '${ToggleSwitchSize.Small}' }"
13+
[ngClass]="{ 'small-slide-toggle': this.size === '${ToggleSwitchSize.Small}', disabled: this.disabled }"
1414
[disabled]="this.disabled"
1515
(change)="this.onToggle($event)"
1616
>

0 commit comments

Comments
 (0)