Skip to content

Commit 2fd862d

Browse files
crisbetommalerba
authored andcommitted
fix(slide-toggle): fix and simplify high contrast styles (#18104)
Fixes the slide toggle high contrast styles which seem to have broken after we changed the mixin from producing a media query to a class. Also simplifies high contrast styles.
1 parent f6cf22f commit 2fd862d

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/material/slide-toggle/slide-toggle.scss

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -217,34 +217,17 @@ $mat-slide-toggle-bar-track-width: $mat-slide-toggle-bar-width - $mat-slide-togg
217217
}
218218

219219
/** Custom styling to make the slide-toggle usable in high contrast mode. */
220-
@include cdk-high-contrast() {
221-
.mat-slide-toggle-thumb {
222-
background: #fff;
223-
border: 1px solid #000;
224-
225-
.mat-slide-toggle.mat-checked & {
226-
background: #000;
227-
border: 1px solid #fff;
228-
}
229-
}
230-
220+
@include cdk-high-contrast {
221+
.mat-slide-toggle-thumb,
231222
.mat-slide-toggle-bar {
232-
background: #fff;
233-
234-
// As a focus indication in high contrast mode, we add a dotted outline to the slide-toggle
235-
// bar. Since the bar element does not have any padding, we need to specify an outline offset
236-
// because otherwise the opaque thumb element will hide the outline.
237-
.mat-slide-toggle.cdk-keyboard-focused & {
238-
outline: 1px dotted;
239-
outline-offset: ($mat-slide-toggle-height - $mat-slide-toggle-bar-height) / 2;
240-
}
223+
border: 1px solid;
241224
}
242-
}
243225

244-
// Since the bar with a white background will be placed on a white background, we need to a black
245-
// border in order to make sure that the bar is visible.
246-
@include cdk-high-contrast(black-on-white) {
247-
.mat-slide-toggle-bar {
248-
border: 1px solid #000;
226+
// As a focus indication in high contrast mode, we add a dotted outline to the slide-toggle
227+
// bar. Since the bar element does not have any padding, we need to specify an outline offset
228+
// because otherwise the opaque thumb element will hide the outline.
229+
.mat-slide-toggle.cdk-keyboard-focused .mat-slide-toggle-bar {
230+
outline: 2px dotted;
231+
outline-offset: ($mat-slide-toggle-height - $mat-slide-toggle-bar-height) / 2;
249232
}
250233
}

0 commit comments

Comments
 (0)