Skip to content

Commit

Permalink
feat(demo): added examples module to explore the library
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Aug 13, 2018
1 parent 1e38cea commit 3a86a5a
Show file tree
Hide file tree
Showing 17 changed files with 349 additions and 42 deletions.
34 changes: 19 additions & 15 deletions demo/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {NgModule} from '@angular/core';
import {Routes, RouterModule} from '@angular/router';

const routes: Routes = [
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'getting-started',
loadChildren: 'app/getting-started/getting-started.module#GettingStartedModule'
}
];
{
path: '',
redirectTo: 'home',
pathMatch: 'full'
},
{
path: 'getting-started',
loadChildren: 'app/getting-started/getting-started.module#GettingStartedModule'
},
{
path: 'examples',
loadChildren: 'app/examples/examples.module#ExamplesModule'
}];

@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
export class AppRoutingModule {
}
4 changes: 3 additions & 1 deletion demo/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import {HomeModule} from './home/home.module';
import {AppComponent} from './app.component';
import {environment} from '../environments/environment';
import {ServiceWorkerModule} from '@angular/service-worker';
import {HttpClientModule} from '@angular/common/http';
import {HttpClient, HttpClientModule} from '@angular/common/http';
import {MatInputModule} from '@angular/material';
import {MarkdownModule} from 'ngx-markdown';

@NgModule({
declarations: [
Expand All @@ -22,6 +23,7 @@ import {MatInputModule} from '@angular/material';
// the page.
BrowserModule.withServerTransition({appId: '@angular-material-extensions/password-strength-demo-id'}),
ServiceWorkerModule.register('/ngsw-worker.js', {enabled: environment.production}),
MarkdownModule.forRoot({loader: HttpClient}),
BrowserAnimationsModule,
FormsModule,
HttpClientModule,
Expand Down
12 changes: 12 additions & 0 deletions demo/src/app/examples/examples-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {RouterModule} from '@angular/router';
import {NgModule} from '@angular/core';
import {ExamplesComponent} from './examples.component';

@NgModule({
imports: [RouterModule.forChild([
{path: '', component: ExamplesComponent}
])],
exports: [RouterModule]
})
export class ExamplesRoutingModule {
}
178 changes: 178 additions & 0 deletions demo/src/app/examples/examples.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
<div class="jumbotron jumbotron-fluid">
<div class="container">
<h1>Explore the library and try these examples <3</h1>
</div>
</div>

<section class="home">
<div class="container">

<mat-card>
<mat-card-title>#1</mat-card-title>
<mat-card-subtitle>stand alone password component, digit char is optional</mat-card-subtitle>

<mat-slide-toggle #toggle1>Show Password Details</mat-slide-toggle>

<mat-card-content>
<!--password input filed-->
<mat-form-field appearance="outline" style="width: 100%" [color]="passwordComponent1.color">
<mat-label>Password</mat-label>
<input matInput #password
type="password"
placeholder="Password">
<mat-hint align="end" aria-live="polite">
{{password.value.length}} / {{passwordComponent1.max}}
</mat-hint>
</mat-form-field>

<!--@angular-material-extensions/password-strength's main component-->
<mat-password-strength #passwordComponent1
[enableDigitRule]="false"
(onStrengthChanged)="onStrengthChanged($event)"
[password]="password.value">
</mat-password-strength>
<!--Password's strength info-->
<mat-password-strength-info
*ngIf="toggle1.checked"
[passwordComponent]="passwordComponent1">
</mat-password-strength-info>
</mat-card-content>

<mat-card class="mt-2">
<mat-card-title>code</mat-card-title>
<mat-card-content>
<markdown src="assets/md/examples/e1.md"></markdown>
</mat-card-content>
</mat-card>
</mat-card>


<!-- #2 -->
<mat-card class="mt-4">
<mat-card-title>#2</mat-card-title>
<mat-card-subtitle>stand alone password component, special char and lower case are optional</mat-card-subtitle>

<mat-slide-toggle #toggle2>Show Password Details</mat-slide-toggle>

<mat-card-content>
<!--password input filed-->
<mat-form-field appearance="outline" style="width: 100%" [color]="passwordComponent2.color">
<mat-label>Password</mat-label>
<input matInput #password2
type="password"
placeholder="Password">
<mat-hint align="end" aria-live="polite">
{{password2.value.length}} / {{passwordComponent2.max}}
</mat-hint>
</mat-form-field>

<!--@angular-material-extensions/password-strength's main component-->
<mat-password-strength #passwordComponent2
[enableLowerCaseLetterRule]="false"
[enableSpecialCharRule]="false"
(onStrengthChanged)="onStrengthChanged($event)"
[password]="password2.value">
</mat-password-strength>
<!--Password's strength info-->
<mat-password-strength-info
*ngIf="toggle2.checked"
[passwordComponent]="passwordComponent2">
</mat-password-strength-info>
</mat-card-content>

<mat-card class="mt-2">
<mat-card-title>code</mat-card-title>
<mat-card-content>
<markdown src="assets/md/examples/e2.md"></markdown>
</mat-card-content>
</mat-card>
</mat-card>

<!-- #3 -->
<mat-card class="mt-4">
<mat-card-title>#3</mat-card-title>
<mat-card-subtitle>stand alone password component, the length of the password and an upper case char are
optional
</mat-card-subtitle>

<mat-slide-toggle #toggle3>Show Password Details</mat-slide-toggle>

<mat-card-content>
<!--password input filed-->
<mat-form-field appearance="outline" style="width: 100%" [color]="passwordComponent3.color">
<mat-label>Password</mat-label>
<input matInput #password3
type="password"
placeholder="Password">
<mat-hint align="end" aria-live="polite">
{{password3.value.length}} / {{passwordComponent3.max}}
</mat-hint>
</mat-form-field>

<!--@angular-material-extensions/password-strength's main component-->
<mat-password-strength #passwordComponent3
[enableLengthRule]="false"
[enableUpperCaseLetterRule]="false"
(onStrengthChanged)="onStrengthChanged($event)"
[password]="password3.value">
</mat-password-strength>
<!--Password's strength info-->
<mat-password-strength-info
*ngIf="toggle3.checked"
[passwordComponent]="passwordComponent3">
</mat-password-strength-info>
</mat-card-content>

<mat-card class="mt-2">
<mat-card-title>code</mat-card-title>
<mat-card-content>
<markdown src="assets/md/examples/e3.md"></markdown>
</mat-card-content>
</mat-card>
</mat-card>

<!-- #4 -->
<mat-card class="mt-4">
<mat-card-title>#4</mat-card-title>
<mat-card-subtitle>stand alone password component, min length = 6 and the max is = 12
optional
</mat-card-subtitle>

<mat-slide-toggle #toggle4>Show Password Details</mat-slide-toggle>

<mat-card-content>
<!--password input filed-->
<mat-form-field appearance="outline" style="width: 100%" [color]="passwordComponent4.color">
<mat-label>Password</mat-label>
<input matInput #password4
type="password"
placeholder="Password">
<mat-hint align="end" aria-live="polite">
{{password4.value.length}} / {{passwordComponent4.max}}
</mat-hint>
</mat-form-field>

<!--@angular-material-extensions/password-strength's main component-->
<mat-password-strength #passwordComponent4
[min]="6"
[max]="12"
(onStrengthChanged)="onStrengthChanged($event)"
[password]="password4.value">
</mat-password-strength>
<!--Password's strength info-->
<mat-password-strength-info
*ngIf="toggle4.checked"
[passwordComponent]="passwordComponent4">
</mat-password-strength-info>
</mat-card-content>

<mat-card class="mt-2">
<mat-card-title>code</mat-card-title>
<mat-card-content>
<markdown src="assets/md/examples/e4.md"></markdown>
</mat-card-content>
</mat-card>
</mat-card>

</div>
</section>
Empty file.
25 changes: 25 additions & 0 deletions demo/src/app/examples/examples.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { ExamplesComponent } from './examples.component';

describe('ExampleComponent', () => {
let component: ExamplesComponent;
let fixture: ComponentFixture<ExamplesComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ExamplesComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(ExamplesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
20 changes: 20 additions & 0 deletions demo/src/app/examples/examples.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Component, OnInit} from '@angular/core';

@Component({
selector: 'app-example',
templateUrl: './examples.component.html',
styleUrls: ['./examples.component.scss']
})
export class ExamplesComponent implements OnInit {

constructor() {
}

ngOnInit() {
}

onStrengthChanged(strength: number) {
console.log('password strength = ', strength);
}

}
13 changes: 13 additions & 0 deletions demo/src/app/examples/examples.module.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ExamplesModule } from './examples.module';

describe('ExamplesModule', () => {
let exampleModule: ExamplesModule;

beforeEach(() => {
exampleModule = new ExamplesModule();
});

it('should create an instance', () => {
expect(exampleModule).toBeTruthy();
});
});
18 changes: 18 additions & 0 deletions demo/src/app/examples/examples.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {ExamplesComponent} from './examples.component';
import {ExamplesRoutingModule} from './examples-routing.module';
import {AppSharedModule} from '../shared';
import {MarkdownModule} from 'ngx-markdown';

@NgModule({
imports: [
CommonModule,
MarkdownModule.forChild(),
ExamplesRoutingModule,
AppSharedModule
],
declarations: [ExamplesComponent]
})
export class ExamplesModule {
}
19 changes: 10 additions & 9 deletions demo/src/app/home/home-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { RouterModule } from '@angular/router';
import { NgModule } from '@angular/core';
import { HomeComponent } from './home.component';
import {RouterModule} from '@angular/router';
import {NgModule} from '@angular/core';
import {HomeComponent} from './home.component';

@NgModule({
imports: [RouterModule.forChild([
{ path: 'home', component: HomeComponent }
])],
exports: [RouterModule]
})
export class HomeRoutingModule {}
imports: [RouterModule.forChild([
{path: 'home', component: HomeComponent}
])],
exports: [RouterModule]
})
export class HomeRoutingModule {
}
2 changes: 1 addition & 1 deletion demo/src/app/home/home.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ <h1>@angular-material-extensions/password-strength</h1>

<!--@angular-material-extensions/password-strength's main component-->
<mat-password-strength #passwordComponent
[enableDigitRule]="false"
[enableDigitRule]="true"
(onStrengthChanged)="onStrengthChanged($event)"
[password]="password.value">
</mat-password-strength>
Expand Down
Loading

0 comments on commit 3a86a5a

Please sign in to comment.