Skip to content

Commit ce0cec3

Browse files
committed
add variants section to input demo
1 parent 9b0963d commit ce0cec3

File tree

4 files changed

+62
-1
lines changed

4 files changed

+62
-1
lines changed

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

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,3 +526,50 @@ <h3>&lt;textarea&gt; with ngModel</h3>
526526
</label>
527527
</mat-card-content>
528528
</mat-card>
529+
530+
<mat-card class="demo-card demo-basic">
531+
<mat-toolbar color="primary">Variants</mat-toolbar>
532+
<mat-card-content>
533+
<mat-form-field variant="legacy">
534+
<input matInput placeholder="example" [(ngModel)]="legacyVariant" required>
535+
<mat-error>This field is required</mat-error>
536+
<mat-hint>Please type something here</mat-hint>
537+
</mat-form-field>
538+
539+
<mat-form-field variant="standard">
540+
<input matInput placeholder="example" [(ngModel)]="standardVariant" required>
541+
<mat-error>This field is required</mat-error>
542+
<mat-hint>Please type something here</mat-hint>
543+
</mat-form-field>
544+
545+
<mat-form-field variant="box">
546+
<input matInput placeholder="example" [(ngModel)]="boxVariant" required>
547+
<mat-error>This field is required</mat-error>
548+
<mat-hint>Please type something here</mat-hint>
549+
</mat-form-field>
550+
551+
<table style="width: 100%" cellspacing="0"><tr>
552+
<td>
553+
<mat-form-field variant="legacy" style="width: 100%">
554+
<input matInput placeholder="example" [(ngModel)]="legacyVariant" required>
555+
<mat-error>This field is required</mat-error>
556+
<mat-hint>Please type something here</mat-hint>
557+
</mat-form-field>
558+
</td>
559+
<td>
560+
<mat-form-field variant="standard" style="width: 100%">
561+
<input matInput placeholder="example" [(ngModel)]="standardVariant" required>
562+
<mat-error>This field is required</mat-error>
563+
<mat-hint>Please type something here</mat-hint>
564+
</mat-form-field>
565+
</td>
566+
<td>
567+
<mat-form-field variant="box" style="width: 100%">
568+
<input matInput placeholder="example" [(ngModel)]="boxVariant" required>
569+
<mat-error>This field is required</mat-error>
570+
<mat-hint>Please type something here</mat-hint>
571+
</mat-form-field>
572+
</td>
573+
</tr></table>
574+
</mat-card-content>
575+
</mat-card>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ export class InputDemo {
5252
delayedFormControl = new FormControl('');
5353
model = 'hello';
5454

55+
legacyVariant: string;
56+
standardVariant: string;
57+
boxVariant: string;
58+
5559
constructor() {
5660
setTimeout(() => this.delayedFormControl.setValue('hello'), 100);
5761
}

src/lib/form-field/form-field-box.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ $mat-form-field-box-subscript-padding:
5353
height: $mat-form-field-box-underline-height;
5454
}
5555

56+
// Note that we need this specific of a selector because we don't want
57+
// the hover effect to show when the user hovers over the hints.
58+
&:not(.mat-form-field-disabled) .mat-form-field-flex:hover ~ .mat-form-field-underline {
59+
.mat-form-field-ripple {
60+
opacity: 1;
61+
transform: none;
62+
transition: opacity 600ms $swift-ease-out-timing-function;
63+
}
64+
}
65+
5666
.mat-form-field-subscript-wrapper {
5767
padding: 0 $mat-form-field-box-subscript-padding;
5868
}

src/lib/form-field/form-field-standard.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $mat-form-field-standard-padding-top: .5em !default;
3737

3838
// Note that we need this specific of a selector because we don't want
3939
// the hover effect to show when the user hovers over the hints.
40-
.mat-form-field:not(.mat-form-field-disabled) .mat-form-field-flex:hover ~ .mat-form-field-underline {
40+
&:not(.mat-form-field-disabled) .mat-form-field-flex:hover ~ .mat-form-field-underline {
4141
.mat-form-field-ripple {
4242
opacity: 1;
4343
transform: none;

0 commit comments

Comments
 (0)