Skip to content

Commit ad68df7

Browse files
committed
feat: styles for login form component
1 parent f2d38fb commit ad68df7

File tree

3 files changed

+91
-26
lines changed

3 files changed

+91
-26
lines changed

src/app/auth/login/login.component.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import { AuthService } from 'src/app/shared/data-access/auth.service';
88
standalone: true,
99
selector: 'app-login',
1010
template: `
11-
<app-login-form
12-
[loginStatus]="loginService.status()"
13-
(login)="loginService.login$.next($event)"
14-
/>
15-
<a routerLink="/auth/register">Create account</a>
11+
<div class="container gradient-bg">
12+
<app-login-form
13+
[loginStatus]="loginService.status()"
14+
(login)="loginService.login$.next($event)"
15+
/>
16+
<a routerLink="/auth/register">Create account</a>
17+
</div>
1618
`,
1719
providers: [LoginService],
1820
imports: [RouterModule, LoginFormComponent],

src/app/auth/login/ui/login-form.component.ts

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { Component, EventEmitter, Input, Output, inject } from '@angular/core';
22
import { 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';
38
import { Credentials } from 'src/app/shared/interfaces/credentials';
49
import { 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
})
3386
export class LoginFormComponent {
3487
@Input({ required: true }) loginStatus!: LoginStatus;

src/styles.scss

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
// hue. Available color palettes: https://material.io/design/color/
1414
$angularstart-chat-primary: mat.define-palette(mat.$orange-palette);
1515
$angularstart-chat-accent: mat.define-palette(
16-
mat.$yellow-palette,
17-
A200,
18-
A100,
19-
A400
16+
mat.$blue-gray-palette,
17+
700,
18+
800,
19+
900
2020
);
2121

2222
// The warn palette is optional (defaults to red).
23-
$angularstart-chat-warn: mat.define-palette(mat.$deep-orange-palette);
23+
$angularstart-chat-warn: mat.define-palette(mat.$red-palette);
2424

2525
// Create the theme object. A theme consists of configurations for individual
2626
// theming systems such as "color" or "typography".
@@ -68,14 +68,24 @@ body {
6868
font-family: Roboto, "Helvetica Neue", sans-serif;
6969
}
7070

71-
.header {
72-
box-shadow: 0px -7px 11px 0px var(--dark);
71+
.container {
72+
height: 100%;
73+
display: flex;
74+
flex-direction: column;
75+
align-items: center;
76+
justify-content: center;
7377
}
7478

75-
form {
76-
input {
77-
padding: 1rem;
78-
}
79+
.gradient-bg {
80+
background: linear-gradient(
81+
138deg,
82+
var(--primary-darker-color) 0%,
83+
var(--primary-color) 100%
84+
);
85+
}
86+
87+
.header {
88+
box-shadow: 0px -7px 11px 0px var(--dark);
7989
}
8090

8191
@keyframes animateInPrimary {

0 commit comments

Comments
 (0)