Skip to content

Commit

Permalink
feat(package): added the ability to change and adapt custom msgs for …
Browse files Browse the repository at this point in the history
…the info component
  • Loading branch information
AnthonyNahas committed Dec 10, 2018
1 parent 068f0c3 commit b817bee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<mat-icon @negativeState color="warn">error</mat-icon>
</ng-template>
<div>
<p>contains at least one lower character</p>
<p>{{lowerCaseCriteriaMsg}}</p>
</div>
</div>

Expand All @@ -25,7 +25,7 @@
<mat-icon @negativeState color="warn">error</mat-icon>
</ng-template>
<div>
<p>contains at least one upper character</p>
<p>{{upperCaseCriteriaMsg}}</p>
</div>
</div>

Expand All @@ -39,7 +39,7 @@
<mat-icon @negativeState color="warn">error</mat-icon>
</ng-template>
<div>
<p>contains at least one digit character</p>
<p>{{digitsCriteriaMsg}}</p>
</div>
</div>

Expand All @@ -53,7 +53,7 @@
<mat-icon @negativeState color="warn">error</mat-icon>
</ng-template>
<div>
<p>contains at least one special character</p>
<p>{{specialCharsCriteriaMsg}}</p>
</div>
</div>

Expand All @@ -67,7 +67,7 @@
<mat-icon @negativeState color="warn">error</mat-icon>
</ng-template>
<div>
<p>contains at least {{passwordComponent.min}} characters</p>
<p>{{minCharsCriteriaMsg}}</p>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Input} from '@angular/core';
import {Component, Input, OnInit} from '@angular/core';
import {MatPasswordStrengthComponent} from '../mat-password-strength/mat-password-strength.component';
import {animate, animateChild, keyframes, query, stagger, style, transition, trigger, useAnimation} from '@angular/animations';
import {shake} from '../../animations/index';
Expand Down Expand Up @@ -72,12 +72,33 @@ import {shake} from '../../animations/index';
]),
],
})
export class MatPasswordStrengthInfoComponent {
export class MatPasswordStrengthInfoComponent implements OnInit {

@Input()
passwordComponent: MatPasswordStrengthComponent;

@Input()
enableScoreInfo = false;

@Input()
lowerCaseCriteriaMsg = 'contains at least one lower character';

@Input()
upperCaseCriteriaMsg = 'contains at least one upper character';

@Input()
digitsCriteriaMsg = 'contains at least one digit character';

@Input()
specialCharsCriteriaMsg = 'contains at least one special character';

@Input()
minCharsCriteriaMsg: string;

ngOnInit(): void {
if (!this.minCharsCriteriaMsg) {
this.minCharsCriteriaMsg = `contains at least ${this.passwordComponent.min} characters`
}
}

}

0 comments on commit b817bee

Please sign in to comment.