Skip to content

Commit

Permalink
fix(input): correct invalid colors (#4771)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
willshowell authored and tinayuangao committed May 26, 2017
1 parent 9e2a66c commit 2103907
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
14 changes: 14 additions & 0 deletions src/demo-app/input/input-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,20 @@ <h4>Textarea</h4>
<md-input-container color="warn">
<textarea mdInput placeholder="Warn Color">example</textarea>
</md-input-container>

<h4>With error</h4>
<md-input-container color="primary" >
<input mdInput placeholder="Default Color" [(ngModel)]="dividerColorExample1" required>
<md-error>This field is required</md-error>
</md-input-container>
<md-input-container color="accent">
<input mdInput placeholder="Accent Color" [(ngModel)]="dividerColorExample2" required>
<md-error>This field is required</md-error>
</md-input-container>
<md-input-container color="warn">
<input mdInput placeholder="Warn Color" [(ngModel)]="dividerColorExample3" required>
<md-error>This field is required</md-error>
</md-input-container>
</md-card-content>
</md-card>

Expand Down
3 changes: 3 additions & 0 deletions src/demo-app/input/input-demo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export class InputDemo {
errorMessageExample1: string;
errorMessageExample2: string;
errorMessageExample3: string;
dividerColorExample1: string;
dividerColorExample2: string;
dividerColorExample3: string;
items: any[] = [
{ value: 10 },
{ value: 20 },
Expand Down
27 changes: 16 additions & 11 deletions src/lib/input/_input-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
color: mat-color($foreground, disabled-text);
}

// See mat-input-placeholder-floating mixin in input.scss
// See mat-input-placeholder-floating mixin in input-container.scss
input.mat-input-element:-webkit-autofill + .mat-input-placeholder,
.mat-focused .mat-input-placeholder.mat-float {
.mat-placeholder-required {
Expand All @@ -52,26 +52,31 @@

.mat-input-underline {
border-color: $input-underline-color;
}

.mat-input-ripple {
background-color: $input-underline-focused-color;
.mat-input-ripple {
background-color: $input-underline-focused-color;

&.mat-accent {
background-color: $input-underline-color-accent;
}
&.mat-warn {
background-color: $input-underline-color-warn;
}
&.mat-accent {
background-color: $input-underline-color-accent;
}

&.mat-warn {
background-color: $input-underline-color-warn;
}
}

// Styling for the error state of the input container. Note that while the same can be
// achieved with the ng-* classes, we use this approach in order to ensure that the same
// logic is used to style the error state and to show the error messages.
.mat-input-invalid {
.mat-input-placeholder,
.mat-placeholder-required {
.mat-input-placeholder {
color: $input-underline-color-warn;

&.mat-accent,
&.mat-float .mat-placeholder-required {
color: $input-underline-color-warn;
}
}

.mat-input-ripple {
Expand Down

0 comments on commit 2103907

Please sign in to comment.