Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(checkbox): outline not visible when checked in high contrast mode #18048

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions src/material/checkbox/_checkbox-theme.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
@import '../core/theming/theming';
@import '../core/typography/typography-utils';
@import '../../cdk/a11y/a11y';


@mixin mat-checkbox-theme($theme) {
Expand Down Expand Up @@ -34,12 +33,6 @@
// !important is needed here because a stroke must be set as an
// attribute on the SVG in order for line animation to work properly.
stroke: $checkbox-mark-color !important;

@include cdk-high-contrast(black-on-white) {
// Having the one above be !important ends up overriding the browser's automatic
// color inversion so we need to re-invert it ourselves for black-on-white.
stroke: #000 !important;
}
}

.mat-checkbox-mixedmark {
Expand Down Expand Up @@ -77,19 +70,6 @@
.mat-checkbox-label {
color: mat-color($foreground, secondary-text);
}

@include cdk-high-contrast {
opacity: 0.5;
}
}

// This one is moved down here so it can target both
// the theme colors and the disabled state.
@include cdk-high-contrast {
.mat-checkbox-background {
// Needs to be removed because it hides the checkbox outline.
background: none;
}
}

// Switch this to a solid color since we're using `opacity`
Expand Down
19 changes: 19 additions & 0 deletions src/material/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,15 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
._mat-animation-noopable & {
transition: none;
}

// `.mat-checkbox` here is redundant, but we need it to increase the specificity so that
// these styles don't get overwritten by the `background-color` from the theme.
.mat-checkbox & {
@include cdk-high-contrast {
// Needs to be removed because it hides the checkbox outline.
background: none;
}
}
}

.mat-checkbox-persistent-ripple {
Expand Down Expand Up @@ -319,6 +328,12 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
dasharray: $_mat-checkbox-mark-path-length;
width: $_mat-checkbox-mark-stroke-size;
}

@include cdk-high-contrast(black-on-white) {
// In the checkbox theme this `stroke` has !important which ends up overriding the browser's
// automatic color inversion so we need to re-invert it ourselves for black-on-white.
stroke: #000 !important;
}
}

.mat-checkbox-mixedmark {
Expand Down Expand Up @@ -393,6 +408,10 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;

.mat-checkbox-disabled {
cursor: default;

@include cdk-high-contrast {
opacity: 0.5;
}
}

.mat-checkbox-anim {
Expand Down