Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit d68f8a7

Browse files
authored
feat(list): Add mixin for disabled text opacity (#4861)
1 parent 747f6ed commit d68f8a7

File tree

4 files changed

+26
-15
lines changed

4 files changed

+26
-15
lines changed

packages/mdc-list/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ Mixin | Description
411411
`mdc-list-item-shape-radius($radius, $rtl-reflexive)` | Sets the rounded shape to list item with given radius size. Set `$rtl-reflexive` to true to flip radius values in RTL context, defaults to false.
412412
`mdc-list-divider-color($color)` | Sets divider ink color.
413413
`mdc-list-group-subheader-ink-color($color)` | Sets ink color of subheader text within list group.
414+
`mdc-list-item-disabled-text-color($color`) | Sets the color of the text when the list item is disabled.
415+
`mdc-list-item-disabled-text-opacity($opacity`) | Sets the opacity of the text when the list item is disabled.
414416

415417
### Accessibility
416418

packages/mdc-list/_mixins.scss

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363
@include mdc-list-item-graphic-ink-color(text-icon-on-background, $query);
6464
@include mdc-list-item-meta-ink-color(text-hint-on-background, $query);
6565
@include mdc-list-group-subheader-ink-color(text-primary-on-background, $query);
66+
@include mdc-list-item-disabled-text-opacity($mdc-list-text-disabled-opacity, $query);
67+
@include mdc-list-item-disabled-text-color($mdc-list-text-disabled-color, $query);
6668

6769
.mdc-list--dense {
6870
@include mdc-feature-targets($feat-structure) {
@@ -86,10 +88,6 @@
8688
@include mdc-list-item-graphic-ink-color(primary, $query);
8789
}
8890

89-
.mdc-list-item--disabled {
90-
@include mdc-list-item-primary-text-ink-color(text-disabled-on-background, $query);
91-
}
92-
9391
.mdc-list-item__graphic {
9492
@include mdc-feature-targets($feat-structure) {
9593
@include mdc-list-graphic-size_(24px);
@@ -393,6 +391,26 @@
393391
}
394392
}
395393

394+
@mixin mdc-list-item-disabled-text-opacity($opacity, $query: mdc-feature-all()) {
395+
$feat-color: mdc-feature-create-target($query, color);
396+
397+
.mdc-list-item--disabled .mdc-list-item__text {
398+
@include mdc-feature-targets($feat-color) {
399+
opacity: $opacity;
400+
}
401+
}
402+
}
403+
404+
@mixin mdc-list-item-disabled-text-color($color, $query: mdc-feature-all()) {
405+
$feat-color: mdc-feature-create-target($query, color);
406+
407+
.mdc-list-item--disabled .mdc-list-item__text {
408+
@include mdc-feature-targets($feat-color) {
409+
@include mdc-theme-prop(color, $color);
410+
}
411+
}
412+
}
413+
396414
//
397415
// Private
398416
//

packages/mdc-list/_variables.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ $mdc-list-divider-color-on-light-bg: rgba(0, 0, 0, .12) !default;
2222
$mdc-list-divider-color-on-dark-bg: rgba(255, 255, 255, .2) !default;
2323
$mdc-list-side-padding: 16px !default;
2424
$mdc-list-text-offset: 72px !default;
25+
$mdc-list-text-disabled-opacity: mdc-theme-text-emphasis(disabled) !default;
26+
$mdc-list-text-disabled-color: on-surface !default;

packages/mdc-menu/_mixins.scss

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,6 @@
6666
}
6767
}
6868

69-
// Target Windows high-contrast mode.
70-
@media screen and (-ms-high-contrast: active) {
71-
.mdc-list-item--disabled {
72-
@include mdc-feature-targets($feat-structure) {
73-
// Decrease opacity of the list item, not just the text color,
74-
// or disabled items won't be differentiated in high contrast mode.
75-
opacity: mdc-theme-text-emphasis(disabled);
76-
}
77-
}
78-
}
79-
8069
//stylelint-disable selector-no-qualifying-type
8170
a.mdc-list-item .mdc-list-item__text,
8271
a.mdc-list-item .mdc-list-item__graphic {

0 commit comments

Comments
 (0)