Skip to content

Commit

Permalink
fix(select): Update colors to match latest guidance. (#2617)
Browse files Browse the repository at this point in the history
  • Loading branch information
williamernest committed Apr 20, 2018
1 parent 0f5af21 commit 5aa7ec7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion demos/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// stylelint-disable selector-class-pattern
.demo-select-custom-colors {
@include mdc-select-ink-color(blue);
@include mdc-select-label-color(blue, .6);
@include mdc-select-label-color(rgba(blue, .6));
@include mdc-select-bottom-line-color(rgba(blue, .5));

// Focused colors
Expand Down
4 changes: 2 additions & 2 deletions packages/mdc-select/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ Mixin | Description
--- | ---
`mdc-select-ink-color($color)` | Customizes the color of the selected item displayed in the select.
`mdc-select-container-fill-color($color)` | Customizes the background color of the select.
`mdc-select-label-color($color, $opacity: 1)` | Customizes the label color of the select in the unfocused state.
`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.
`mdc-select-label-color($color)` | Customizes the label color of the select in the unfocused state.
`mdc-select-focused-label-color($color)` | Customizes the label color of the select when focused.
`mdc-select-bottom-line-color($color)` | Customizes the color of the default bottom line of the select.
`mdc-select-focused-bottom-line-color($color)` | Customizes the color of the bottom line of the select when focused.
`mdc-select-hover-bottom-line-color($color)` | Customizes the color of the bottom line when select is hovered.
Expand Down
8 changes: 4 additions & 4 deletions packages/mdc-select/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
}
}

@mixin mdc-select-focused-label-color($color, $opacity: .87) {
@mixin mdc-select-focused-label-color($color) {
&:not(.mdc-select--disabled) {
.mdc-select__native-control:focus ~ .mdc-floating-label {
@include mdc-floating-label-ink-color(rgba(mdc-theme-prop-value($color), $opacity));
@include mdc-floating-label-ink-color(mdc-theme-prop-value($color));
}
}
}
Expand All @@ -58,9 +58,9 @@
}
}

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

Expand Down
13 changes: 13 additions & 0 deletions packages/mdc-select/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,16 @@

$mdc-select-arrow-padding: 26px;
$mdc-select-label-padding: 16px;

$mdc-select-ink-color: rgba(mdc-theme-prop-value(on-surface), .87);
$mdc-select-disabled-ink-color: rgba(mdc-theme-prop-value(on-surface), .37);

$mdc-select-label-color: rgba(mdc-theme-prop-value(on-surface), .6);
$mdc-select-focused-label-color: rgba(mdc-theme-prop-value(primary), .87);
$mdc-select-disabled-label-color: rgba(mdc-theme-prop-value(on-surface), .37);

$mdc-select-bottom-line-idle-color: rgba(mdc-theme-prop-value(on-surface), .42);
$mdc-select-bottom-line-hover-color: rgba(mdc-theme-prop-value(on-surface), .87);

$mdc-select-box-fill-color: mix(mdc-theme-prop-value(on-surface), mdc-theme-prop-value(surface), 4%);
$mdc-select-box-disabled-fill-color: mix(mdc-theme-prop-value(on-surface), mdc-theme-prop-value(surface), 2%);
27 changes: 15 additions & 12 deletions packages/mdc-select/mdc-select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
@include mdc-typography-base;
@include mdc-select-container-fill-color(transparent);
@include mdc-select-dd-arrow-svg-bg_;
@include mdc-select-ink-color(text-primary-on-light);
@include mdc-select-label-color(black, .6);
@include mdc-select-bottom-line-color(rgba(black, .5));
@include mdc-select-ink-color($mdc-select-ink-color);
@include mdc-select-label-color($mdc-select-label-color);
@include mdc-select-bottom-line-color($mdc-select-bottom-line-idle-color);

// Focused state colors
@include mdc-select-focused-bottom-line-color(primary);
@include mdc-select-focused-label-color(primary);
@include mdc-select-focused-label-color($mdc-select-focused-label-color);

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

display: inline-flex;
position: relative;
Expand Down Expand Up @@ -93,14 +93,14 @@
}

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

Expand Down Expand Up @@ -135,11 +135,14 @@
}

.mdc-select--disabled {
@include mdc-select-dd-arrow-svg-bg_(000000, .38);
@include mdc-select-container-fill-color_(transparent);
@include mdc-select-dd-arrow-svg-bg_($mdc-select-disabled-ink-color);

&.mdc-select--box {
@include mdc-select-container-fill-color_($mdc-select-box-disabled-fill-color);
}

.mdc-floating-label {
@include mdc-floating-label-ink-color(text-disabled-on-light);
@include mdc-floating-label-ink-color($mdc-select-disabled-label-color);
}

// stylelint-disable plugin/selector-bem-pattern
Expand Down

0 comments on commit 5aa7ec7

Please sign in to comment.