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

Commit 5aa7ec7

Browse files
fix(select): Update colors to match latest guidance. (#2617)
1 parent 0f5af21 commit 5aa7ec7

File tree

5 files changed

+35
-19
lines changed

5 files changed

+35
-19
lines changed

demos/select.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
// stylelint-disable selector-class-pattern
2222
.demo-select-custom-colors {
2323
@include mdc-select-ink-color(blue);
24-
@include mdc-select-label-color(blue, .6);
24+
@include mdc-select-label-color(rgba(blue, .6));
2525
@include mdc-select-bottom-line-color(rgba(blue, .5));
2626

2727
// Focused colors

packages/mdc-select/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ Mixin | Description
164164
--- | ---
165165
`mdc-select-ink-color($color)` | Customizes the color of the selected item displayed in the select.
166166
`mdc-select-container-fill-color($color)` | Customizes the background color of the select.
167-
`mdc-select-label-color($color, $opacity: 1)` | Customizes the label color of the select in the unfocused state.
168-
`mdc-select-focused-label-color($color, $opacity: 0.87)` | Customizes the label color of the select when focused. Changing opacity for the label when floating is optional.
167+
`mdc-select-label-color($color)` | Customizes the label color of the select in the unfocused state.
168+
`mdc-select-focused-label-color($color)` | Customizes the label color of the select when focused.
169169
`mdc-select-bottom-line-color($color)` | Customizes the color of the default bottom line of the select.
170170
`mdc-select-focused-bottom-line-color($color)` | Customizes the color of the bottom line of the select when focused.
171171
`mdc-select-hover-bottom-line-color($color)` | Customizes the color of the bottom line when select is hovered.

packages/mdc-select/_mixins.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
}
3333
}
3434

35-
@mixin mdc-select-focused-label-color($color, $opacity: .87) {
35+
@mixin mdc-select-focused-label-color($color) {
3636
&:not(.mdc-select--disabled) {
3737
.mdc-select__native-control:focus ~ .mdc-floating-label {
38-
@include mdc-floating-label-ink-color(rgba(mdc-theme-prop-value($color), $opacity));
38+
@include mdc-floating-label-ink-color(mdc-theme-prop-value($color));
3939
}
4040
}
4141
}
@@ -58,9 +58,9 @@
5858
}
5959
}
6060

61-
@mixin mdc-select-label-color($color, $opacity: 1) {
61+
@mixin mdc-select-label-color($color) {
6262
&:not(.mdc-select--disabled) .mdc-floating-label {
63-
@include mdc-floating-label-ink-color(rgba(mdc-theme-prop-value($color), $opacity));
63+
@include mdc-floating-label-ink-color($color);
6464
}
6565
}
6666

packages/mdc-select/_variables.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,16 @@
1818

1919
$mdc-select-arrow-padding: 26px;
2020
$mdc-select-label-padding: 16px;
21+
22+
$mdc-select-ink-color: rgba(mdc-theme-prop-value(on-surface), .87);
23+
$mdc-select-disabled-ink-color: rgba(mdc-theme-prop-value(on-surface), .37);
24+
25+
$mdc-select-label-color: rgba(mdc-theme-prop-value(on-surface), .6);
26+
$mdc-select-focused-label-color: rgba(mdc-theme-prop-value(primary), .87);
27+
$mdc-select-disabled-label-color: rgba(mdc-theme-prop-value(on-surface), .37);
28+
29+
$mdc-select-bottom-line-idle-color: rgba(mdc-theme-prop-value(on-surface), .42);
30+
$mdc-select-bottom-line-hover-color: rgba(mdc-theme-prop-value(on-surface), .87);
31+
32+
$mdc-select-box-fill-color: mix(mdc-theme-prop-value(on-surface), mdc-theme-prop-value(surface), 4%);
33+
$mdc-select-box-disabled-fill-color: mix(mdc-theme-prop-value(on-surface), mdc-theme-prop-value(surface), 2%);

packages/mdc-select/mdc-select.scss

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
@include mdc-typography-base;
3131
@include mdc-select-container-fill-color(transparent);
3232
@include mdc-select-dd-arrow-svg-bg_;
33-
@include mdc-select-ink-color(text-primary-on-light);
34-
@include mdc-select-label-color(black, .6);
35-
@include mdc-select-bottom-line-color(rgba(black, .5));
33+
@include mdc-select-ink-color($mdc-select-ink-color);
34+
@include mdc-select-label-color($mdc-select-label-color);
35+
@include mdc-select-bottom-line-color($mdc-select-bottom-line-idle-color);
3636

3737
// Focused state colors
3838
@include mdc-select-focused-bottom-line-color(primary);
39-
@include mdc-select-focused-label-color(primary);
39+
@include mdc-select-focused-label-color($mdc-select-focused-label-color);
4040

4141
// Hover state colors
42-
@include mdc-select-hover-bottom-line-color(rgba(black, .87));
42+
@include mdc-select-hover-bottom-line-color($mdc-select-bottom-line-hover-color);
4343

4444
display: inline-flex;
4545
position: relative;
@@ -93,14 +93,14 @@
9393
}
9494

9595
.mdc-select--box {
96-
@include mdc-select-container-fill-color(rgba(black, .04));
96+
@include mdc-select-container-fill-color($mdc-select-box-fill-color);
9797
@include mdc-ripple-surface;
9898
@include mdc-ripple-radius-bounded;
9999
// Select Box intentionally omits press ripple, so each state needs to be specified individually
100-
@include mdc-states-base-color(text-primary-on-background);
101-
@include mdc-states-hover-opacity(mdc-states-opacity(text-primary-on-background, hover));
100+
@include mdc-states-base-color($mdc-select-ink-color);
101+
@include mdc-states-hover-opacity(mdc-states-opacity($mdc-select-ink-color, hover));
102102
@include mdc-states-focus-opacity(
103-
mdc-states-opacity(text-primary-on-background, focus),
103+
mdc-states-opacity($mdc-select-ink-color, focus),
104104
$has-nested-focusable-element: true
105105
);
106106

@@ -135,11 +135,14 @@
135135
}
136136

137137
.mdc-select--disabled {
138-
@include mdc-select-dd-arrow-svg-bg_(000000, .38);
139-
@include mdc-select-container-fill-color_(transparent);
138+
@include mdc-select-dd-arrow-svg-bg_($mdc-select-disabled-ink-color);
139+
140+
&.mdc-select--box {
141+
@include mdc-select-container-fill-color_($mdc-select-box-disabled-fill-color);
142+
}
140143

141144
.mdc-floating-label {
142-
@include mdc-floating-label-ink-color(text-disabled-on-light);
145+
@include mdc-floating-label-ink-color($mdc-select-disabled-label-color);
143146
}
144147

145148
// stylelint-disable plugin/selector-bem-pattern

0 commit comments

Comments
 (0)