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: reduce amount of generated high contrast styles #18332

Merged
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
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
.mat-mdc-fab,
.mat-mdc-mini-fab,
.mat-mdc-icon-button {
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ $mat-card-default-padding: 16px !default;
// Add styles to the root card to have an outline in high-contrast mode.
// TODO(jelbourn): file bug for MDC supporting high-contrast mode on `.mdc-card`.
.mat-mdc-card {
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-chips/chips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
transition-duration: 1ms;
}

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

&:focus {
Expand Down Expand Up @@ -79,7 +79,7 @@ input.mat-mdc-chip-input {
}

.mdc-chip__checkmark-path {
@include cdk-high-contrast(black-on-white) {
@include cdk-high-contrast(black-on-white, off) {
// SVG colors won't be changed in high contrast mode and since the checkmark is white
// by default, it'll blend in with the background in black-on-white mode. Override the color
// to ensure that it's visible. We need !important, because the theme styles are very specific.
Expand Down
4 changes: 2 additions & 2 deletions src/material-experimental/mdc-menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// The CDK positioning uses flexbox to anchor the element, whereas MDC uses `position: absolute`.
position: static;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@
}
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
&.cdk-program-focused,
&.cdk-keyboard-focused,
&-highlighted {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
}


@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
.mat-mdc-slide-toggle-focused {
.mdc-switch__track {
// Usually 1px would be enough, but MDC reduces the opacity on the
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/mdc-slider/slider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $mat-slider-horizontal-margin: 8px !default;
width: auto;
min-width: $mat-slider-min-size - (2 * $mat-slider-horizontal-margin);

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
// The slider track isn't visible in high contrast mode so we work
// around it by setting an outline and removing the height to make it look solid.
.mdc-slider__track-container {
Expand Down
2 changes: 1 addition & 1 deletion src/material-experimental/popover-edit/_popover-edit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
display: block;
padding: 16px 24px;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
// Note that normally we use 1px for high contrast outline, however here we use 3,
// because the popover is rendered on top of a table which already has some borders
// and doesn't have a backdrop. The thicker outline makes it easier to differentiate.
Expand Down
2 changes: 1 addition & 1 deletion src/material/autocomplete/autocomplete.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $mat-autocomplete-panel-border-radius: 4px !default;
margin-top: -1px;
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/badge/_badge-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ $mat-badge-large-size: $mat-badge-default-size + 6;
color: mat-color($primary, default-contrast);
background: mat-color($primary);

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
border-radius: 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/bottom-sheet/bottom-sheet-container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $mat-bottom-sheet-container-horizontal-padding: 16px !default;
max-height: 80vh;
overflow: auto;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: 1px solid;
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/material/button-toggle/button-toggle.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
border-radius: $mat-button-toggle-legacy-border-radius;
-webkit-tap-highlight-color: transparent;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand All @@ -29,7 +29,7 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
.mat-button-toggle-group-appearance-standard {
border-radius: $mat-button-toggle-standard-border-radius;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: 0;
}
}
Expand Down Expand Up @@ -58,7 +58,7 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
opacity: 1;

// In high contrast mode `opacity: 1` will show the overlay as solid so we fall back 0.5.
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
opacity: 0.5;
}
}
Expand All @@ -78,7 +78,7 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
&.cdk-keyboard-focused:not(.mat-button-toggle-disabled) .mat-button-toggle-focus-overlay {
opacity: 0.12;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
opacity: 0.5;
}
}
Expand Down Expand Up @@ -128,14 +128,14 @@ $mat-button-toggle-legacy-border-radius: 2px !default;
// Changing the background color for the selected item won't be visible in high contrast mode.
// We fall back to using the overlay to draw a brighter, semi-transparent tint on top instead.
// It uses a border, because the browser will render it using a brighter color.
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
opacity: 0.5;
height: 0;
}
}
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
.mat-button-toggle-checked {
&.mat-button-toggle-appearance-standard .mat-button-toggle-focus-overlay {
border-bottom: solid $mat-button-toggle-standard-height;
Expand Down
6 changes: 3 additions & 3 deletions src/material/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@
transition: none;
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
// Note that IE will render this in the same way, no
// matter whether the theme is light or dark. This helps
// with the readability of focused buttons.
background-color: #fff;
}

@include cdk-high-contrast(black-on-white) {
@include cdk-high-contrast(black-on-white, off) {
// For the black-on-white high contrast mode, the browser will set this element
// to white, making it blend in with the background, hence why we need to set
// it explicitly to black.
Expand Down Expand Up @@ -167,7 +167,7 @@

// Add an outline to make buttons more visible in high contrast mode. Stroked buttons
// don't need a special look in high-contrast mode, because those already have an outline.
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
.mat-button, .mat-flat-button, .mat-raised-button, .mat-icon-button, .mat-fab, .mat-mini-fab {
outline: solid 1px;
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/card/card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $mat-card-header-size: 40px !default;
}
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/material/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
transition: none;
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
// Note that we change the border style of the checkbox frame to dotted because this
// is how IE/Edge similarly treats native checkboxes in high contrast mode.
.mat-checkbox.cdk-keyboard-focused & {
Expand All @@ -279,7 +279,7 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
// `.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 {
@include cdk-high-contrast(active, off) {
// Needs to be removed because it hides the checkbox outline.
background: none;
}
Expand Down Expand Up @@ -329,7 +329,7 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
width: $_mat-checkbox-mark-stroke-size;
}

@include cdk-high-contrast(black-on-white) {
@include cdk-high-contrast(black-on-white, off) {
// 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;
Expand All @@ -345,7 +345,7 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
transform: scaleX(0) rotate(0deg);
border-radius: 2px;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
height: 0;
border-top: solid $height;
margin-top: $height;
Expand Down Expand Up @@ -409,7 +409,7 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
.mat-checkbox-disabled {
cursor: default;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
opacity: 0.5;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/chips/chips.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ $mat-chip-remove-size: 18px;
}
}

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

&:focus {
Expand Down
4 changes: 2 additions & 2 deletions src/material/core/option/option.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
$high-contrast-border-width: 1px;

// Add a margin to offset the border that we're adding to active option, in order
Expand Down Expand Up @@ -69,7 +69,7 @@
pointer-events: none;

// Prevents the ripple from completely covering the option in high contrast mode.
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
opacity: 0.5;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/core/ripple/_ripple.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ $mat-ripple-color-opacity: 0.1;
transform: scale(0);

// In high contrast mode the ripple is opaque, causing it to obstruct the content.
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
display: none;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/material/datepicker/calendar-body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ $mat-calendar-body-cell-content-size: 100% - $mat-calendar-body-cell-content-mar
// Choosing a value clearly larger than the height ensures we get the correct capsule shape.
border-radius: 999px;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
border: none;
}
}


@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
.mat-datepicker-popup:not(:empty),
.mat-calendar-body-selected {
outline: solid 1px;
Expand Down
2 changes: 1 addition & 1 deletion src/material/dialog/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $mat-dialog-button-margin: 8px !default;
min-height: inherit;
max-height: inherit;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/expansion/expansion-panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
}

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}

Expand Down
4 changes: 2 additions & 2 deletions src/material/form-field/form-field-fill.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ $mat-form-field-fill-subscript-padding:
padding: $mat-form-field-fill-line-spacing $mat-form-field-fill-side-padding 0
$mat-form-field-fill-side-padding;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
outline: solid 1px;
}
}
Expand All @@ -46,7 +46,7 @@ $mat-form-field-fill-subscript-padding:
bottom: 0;
height: $mat-form-field-fill-underline-ripple-height;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
height: 0;
border-top: solid $mat-form-field-fill-underline-ripple-height;
}
Expand Down
2 changes: 1 addition & 1 deletion src/material/form-field/form-field-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ select.mat-input-element {
// as the background, however this causes it blend in because we've reset the `background`
// above. We have to add a more specific selector in order to ensure that it gets the
// `color` from our theme instead.
@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
.mat-focused & {
color: inherit;
}
Expand Down
6 changes: 3 additions & 3 deletions src/material/form-field/form-field-legacy.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ $mat-form-field-legacy-underline-height: 1px !default;
.mat-form-field-underline {
height: $mat-form-field-legacy-underline-height;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
height: 0;
border-top: solid $mat-form-field-legacy-underline-height;
}
Expand All @@ -53,7 +53,7 @@ $mat-form-field-legacy-underline-height: 1px !default;
// the desired form-field ripple height. See: angular/components#6351
overflow: hidden;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
height: 0;
border-top: solid $height;
}
Expand All @@ -63,7 +63,7 @@ $mat-form-field-legacy-underline-height: 1px !default;
background-position: 0;
background-color: transparent;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
border-top-style: dotted;
border-top-width: 2px;
}
Expand Down
6 changes: 3 additions & 3 deletions src/material/form-field/form-field-standard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ $mat-form-field-standard-padding-top: 0.75em !default;
.mat-form-field-underline {
height: $mat-form-field-standard-underline-height;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
height: 0;
border-top: solid $mat-form-field-standard-underline-height;
}
Expand All @@ -33,7 +33,7 @@ $mat-form-field-standard-padding-top: 0.75em !default;
bottom: 0;
height: $height;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
height: 0;
border-top: $height;
}
Expand All @@ -43,7 +43,7 @@ $mat-form-field-standard-padding-top: 0.75em !default;
background-position: 0;
background-color: transparent;

@include cdk-high-contrast {
@include cdk-high-contrast(active, off) {
border-top-style: dotted;
border-top-width: 2px;
}
Expand Down
Loading