Skip to content

Commit 5c7fce4

Browse files
authored
Merge pull request #6 from jaganbishoyi/feature
Pro theme added
2 parents 3aa8314 + 438e6fd commit 5c7fce4

File tree

10 files changed

+102
-38
lines changed

10 files changed

+102
-38
lines changed

ngx-password-validator/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ngx-password-validator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ngx-password-validator",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",

ngx-password-validator/projects/ng-password-validator/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,27 @@ myOptions = {
6464
}
6565
```
6666

67+
Theming( Default value is pro ):
68+
69+
```html
70+
<input type="text" id="password" name="password" placeholder="Password.."
71+
NgPasswordValidator [options]="myOptions">
72+
```
73+
Theme as 'basic':
74+
```ts
75+
myOptions = {
76+
'placement': 'top',
77+
'theme': 'basic'
78+
}
79+
```
80+
Theme as 'pro':
81+
```ts
82+
myOptions = {
83+
'placement': 'top',
84+
'theme': 'pro'
85+
}
86+
```
87+
6788
After closing the popup window, you will get one output for password validity (true/false):
6889

6990
```html

ngx-password-validator/projects/ng-password-validator/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ng-password-validator",
3-
"version": "0.0.5",
3+
"version": "0.0.6",
44
"description": "The password validator is a pop-up window that appears when you start typing in input box. Here you can configure the password acceptance criteria, once your enter characters fullfil the requirement you will get a success message.",
55
"author": "Jagan Mohan Bishoyi",
66
"license": "MIT",

ngx-password-validator/projects/ng-password-validator/src/lib/ng-password-validator.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class="popup-window">
2-
<div class="heading">Password Requirement</div>
2+
<div class="heading">Password Policy</div>
33
<div *ngIf="rules['password']">
44
<div class="rule" [hidden]="rules['password'].type !== 'number'"
55
[ngClass]="{'rule-pass':passwordStatus['password']}">

ngx-password-validator/projects/ng-password-validator/src/lib/ng-password-validator.component.scss

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,45 +28,74 @@
2828
box-shadow: 0 1px 5px 0px $light-black;
2929
}
3030

31-
.popup-window {
32-
.heading {
33-
font-size: $heading-font-size;
34-
color: $black;
35-
margin-bottom: 0.5rem;
36-
font-weight: 700;
37-
}
38-
39-
.rule {
40-
font-size: $body-font-size;
41-
color: $grey;
42-
43-
&::before {
44-
content: "\a";
45-
width: 5px;
46-
height: 5px;
47-
border-radius: 50%;
48-
background: $grey;
49-
display: inline-block;
50-
vertical-align: sub;
51-
margin: 0 5px 6px 0;
31+
&.popup {
32+
.popup-window {
33+
.heading {
34+
font-size: $heading-font-size;
35+
color: $black;
36+
margin-bottom: 0.5rem;
37+
font-weight: 700;
5238
}
5339

54-
&.rule-pass {
55-
text-decoration: line-through;
56-
color: $light-grey;
40+
.rule {
41+
font-size: $body-font-size;
42+
color: $grey;
43+
line-height: 17px;
5744

5845
&::before {
59-
background: $light-grey;
46+
content: "\a";
47+
width: 5px;
48+
height: 5px;
49+
border-radius: 50%;
50+
background: $grey;
51+
display: inline-block;
52+
vertical-align: sub;
53+
margin: 0 10px 6px 0;
54+
}
55+
56+
&.rule-pass {
57+
text-decoration: line-through;
58+
color: $light-grey;
59+
60+
&::before {
61+
background: $light-grey;
62+
}
6063
}
6164
}
62-
}
6365

64-
.success-message {
65-
color: $color-success;
66-
text-align: left;
67-
font-size: $heading-font-size;
68-
margin-top: 5px;
66+
.success-message {
67+
color: $color-success;
68+
text-align: center;
69+
font-size: $heading-font-size;
70+
margin-top: 5px;
71+
}
72+
6973
}
7074

75+
&.popup-pro {
76+
.popup-window {
77+
.rule {
78+
&.rule-pass {
79+
color: $color-success;
80+
text-decoration: none;
81+
82+
&::before {
83+
content: "\2713" !important;
84+
width: 0;
85+
height: 0;
86+
padding-right: 5px;
87+
vertical-align: inherit;
88+
background: $color-success;
89+
}
90+
}
91+
}
92+
93+
.success-message {
94+
color: $dark-red;
95+
}
96+
}
97+
}
7198
}
99+
100+
72101
}

ngx-password-validator/projects/ng-password-validator/src/lib/ng-password-validator.component.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ export class NgPasswordValidatorComponent implements OnInit {
106106
ngOnInit(): void {
107107
this.setCustomClass();
108108
this.setStyles();
109+
this.theme();
109110
this.dataService.updatedValue.subscribe((data: IStatus) => {
110111
this.passwordStatus = { ... this.passwordStatus, ...data };
111112
for (const propName in this.passwordOptions.rules) {
@@ -240,6 +241,18 @@ export class NgPasswordValidatorComponent implements OnInit {
240241
}
241242
}
242243

244+
/**
245+
* Set theme
246+
*
247+
* @memberof NgPasswordValidatorComponent
248+
*/
249+
theme(): void {
250+
if (this.options["theme"]) {
251+
this.renderer.addClass(this.elementRef.nativeElement, "popup-" + this.options["theme"]);
252+
}
253+
}
254+
255+
243256
/**
244257
* Sets the animation duration
245258
*

ngx-password-validator/projects/ng-password-validator/src/lib/ng-password-validator.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export interface NgPasswordValidatorOptions {
44
"animation-duration"?: number;
55
"custom-class"?: string;
66
"shadow"?: boolean;
7-
"theme"?: string;
7+
"theme"?: "basic" | "pro";
88
"offset"?: number;
99
"width"?: number;
1010
"max-width"?: number;

ngx-password-validator/projects/ng-password-validator/src/lib/options.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { IStatus, NgPasswordValidatorOptions } from "./ng-password-validator.int
33
export const defaultOptions: NgPasswordValidatorOptions = {
44
placement: "bottom",
55
"z-index": 0,
6-
"custom-class": "",
6+
"custom-class": "custom-class",
77
shadow: true,
8-
theme: "basic",
8+
theme: "pro",
99
offset: 8,
1010
rules: {
1111
password: {

ngx-password-validator/projects/ng-password-validator/src/lib/variable.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ $white: #fff;
33
$black: #000;
44
$green: #28a745;
55
$grey: #6a6a6a;
6+
$dark-red: #9c0404;
67

78
$light-grey: #d3d3d3;
89
$light-black: rgba(0, 0, 0, 0.4);

0 commit comments

Comments
 (0)