Skip to content

Commit a81cac3

Browse files
committed
demo(app): updated the home component - added outline appearance to the input+
1 parent 0ddf90a commit a81cac3

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

demo/src/app/home/home.component.html

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,17 @@ <h1>ngx-material-password-strength</h1>
2727
<mat-card fxFlex>
2828
<mat-card-title>ngx-material-password-strength
2929
</mat-card-title>
30-
<mat-card-subtitle>
30+
<mat-card-subtitle fxLayout="row" fxLayoutGap="10px">
3131
<mat-slide-toggle (change)="onSlideToggleChange($event)">Show Password</mat-slide-toggle>
3232
<mat-slide-toggle [(ngModel)]="showDetails">Show Password Details</mat-slide-toggle>
3333
</mat-card-subtitle>
3434

3535
<mat-card-content>
36+
3637
<div fxFlex>
37-
<mat-form-field floatPlaceholder="auto" style="width: 100%">
38+
39+
<mat-form-field appearance="outline" style="width: 100%" [color]="passwordComponent.color">
40+
<mat-label>Password</mat-label>
3841
<input matInput #password
3942
[type]="inputType"
4043
required
@@ -43,11 +46,15 @@ <h1>ngx-material-password-strength</h1>
4346
{{password.value.length}} / 25
4447
</mat-hint>
4548
</mat-form-field>
49+
4650
<ngx-material-password-strength #passwordComponent
51+
(onStrengthChanged)="onStrengthChanged($event)"
4752
[password]="password.value">
4853
</ngx-material-password-strength>
54+
4955
<mat-card *ngIf="showDetails" fxFlex fxLayout="row" fxLayoutAlign="center">
5056
<mat-card-content fxLayout="column" fxLayoutAlign="start">
57+
5158
<div fxLayout="row" fxLayoutGap="10px">
5259
<div *ngIf="passwordComponent.containAtLeastOneLowerCaseLetter; then done else error">
5360
</div>
@@ -61,6 +68,7 @@ <h1>ngx-material-password-strength</h1>
6168
<p>contains at least one lower character</p>
6269
</div>
6370
</div>
71+
6472
<div fxLayout="row" fxLayoutGap="10px">
6573
<div *ngIf="passwordComponent.containAtLeastOneUpperCaseLetter; then done else error">
6674
</div>
@@ -74,6 +82,7 @@ <h1>ngx-material-password-strength</h1>
7482
<p>contains at least one upper character</p>
7583
</div>
7684
</div>
85+
7786
<div fxLayout="row" fxLayoutGap="10px">
7887
<div *ngIf="passwordComponent.containAtLeastOneDigit; then done else error">
7988
</div>
@@ -87,6 +96,7 @@ <h1>ngx-material-password-strength</h1>
8796
<p>contains at least one digit character</p>
8897
</div>
8998
</div>
99+
90100
<div fxLayout="row" fxLayoutGap="10px">
91101
<div *ngIf="passwordComponent.containAtLeastOneSpecialChar; then done else error">
92102
</div>
@@ -100,6 +110,7 @@ <h1>ngx-material-password-strength</h1>
100110
<p>contains at least one special character</p>
101111
</div>
102112
</div>
113+
103114
<div fxLayout="row" fxLayoutGap="10px">
104115
<div *ngIf="passwordComponent.containAtLeastEightChars; then done else error">
105116
</div>
@@ -113,6 +124,21 @@ <h1>ngx-material-password-strength</h1>
113124
<p>contains at least eight characters</p>
114125
</div>
115126
</div>
127+
128+
<div fxLayout="row" fxLayoutGap="10px">
129+
<div *ngIf="passwordComponent.strength === 100; then done else error">
130+
</div>
131+
<ng-template #done>
132+
<mat-icon color="primary">done</mat-icon>
133+
</ng-template>
134+
<ng-template #error>
135+
<mat-icon color="warn">error</mat-icon>
136+
</ng-template>
137+
<div>
138+
<p>Password's strength = {{passwordComponent.strength}} %100</p>
139+
</div>
140+
</div>
141+
116142
</mat-card-content>
117143
</mat-card>
118144
</div>

demo/src/app/home/home.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class HomeComponent implements OnInit {
1212
password: string;
1313
inputType = 'password';
1414
showDetails: boolean;
15+
color = '';
1516

1617
constructor(private titleService: Title) {
1718
}
@@ -20,6 +21,10 @@ export class HomeComponent implements OnInit {
2021
this.titleService.setTitle('Home | ngx-material-password-strength');
2122
}
2223

24+
onStrengthChanged(strength: number) {
25+
console.log("password strength = ", strength);
26+
}
27+
2328
onSlideToggleChange(event: MatSlideToggleChange) {
2429
event.checked ? this.inputType = 'text' : this.inputType = 'password';
2530
}

0 commit comments

Comments
 (0)