Skip to content

Commit 2103907

Browse files
willshowelltinayuangao
authored andcommitted
fix(input): correct invalid colors (#4771)
* fix(input): correct invalid colors - Make ripple & placeholder use warn color even with .mat-accent class - Make req'd asterisk warn color whenever input is invalid * Address comments
1 parent 9e2a66c commit 2103907

File tree

3 files changed

+33
-11
lines changed

3 files changed

+33
-11
lines changed

src/demo-app/input/input-demo.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,20 @@ <h4>Textarea</h4>
140140
<md-input-container color="warn">
141141
<textarea mdInput placeholder="Warn Color">example</textarea>
142142
</md-input-container>
143+
144+
<h4>With error</h4>
145+
<md-input-container color="primary" >
146+
<input mdInput placeholder="Default Color" [(ngModel)]="dividerColorExample1" required>
147+
<md-error>This field is required</md-error>
148+
</md-input-container>
149+
<md-input-container color="accent">
150+
<input mdInput placeholder="Accent Color" [(ngModel)]="dividerColorExample2" required>
151+
<md-error>This field is required</md-error>
152+
</md-input-container>
153+
<md-input-container color="warn">
154+
<input mdInput placeholder="Warn Color" [(ngModel)]="dividerColorExample3" required>
155+
<md-error>This field is required</md-error>
156+
</md-input-container>
143157
</md-card-content>
144158
</md-card>
145159

src/demo-app/input/input-demo.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export class InputDemo {
2323
errorMessageExample1: string;
2424
errorMessageExample2: string;
2525
errorMessageExample3: string;
26+
dividerColorExample1: string;
27+
dividerColorExample2: string;
28+
dividerColorExample3: string;
2629
items: any[] = [
2730
{ value: 10 },
2831
{ value: 20 },

src/lib/input/_input-theme.scss

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
color: mat-color($foreground, disabled-text);
4343
}
4444

45-
// See mat-input-placeholder-floating mixin in input.scss
45+
// See mat-input-placeholder-floating mixin in input-container.scss
4646
input.mat-input-element:-webkit-autofill + .mat-input-placeholder,
4747
.mat-focused .mat-input-placeholder.mat-float {
4848
.mat-placeholder-required {
@@ -52,26 +52,31 @@
5252

5353
.mat-input-underline {
5454
border-color: $input-underline-color;
55+
}
5556

56-
.mat-input-ripple {
57-
background-color: $input-underline-focused-color;
57+
.mat-input-ripple {
58+
background-color: $input-underline-focused-color;
5859

59-
&.mat-accent {
60-
background-color: $input-underline-color-accent;
61-
}
62-
&.mat-warn {
63-
background-color: $input-underline-color-warn;
64-
}
60+
&.mat-accent {
61+
background-color: $input-underline-color-accent;
62+
}
63+
64+
&.mat-warn {
65+
background-color: $input-underline-color-warn;
6566
}
6667
}
6768

6869
// Styling for the error state of the input container. Note that while the same can be
6970
// achieved with the ng-* classes, we use this approach in order to ensure that the same
7071
// logic is used to style the error state and to show the error messages.
7172
.mat-input-invalid {
72-
.mat-input-placeholder,
73-
.mat-placeholder-required {
73+
.mat-input-placeholder {
7474
color: $input-underline-color-warn;
75+
76+
&.mat-accent,
77+
&.mat-float .mat-placeholder-required {
78+
color: $input-underline-color-warn;
79+
}
7580
}
7681

7782
.mat-input-ripple {

0 commit comments

Comments
 (0)