Skip to content

Commit b119472

Browse files
crisbetojelbourn
authored andcommitted
fix: reduce amount of generated high contrast styles (#18332)
Since we know that all of our components have encapsulation turned off, we can pass in the encapsulation parameter to the `cdk-high-contrast` mixin and avoid having to output the styles twice. (cherry picked from commit 05f59b3)
1 parent aff21e8 commit b119472

File tree

38 files changed

+72
-72
lines changed

38 files changed

+72
-72
lines changed

src/material-experimental/mdc-button/button.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// Add an outline to make buttons more visible in high contrast mode. Stroked buttons
1414
// don't need a special look in high-contrast mode, because those already have an outline.
15-
@include cdk-high-contrast {
15+
@include cdk-high-contrast(active, off) {
1616
&:not(.mdc-button--outlined) {
1717
outline: solid 1px;
1818
}

src/material-experimental/mdc-card/card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $mat-card-default-padding: 16px !default;
1616
// Add styles to the root card to have an outline in high-contrast mode.
1717
// TODO(jelbourn): file bug for MDC supporting high-contrast mode on `.mdc-card`.
1818
.mat-mdc-card {
19-
@include cdk-high-contrast {
19+
@include cdk-high-contrast(active, off) {
2020
outline: solid 1px;
2121
}
2222
}

src/material-experimental/mdc-chips/chips.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
// Required for the ripple to clip properly in Safari.
1717
transform: translateZ(0);
1818

19-
@include cdk-high-contrast {
19+
@include cdk-high-contrast(active, off) {
2020
outline: solid 1px;
2121

2222
&:focus {
@@ -73,7 +73,7 @@ input.mat-mdc-chip-input {
7373
}
7474

7575
.mdc-chip__checkmark-path {
76-
@include cdk-high-contrast(black-on-white) {
76+
@include cdk-high-contrast(black-on-white, off) {
7777
// SVG colors won't be changed in high contrast mode and since the checkmark is white
7878
// by default, it'll blend in with the background in black-on-white mode. Override the color
7979
// to ensure that it's visible. We need !important, because the theme styles are very specific.

src/material-experimental/mdc-menu/menu.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// The CDK positioning uses flexbox to anchor the element, whereas MDC uses `position: absolute`.
2424
position: static;
2525

26-
@include cdk-high-contrast {
26+
@include cdk-high-contrast(active, off) {
2727
outline: solid 1px;
2828
}
2929
}
@@ -75,7 +75,7 @@
7575
}
7676
}
7777

78-
@include cdk-high-contrast {
78+
@include cdk-high-contrast(active, off) {
7979
&.cdk-program-focused,
8080
&.cdk-keyboard-focused,
8181
&-highlighted {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
}
5656

5757

58-
@include cdk-high-contrast {
58+
@include cdk-high-contrast(active, off) {
5959
.mat-mdc-slide-toggle-focused {
6060
.mdc-switch__track {
6161
// Usually 1px would be enough, but MDC reduces the opacity on the

src/material-experimental/mdc-slider/slider.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $mat-slider-horizontal-margin: 8px !default;
2626
width: auto;
2727
min-width: $mat-slider-min-size - (2 * $mat-slider-horizontal-margin);
2828

29-
@include cdk-high-contrast {
29+
@include cdk-high-contrast(active, off) {
3030
// The slider track isn't visible in high contrast mode so we work
3131
// around it by setting an outline and removing the height to make it look solid.
3232
.mdc-slider__track-container {

src/material-experimental/popover-edit/_popover-edit.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
display: block;
8282
padding: 16px 24px;
8383

84-
@include cdk-high-contrast {
84+
@include cdk-high-contrast(active, off) {
8585
// Note that normally we use 1px for high contrast outline, however here we use 3,
8686
// because the popover is rendered on top of a table which already has some borders
8787
// and doesn't have a backdrop. The thicker outline makes it easier to differentiate.

src/material/autocomplete/autocomplete.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $mat-autocomplete-panel-border-radius: 4px !default;
3838
margin-top: -1px;
3939
}
4040

41-
@include cdk-high-contrast {
41+
@include cdk-high-contrast(active, off) {
4242
outline: solid 1px;
4343
}
4444
}

src/material/badge/_badge-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ $mat-badge-large-size: $mat-badge-default-size + 6;
9898
color: mat-color($primary, default-contrast);
9999
background: mat-color($primary);
100100

101-
@include cdk-high-contrast {
101+
@include cdk-high-contrast(active, off) {
102102
outline: solid 1px;
103103
border-radius: 0;
104104
}

src/material/bottom-sheet/bottom-sheet-container.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $mat-bottom-sheet-container-horizontal-padding: 16px !default;
1717
max-height: 80vh;
1818
overflow: auto;
1919

20-
@include cdk-high-contrast {
20+
@include cdk-high-contrast(active, off) {
2121
outline: 1px solid;
2222
}
2323
}

0 commit comments

Comments
 (0)