-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(demo): add bootstrap demo component
- Loading branch information
Hung Pham
committed
May 16, 2023
1 parent
cf2935a
commit b82c355
Showing
13 changed files
with
275 additions
and
194 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
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 |
---|---|---|
@@ -1,76 +1 @@ | ||
<div class="container py-5"> | ||
<div class="row"> | ||
<div class="col-sm-12 col-md-10 col-lg-8 col-xl-6"> | ||
<section> | ||
<h3> | ||
Simple login form | ||
</h3> | ||
|
||
<div class="card login-card"> | ||
<div class="card-body"> | ||
<form (ngSubmit)="onSubmit()" [formGroup]="loginForm"> | ||
<div class="mb-3"> | ||
<label for="email" class="form-label">Email address</label> | ||
<input type="email" class="form-control" id="email" formControlName="email"> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="password" class="form-label">Password</label> | ||
<input type="password" class="form-control" id="password" formControlName="password"> | ||
</div> | ||
<div class="d-grid"> | ||
<button class="btn btn-primary" type="submit">Login</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<section class="mt-5"> | ||
<h3> | ||
Register form with nested form group | ||
</h3> | ||
|
||
<div class="card login-card"> | ||
<div class="card-body"> | ||
<form (ngSubmit)="onSubmit()" [formGroup]="registerForm"> | ||
<div class="mb-3"> | ||
<label for="first-name" class="form-label">First name</label> | ||
<input type="text" class="form-control" id="first-name" formControlName="firstName"> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="last-name" class="form-label">Last name</label> | ||
<input type="text" class="form-control" id="last-name" formControlName="lastName"> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="email" class="form-label">Email address</label> | ||
<input type="email" class="form-control" id="email" formControlName="email"> | ||
</div> | ||
<div formGroupName="address"> | ||
<div class="mb-3"> | ||
<label for="street" class="form-label">Street</label> | ||
<input type="text" class="form-control" id="street" formControlName="street"> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="city" class="form-label">City</label> | ||
<input type="text" class="form-control" id="city" formControlName="city"> | ||
</div> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="password" class="form-label">Password</label> | ||
<input type="password" class="form-control" id="password" formControlName="password"> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="confirm-password" class="form-label">Confirm password</label> | ||
<input type="password" class="form-control" id="confirm-password" formControlName="confirmPassword"> | ||
</div> | ||
|
||
<div class="d-grid"> | ||
<button class="btn btn-primary" type="submit">Register</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</section> | ||
</div> | ||
</div> | ||
</div> | ||
<router-outlet></router-outlet> |
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 |
---|---|---|
@@ -1,23 +0,0 @@ | ||
.card { | ||
width: 520px; | ||
} | ||
|
||
.card-body { | ||
padding: 24px; | ||
} | ||
|
||
.mb-3 { | ||
margin-bottom: 16px; | ||
} | ||
|
||
input { | ||
display: block; | ||
width: 100%; | ||
padding: 6px; | ||
} | ||
|
||
button{ | ||
cursor: pointer; | ||
height: 32px; | ||
padding: 0 12px; | ||
} | ||
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,63 +1,9 @@ | ||
import { Component } from '@angular/core'; | ||
import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | ||
|
||
const matchPassword = (password: string, confirmPassword: string) => { | ||
return (formGroup: FormGroup) => { | ||
const passwordControl = formGroup.controls[password]; | ||
const confirmPasswordControl = formGroup.controls[confirmPassword]; | ||
|
||
if (!passwordControl || !confirmPasswordControl) { | ||
return; | ||
} | ||
|
||
if ( | ||
confirmPasswordControl.errors && | ||
!confirmPasswordControl.errors['passwordMismatch'] | ||
) { | ||
return; | ||
} | ||
|
||
if (passwordControl.value !== confirmPasswordControl.value) { | ||
confirmPasswordControl.setErrors({ | ||
passwordMismatch: { message: 'not match' }, | ||
}); | ||
} else { | ||
confirmPasswordControl.setErrors(null); | ||
} | ||
}; | ||
}; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'], | ||
styleUrls: ['./app.component.scss'] | ||
}) | ||
export class AppComponent { | ||
loginForm = this.formBuilder.group({ | ||
email: ['', [Validators.required, Validators.email]], | ||
password: ['', [Validators.required, Validators.minLength(6)]], | ||
}); | ||
|
||
registerForm = this.formBuilder.group( | ||
{ | ||
firstName: ['', [Validators.required]], | ||
lastName: ['', [Validators.required]], | ||
email: ['', [Validators.required, Validators.email]], | ||
address: this.formBuilder.group({ | ||
street: ['', [Validators.required]], | ||
city: ['', [Validators.required]], | ||
}), | ||
password: ['', [Validators.required, Validators.minLength(6)]], | ||
confirmPassword: ['', [Validators.required]], | ||
}, | ||
{ | ||
validators: [matchPassword], | ||
} | ||
); | ||
|
||
constructor(private formBuilder: FormBuilder) {} | ||
|
||
onSubmit(): void { | ||
console.log(this.loginForm); | ||
} | ||
} |
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
Oops, something went wrong.