Skip to content

Commit

Permalink
fix(material-experimental/mdc-list): add high contrast mode treatment
Browse files Browse the repository at this point in the history
Adds similar high contrast mode treatment to the non-MDC list since the MDC
implementation suffers from the same issues we had resolved before.
  • Loading branch information
crisbeto committed Feb 28, 2021
1 parent db6511b commit ec44c90
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions src/material-experimental/mdc-list/list.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use '../mdc-helpers/mdc-helpers';
@use '../../material/core/style/layout-common';
@use '../../cdk/a11y/a11y';
@import '@material/list/mixins.import';
@import '@material/list/variables.import';

Expand Down Expand Up @@ -125,3 +126,35 @@
@include layout-common.fill();
pointer-events: none;
}


@include a11y.high-contrast(active, off) {
.mat-mdc-list-option,
.mat-mdc-nav-list .mat-mdc-list-item,
.mat-mdc-action-list .mat-mdc-list-item {
&:hover, &:focus {
outline: dotted 1px;
}
}

// In single selection mode, the selected option is indicated by changing its
// background color, but that doesn't work in high contrast mode. We add an
// alternate indication by rendering out a circle.
.mat-mdc-list-option.mdc-list-item--selected::after {
$size: 10px;
content: '';
position: absolute;
top: 50%;
right: $mdc-list-side-padding;
transform: translateY(-50%);
width: $size;
height: 0;
border-bottom: solid $size;
border-radius: $size;
}

[dir='rtl'] .mat-mdc-list-option.mdc-list-item--selected::after {
right: auto;
left: $mdc-list-side-padding;
}
}

0 comments on commit ec44c90

Please sign in to comment.