aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/login
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 19:55:59 +0300
committerGitHub <noreply@github.com>2021-04-09 19:55:59 +0300
commitf849e37ccdd6fd48f83119a3b3b65cdd8b765dc3 (patch)
tree83b88a773bb7dc053bb3aced35bce302264ec925 /src/app/components/login
parentbcd88af53b1a920d728ec98b45daa9ac2e2c0917 (diff)
parentc13889759d70687de6833c505221c203f65fedb8 (diff)
downloadDevHive-Angular-0.2.tar
DevHive-Angular-0.2.tar.gz
DevHive-Angular-0.2.zip
Merge pull request #7 from Team-Kaleidoscope/devHEADv0.2main
Second Stage: Complete
Diffstat (limited to 'src/app/components/login')
-rw-r--r--src/app/components/login/login.component.css32
-rw-r--r--src/app/components/login/login.component.html38
-rw-r--r--src/app/components/login/login.component.ts23
3 files changed, 28 insertions, 65 deletions
diff --git a/src/app/components/login/login.component.css b/src/app/components/login/login.component.css
index 766522e..e69de29 100644
--- a/src/app/components/login/login.component.css
+++ b/src/app/components/login/login.component.css
@@ -1,32 +0,0 @@
-* {
- transition: .2s;
-}
-
-form {
- width: 100%;
-}
-
-#content hr {
- width: 100%;
- border: 1px solid black;
- box-sizing: border-box;
-}
-
-.input-selection:nth-of-type(1) {
- margin-top: 1.2em;
-}
-
-.submit-btn {
- margin-bottom: .2em;
-}
-
-.redirect-to-register {
- color: var(--focus-color);
- background-color: var(--bg-color);
- border-color: var(--focus-color);
-}
-
-.redirect-to-register:hover {
- border-color: black !important;
- color: black;
-}
diff --git a/src/app/components/login/login.component.html b/src/app/components/login/login.component.html
index 13f9bbf..95075c9 100644
--- a/src/app/components/login/login.component.html
+++ b/src/app/components/login/login.component.html
@@ -1,30 +1,28 @@
-<div id="content">
- <div class="title">Login</div>
+<main class="centered-content scroll-standalone flex-col flex-center-align-items flex-justify-center height-full">
+ <summary class="title card width-full margin-0 padding-dot2">Login</summary>
- <form [formGroup]="loginUserFormGroup" (ngSubmit)="onSubmit()">
- <hr>
-
- <div class="input-selection">
- <input type="text" placeholder="Username" class="input-field" formControlName="username" required>
- <label class="input-field-label">Username</label>
+ <app-error-bar class="width-full margin-top-dot4"></app-error-bar>
+ <form class="width-full card padding-dot6" [formGroup]="loginUserFormGroup" (ngSubmit)="onSubmit()">
+ <section class="input-selection width-full">
+ <input type="text" placeholder="Username" class="fancy-input width-full border-faded-slim border-bottom-only" formControlName="username" required>
+ <label class="fancy-input-label width-full">Username</label>
<div class="input-errors">
<label *ngIf="loginUserFormGroup.get('username')?.errors?.required" class="error">*Required</label>
</div>
- </div>
-
- <div class="input-selection">
- <input type="password" placeholder="Password" class="input-field" formControlName="password" required>
- <label class="input-field-label">Password</label>
-
+ </section>
+ <section class="input-selection">
+ <input [type]="showingPassword ? 'text' : 'password'" placeholder="Password" class="fancy-input width-full border-faded-slim border-bottom-only padding-right-1dot5" formControlName="password" required>
+ <label class="fancy-input-label width-full">Password</label>
+ <button type="button" class="show-password-button hover-half-opacity click-effect" (click)="toggleShowPassword()">
+ <img [src]="showingPassword ? '/assets/icons/tabler-icon-eye-off.svg' : '/assets/icons/tabler-icon-eye.svg'">
+ </button>
<div class="input-errors">
<label *ngIf="loginUserFormGroup.get('password')?.errors?.required" class="error">*Required</label>
</div>
- </div>
+ </section>
- <hr>
- <button class="submit-btn" type="submit">Submit</button>
- <app-error-bar></app-error-bar>
+ <button class="border-faded-slim padding-dot3 lighter-hover click-effect border-radius-dot3 width-full" type="submit">Submit</button>
</form>
- <button class="submit-btn redirect-to-register" (click)="onRedirectRegister()">New to DevHive? Register instead</button>
-</div>
+ <button class="fg-focus border-faded-slim padding-dot3 lighter-hover click-effect border-radius-dot3 width-full margin-top-dot4" (click)="onRedirectRegister()">New to DevHive? Register instead</button>
+</main>
diff --git a/src/app/components/login/login.component.ts b/src/app/components/login/login.component.ts
index c3fb79c..a0ce730 100644
--- a/src/app/components/login/login.component.ts
+++ b/src/app/components/login/login.component.ts
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from '@angular/core';
-import { FormGroup, FormBuilder, Validators, FormControl, AbstractControl } from '@angular/forms';
+import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
import { Router } from '@angular/router';
import { Title } from '@angular/platform-browser';
import { UserService } from 'src/app/services/user.service';
@@ -16,6 +16,7 @@ export class LoginComponent implements OnInit {
@ViewChild(ErrorBarComponent) private _errorBar: ErrorBarComponent;
private _title = 'Login';
public loginUserFormGroup: FormGroup;
+ public showingPassword = false;
constructor(private _titleService: Title, private _fb: FormBuilder, private _router: Router, private _userService: UserService, private _tokenService: TokenService) {
this._titleService.setTitle(this._title);
@@ -32,28 +33,24 @@ export class LoginComponent implements OnInit {
});
}
+ toggleShowPassword(): void {
+ this.showingPassword = !this.showingPassword;
+ }
+
onSubmit(): void {
this._errorBar.hideError();
- this._userService.loginUserRequest(this.loginUserFormGroup).subscribe(
- (res: object) => {
+ this._userService.loginUserRequest(this.loginUserFormGroup).subscribe({
+ next: (res: object) => {
this._tokenService.setUserTokenToSessionStorage(res);
this._router.navigate(['/']);
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
onRedirectRegister(): void {
this._router.navigate(['/register']);
}
-
- get username(): AbstractControl | null {
- return this.loginUserFormGroup.get('username');
- }
-
- get password(): AbstractControl | null {
- return this.loginUserFormGroup.get('password');
- }
}