11import { Component , EventEmitter , Input , Output , inject } from '@angular/core' ;
22import { FormBuilder , ReactiveFormsModule } from '@angular/forms' ;
3+ import { MatButtonModule } from '@angular/material/button' ;
4+ import { MatIconModule } from '@angular/material/icon' ;
5+ import { MatInputModule } from '@angular/material/input' ;
6+ import { MatFormFieldModule } from '@angular/material/form-field' ;
7+ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner' ;
38import { Credentials } from 'src/app/shared/interfaces/credentials' ;
49import { LoginStatus } from '../data-access/login.service' ;
510
@@ -11,24 +16,72 @@ import { LoginStatus } from '../data-access/login.service';
1116 [formGroup]="loginForm"
1217 (ngSubmit)="login.emit(loginForm.getRawValue())"
1318 >
14- <input formControlName="email" type="email" placeholder="email" />
15- <input
16- formControlName="password"
17- type="password"
18- placeholder="password"
19- />
19+ <mat-form-field appearance="fill">
20+ <mat-label>email</mat-label>
21+ <input
22+ matNativeControl
23+ formControlName="email"
24+ type="email"
25+ placeholder="email"
26+ />
27+ <mat-icon matPrefix>mail</mat-icon>
28+ </mat-form-field>
29+ <mat-form-field appearance="fill">
30+ <mat-label>password</mat-label>
31+ <input
32+ matNativeControl
33+ formControlName="password"
34+ type="password"
35+ placeholder="password"
36+ />
37+ <mat-icon matPrefix>lock</mat-icon>
38+ </mat-form-field>
39+
2040 @if (loginStatus === 'error'){
21- <p >Could not log you in with those details.</p >
41+ <mat-error >Could not log you in with those details.</mat-error >
2242 } @if(loginStatus === 'authenticating'){
23- <p>Authenticating...</p >
43+ <mat-spinner diameter="50"></mat-spinner >
2444 }
2545
26- <button type="submit" [disabled]="loginStatus === 'authenticating'">
46+ <button
47+ mat-raised-button
48+ color="accent"
49+ type="submit"
50+ [disabled]="loginStatus === 'authenticating'"
51+ >
2752 Login
2853 </button>
2954 </form>
3055 ` ,
31- imports : [ ReactiveFormsModule ] ,
56+ imports : [
57+ ReactiveFormsModule ,
58+ MatButtonModule ,
59+ MatFormFieldModule ,
60+ MatInputModule ,
61+ MatIconModule ,
62+ MatProgressSpinnerModule ,
63+ ] ,
64+ styles : [
65+ `
66+ form {
67+ display: flex;
68+ flex-direction: column;
69+ align-items: center;
70+ }
71+
72+ button {
73+ width: 100%;
74+ }
75+
76+ mat-error {
77+ margin: 5px 0;
78+ }
79+
80+ mat-spinner {
81+ margin: 1rem 0;
82+ }
83+ ` ,
84+ ] ,
3285} )
3386export class LoginFormComponent {
3487 @Input ( { required : true } ) loginStatus ! : LoginStatus ;
0 commit comments