This repository was archived by the owner on Nov 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/new-setup' of https://github.com/fivethree-team…
…/component-library into feature/new-setup # Conflicts: # projects/core/src/lib/fivethree.core.module.ts
- Loading branch information
Showing
15 changed files
with
246 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# fiv-password |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ion-item> | ||
<ion-label *ngIf="placeholder" [position]="position">{{ placeholder }}</ion-label> | ||
<ion-input [type]="show ? 'text' : 'password'" [(ngModel)]="value" [clearOnEdit]="clearOnEdit"></ion-input> | ||
<ion-icon slot="end" [name]="show ? hideIcon : showIcon" (click)="toggleShowPassword()"></ion-icon> | ||
</ion-item> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PasswordComponent } from './password.component'; | ||
|
||
describe('PasswordComponent', () => { | ||
let component: PasswordComponent; | ||
let fixture: ComponentFixture<PasswordComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ PasswordComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PasswordComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { Component, OnInit, Input, forwardRef } from '@angular/core'; | ||
import { NG_VALUE_ACCESSOR, ControlValueAccessor, Validator, ValidationErrors, AbstractControl, NG_VALIDATORS } from '@angular/forms'; | ||
|
||
export const CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR: any = { | ||
provide: NG_VALUE_ACCESSOR, | ||
useExisting: forwardRef(() => PasswordComponent), | ||
multi: true | ||
}; | ||
|
||
export const CUSTOM_INPUT_VALIDATOR = { | ||
provide: NG_VALIDATORS, | ||
useExisting: forwardRef(() => PasswordComponent), | ||
multi: true, | ||
}; | ||
|
||
@Component({ | ||
selector: 'fiv-password', | ||
templateUrl: './password.component.html', | ||
styleUrls: ['./password.component.scss'], | ||
providers: [ | ||
CUSTOM_INPUT_CONTROL_VALUE_ACCESSOR, | ||
CUSTOM_INPUT_VALIDATOR | ||
], | ||
}) | ||
export class PasswordComponent implements ControlValueAccessor, OnInit, Validator { | ||
|
||
@Input() hideIcon = 'eye-off'; | ||
@Input() placeholder: string; | ||
@Input() position: 'floating' | 'inline' | 'fixed' | 'stacked' = 'floating'; | ||
@Input() show: boolean; | ||
@Input() showIcon = 'eye'; | ||
@Input() clearOnEdit = false; | ||
|
||
private innerValue: any = ''; | ||
private onTouchedCallback: () => {}; | ||
private onChangeCallback: (_: any) => {}; | ||
|
||
constructor() { } | ||
|
||
ngOnInit() { | ||
} | ||
|
||
toggleShowPassword() { | ||
this.show = !this.show; | ||
} | ||
|
||
get value(): any { | ||
return this.innerValue; | ||
} | ||
|
||
set value(v: any) { | ||
if (v !== this.innerValue) { | ||
this.innerValue = v; | ||
this.onChangeCallback(v); | ||
} | ||
} | ||
|
||
writeValue(value: any) { | ||
if (value !== this.innerValue) { | ||
this.innerValue = value; | ||
} | ||
} | ||
|
||
registerOnChange(fn: any) { | ||
this.onChangeCallback = fn; | ||
} | ||
|
||
registerOnTouched(fn: any) { | ||
this.onTouchedCallback = fn; | ||
} | ||
|
||
validate(control: AbstractControl): ValidationErrors { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { FivethreeCoreModule } from 'core'; | ||
import { NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; | ||
import { Routes, RouterModule } from '@angular/router'; | ||
|
||
import { IonicModule } from '@ionic/angular'; | ||
|
||
import { PasswordPage } from './password.page'; | ||
|
||
const routes: Routes = [ | ||
{ | ||
path: '', | ||
component: PasswordPage | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [ | ||
CommonModule, | ||
FormsModule, | ||
IonicModule, | ||
FivethreeCoreModule, | ||
ReactiveFormsModule, | ||
RouterModule.forChild(routes) | ||
], | ||
declarations: [PasswordPage] | ||
}) | ||
export class PasswordPageModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<ion-header> | ||
<ion-toolbar> | ||
<ion-title>password</ion-title> | ||
</ion-toolbar> | ||
</ion-header> | ||
|
||
<ion-content padding> | ||
|
||
<ion-item-divider>Default Password</ion-item-divider> | ||
<fiv-password></fiv-password> | ||
|
||
<ion-item-divider>Password with placeholder</ion-item-divider> | ||
<fiv-password placeholder="Password"></fiv-password> | ||
|
||
<ion-item-divider>Password with placeholder and inline position</ion-item-divider> | ||
<fiv-password placeholder="Password" position="inline"></fiv-password> | ||
|
||
<ion-item-divider>Show password</ion-item-divider> | ||
<fiv-password [show]="true"></fiv-password> | ||
|
||
<ion-item-divider>Password with any show and hide icons</ion-item-divider> | ||
<fiv-password showIcon="ice-cream" hideIcon="leaf"></fiv-password> | ||
|
||
<ion-item-divider>Password in form</ion-item-divider> | ||
<form [formGroup]="loginForm" (ngSubmit)="onSubmit()"> | ||
<ion-item> | ||
<ion-label position="floating">E-Mail</ion-label> | ||
<ion-input formControlName="email" type="text"></ion-input> | ||
</ion-item> | ||
<fiv-password placeholder="Password" formControlName="password"></fiv-password> | ||
<ion-button block color="primary" type="submit" [disabled]="loginForm.invalid"> | ||
Login | ||
</ion-button> | ||
</form> | ||
|
||
</ion-content> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PasswordPage } from './password.page'; | ||
|
||
describe('PasswordPage', () => { | ||
let component: PasswordPage; | ||
let fixture: ComponentFixture<PasswordPage>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ PasswordPage ], | ||
schemas: [CUSTOM_ELEMENTS_SCHEMA], | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(PasswordPage); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Component, OnInit } from '@angular/core'; | ||
import { FormGroup, FormBuilder, Validators, AbstractControl } from '@angular/forms'; | ||
|
||
@Component({ | ||
selector: 'app-password', | ||
templateUrl: './password.page.html', | ||
styleUrls: ['./password.page.scss'], | ||
}) | ||
export class PasswordPage implements OnInit { | ||
|
||
loginForm: FormGroup; | ||
|
||
constructor(public formBuilder: FormBuilder) { } | ||
|
||
ngOnInit() { | ||
this.setupForm(); | ||
} | ||
|
||
setupForm() { | ||
this.loginForm = this.formBuilder.group({ | ||
email: ['', [Validators.email, Validators.required]], | ||
password: ['', [Validators.minLength(6), Validators.required]], | ||
}); | ||
} | ||
|
||
get email(): AbstractControl { | ||
return this.loginForm.get('email'); | ||
} | ||
|
||
onSubmit() { | ||
console.log(this.loginForm.value); | ||
} | ||
|
||
} |