Skip to content

Commit

Permalink
feat(dom): add forced-colors-mode mixin
Browse files Browse the repository at this point in the history
BREAKING_CHANGE: ie-high-contrast-mode has been removed in favor of forced-colors-mode
PiperOrigin-RevId: 378027927
  • Loading branch information
asyncLiz authored and Copybara-Service committed Jun 7, 2021
1 parent e853479 commit 8416fb9
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 14 deletions.
3 changes: 2 additions & 1 deletion packages/mdc-checkbox/_checkbox.scss
Expand Up @@ -28,6 +28,7 @@
@use '@material/animation/functions' as functions2;
@use '@material/animation/variables' as animation-variables;
@use '@material/density/functions' as density-functions;
@use '@material/dom/dom';
@use '@material/feature-targeting/feature-targeting';
@use '@material/ripple/ripple';
@use '@material/ripple/ripple-theme';
Expand Down Expand Up @@ -77,7 +78,7 @@
}
}

@media screen and (-ms-high-contrast: active) {
@include dom.forced-colors-mode {
@include checkbox-theme.disabled-container-colors(
$unmarked-stroke-color: GrayText,
$unmarked-fill-color: transparent,
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-chips/_chip.scss
Expand Up @@ -418,7 +418,7 @@
@mixin _high-contrast-mode($query: feature-targeting.all()) {
$feat-structure: feature-targeting.create-target($query, structure);

@include dom.ie-high-contrast-mode {
@include dom.forced-colors-mode {
@include chip-theme.outline-color(
(
disabled: GrayText,
Expand Down
4 changes: 2 additions & 2 deletions packages/mdc-dialog/_mixins.scss
Expand Up @@ -150,8 +150,8 @@
text-align: right;
}

@include dom.ie-high-contrast-mode {
// Colored outline is used for IE11 HCM instead of transparent border
@include dom.forced-colors-mode {
// Colored outline is used for HCM instead of transparent border
// below to prevent scrolling content overflow.
outline: 2px solid windowText;
}
Expand Down
11 changes: 7 additions & 4 deletions packages/mdc-dom/_dom.scss
Expand Up @@ -67,12 +67,15 @@
}
}

/// Selects for `forced-colors` high contrast mode.
///
/// Selects for high-contrast mode. Currently this only detects high-contrast
/// mode in IE and Edge.
/// While in `forced-colors` mode, only system colors should be used.
///
@mixin ie-high-contrast-mode {
@media screen and (-ms-high-contrast: active) {
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#system_colors
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/@media/forced-colors
/// @content styles to emit in `forced-colors` mode
@mixin forced-colors-mode {
@media screen and (forced-colors: active), (-ms-high-contrast: active) {
@content;
}
}
2 changes: 1 addition & 1 deletion packages/mdc-dom/_mixins.scss
Expand Up @@ -19,4 +19,4 @@
// THE SOFTWARE.

/// @deprecated Import '_dom.scss' instead.
@forward './dom' show transparent-border, visually-hidden, ie-high-contrast-mode;
@forward './dom' show transparent-border, visually-hidden, forced-colors-mode;
2 changes: 1 addition & 1 deletion packages/mdc-list/_evolution-mixins.scss
Expand Up @@ -1185,7 +1185,7 @@
$feat-structure: feature-targeting.create-target($query, structure);
$feat-color: feature-targeting.create-target($query, color);

@include dom-mixins.ie-high-contrast-mode {
@include dom-mixins.forced-colors-mode {
.mdc-list-divider::after {
@include feature-targeting.targets($feat-structure) {
content: '';
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-radio/_radio.scss
Expand Up @@ -250,7 +250,7 @@ $ripple-target: radio-theme.$ripple-target;
);
@include radio-theme.density(radio-theme.$density-scale, $query: $query);

@include dom.ie-high-contrast-mode {
@include dom.forced-colors-mode {
@include radio-theme.disabled-unchecked-stroke-color(
GrayText,
$query: $query
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-select/_select.scss
Expand Up @@ -93,7 +93,7 @@
);

// High-contrast mode support
@include dom-mixins.ie-high-contrast-mode() {
@include dom-mixins.forced-colors-mode() {
$gray-text: (
disabled: GrayText,
);
Expand Down
2 changes: 1 addition & 1 deletion packages/mdc-switch/styles.scss
Expand Up @@ -33,7 +33,7 @@
@include switch-theme.theme(switch-theme.$light-theme);
}

@include dom.ie-high-contrast-mode {
@include dom.forced-colors-mode {
.mdc-switch {
@include switch-theme.theme(switch-theme.$forced-colors-theme);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/mdc-textfield/_mixins.scss
Expand Up @@ -29,6 +29,7 @@
@use 'sass:meta';
@use '@material/animation/animation';
@use '@material/density/functions' as density-functions;
@use '@material/dom/dom';
@use '@material/floating-label/mixins' as floating-label-mixins;
@use '@material/floating-label/variables' as floating-label-variables;
@use '@material/line-ripple/mixins' as line-ripple-mixins;
Expand Down Expand Up @@ -1633,7 +1634,7 @@
$query: $query
);

@media screen and (-ms-high-contrast: active) {
@include dom.forced-colors-mode {
@include placeholder-color_(GrayText, $query: $query);
@include label-ink-color_(GrayText, $query: $query);
@include helper-text-mixins.helper-text-color_(GrayText, $query: $query);
Expand Down

0 comments on commit 8416fb9

Please sign in to comment.