Skip to content

Commit 266f237

Browse files
crisbetokara
authored andcommitted
fix(input,select): align colors with spec (#5155)
Fixes #5114.
1 parent eabe2cb commit 266f237

File tree

5 files changed

+27
-17
lines changed

5 files changed

+27
-17
lines changed

src/lib/core/style/_form-common.scss

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
1-
2-
// Gradient for showing the dashed line when the input is disabled.
1+
// Renders a gradient for showing the dashed line when the input is disabled.
32
// Unlike using a border, a gradient allows us to adjust the spacing of the dotted line
43
// to match the Material Design spec.
5-
$mat-underline-disabled-background-image:
6-
linear-gradient(to right, rgba(0, 0, 0, 0.26) 0%, rgba(0, 0, 0, 0.26) 33%, transparent 0%);
7-
8-
@mixin mat-control-disabled-underline {
9-
background-image: $mat-underline-disabled-background-image;
4+
@mixin mat-control-disabled-underline($color) {
5+
background-image: linear-gradient(to right, $color 0%, $color 33%, transparent 0%);
106
background-size: 4px 1px;
117
background-repeat: repeat-x;
128
}

src/lib/input/_input-theme.scss

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import '../core/theming/palette';
22
@import '../core/theming/theming';
3+
@import '../core/style/form-common';
34
@import '../core/typography/typography-utils';
45

56

@@ -9,14 +10,15 @@
910
$warn: map-get($theme, warn);
1011
$background: map-get($theme, background);
1112
$foreground: map-get($theme, foreground);
13+
$is-dark-theme: map-get($theme, is-dark);
1214

1315
// Placeholder colors. Required is used for the `*` star shown in the placeholder.
14-
$input-placeholder-color: mat-color($foreground, hint-text);
16+
$input-placeholder-color: mat-color($foreground, secondary-text);
1517
$input-floating-placeholder-color: mat-color($primary);
1618
$input-required-placeholder-color: mat-color($accent);
1719

1820
// Underline colors.
19-
$input-underline-color: mat-color($foreground, divider);
21+
$input-underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.7, 0.42));
2022
$input-underline-color-accent: mat-color($accent);
2123
$input-underline-color-warn: mat-color($warn);
2224
$input-underline-focused-color: mat-color($primary);
@@ -25,6 +27,10 @@
2527
color: $input-placeholder-color;
2628
}
2729

30+
.mat-hint {
31+
color: mat-color($foreground, secondary-text);
32+
}
33+
2834
// :focus is applied to the input, but we apply mat-focused to the other elements
2935
// that need to listen to it.
3036
.mat-focused .mat-input-placeholder {
@@ -40,7 +46,7 @@
4046
}
4147

4248
.mat-input-element:disabled {
43-
color: mat-color($foreground, disabled-text);
49+
color: mat-color($foreground, secondary-text, if($is-dark-theme, 0.7, 0.42));
4450
}
4551

4652
// See _mat-input-placeholder-floating mixin in input-container.scss
@@ -53,6 +59,10 @@
5359

5460
.mat-input-underline {
5561
background-color: $input-underline-color;
62+
63+
&.mat-disabled {
64+
@include mat-control-disabled-underline($input-underline-color);
65+
}
5666
}
5767

5868
.mat-input-ripple {

src/lib/input/input-container.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import '../core/style/variables';
22
@import '../core/style/vendor-prefixes';
3-
@import '../core/style/form-common';
43

54

65
// Min amount of space between start and end hint.
@@ -201,7 +200,6 @@ textarea.mat-input-element {
201200
width: 100%;
202201

203202
&.mat-disabled {
204-
@include mat-control-disabled-underline();
205203
background-position: 0;
206204
background-color: transparent;
207205
}

src/lib/select/_select-theme.scss

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@import '../core/theming/palette';
22
@import '../core/theming/theming';
3+
@import '../core/style/form-common';
34
@import '../core/typography/typography-utils';
45

56
@mixin _mat-select-inner-content-theme($palette) {
@@ -20,20 +21,27 @@
2021
$primary: map-get($theme, primary);
2122
$accent: map-get($theme, accent);
2223
$warn: map-get($theme, warn);
24+
$is-dark-theme: map-get($theme, is-dark);
25+
$underline-color: mat-color($foreground, divider, if($is-dark-theme, 0.7, 0.42));
2326

2427
.mat-select-trigger,
2528
.mat-select-arrow {
26-
color: mat-color($foreground, hint-text);
29+
color: mat-color($foreground, secondary-text);
2730
}
2831

2932
.mat-select-underline {
30-
background-color: mat-color($foreground, divider);
33+
background-color: $underline-color;
34+
}
35+
36+
[aria-disabled='true'] .mat-select-underline {
37+
// Since this is a dotted line, we need to make it slightly darker to get it to stand out.
38+
@include mat-control-disabled-underline($underline-color);
3139
}
3240

3341
.mat-select-disabled .mat-select-value,
3442
.mat-select-arrow,
3543
.mat-select-trigger {
36-
color: mat-color($foreground, hint-text);
44+
color: mat-color($foreground, secondary-text);
3745
}
3846

3947
.mat-select-content, .mat-select-panel-done-animating {

src/lib/select/select.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@import '../core/style/menu-common';
22
@import '../core/style/list-common';
3-
@import '../core/style/form-common';
43
@import '../core/style/variables';
54
@import '../core/style/vendor-prefixes';
65
@import '../core/a11y/a11y';
@@ -44,7 +43,6 @@ $mat-select-trigger-underline-height: 1px !default;
4443
}
4544

4645
.mat-select-disabled & {
47-
@include mat-control-disabled-underline();
4846
background-color: transparent;
4947
background-position: 0 bottom;
5048
}

0 commit comments

Comments
 (0)