aboutsummaryrefslogtreecommitdiff
path: root/src/app/components/register
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/register
parentbcd88af53b1a920d728ec98b45daa9ac2e2c0917 (diff)
parentc13889759d70687de6833c505221c203f65fedb8 (diff)
downloadDevHive-Angular-f849e37ccdd6fd48f83119a3b3b65cdd8b765dc3.tar
DevHive-Angular-f849e37ccdd6fd48f83119a3b3b65cdd8b765dc3.tar.gz
DevHive-Angular-f849e37ccdd6fd48f83119a3b3b65cdd8b765dc3.zip
Merge pull request #7 from Team-Kaleidoscope/devHEADv0.2main
Second Stage: Complete
Diffstat (limited to 'src/app/components/register')
-rw-r--r--src/app/components/register/register.component.css40
-rw-r--r--src/app/components/register/register.component.html72
-rw-r--r--src/app/components/register/register.component.ts36
3 files changed, 43 insertions, 105 deletions
diff --git a/src/app/components/register/register.component.css b/src/app/components/register/register.component.css
index 93d8006..e69de29 100644
--- a/src/app/components/register/register.component.css
+++ b/src/app/components/register/register.component.css
@@ -1,40 +0,0 @@
-/* A lot of stuff are moved to the global styles! */
-
-* {
- transition: 0.2s;
-}
-
-form {
- width: 100%;
-}
-
-@media screen and (max-height: 630px) {
- #content {
- height: fit-content !important;
- }
-}
-
-#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-login {
- color: var(--focus-color);
- background-color: var(--bg-color);
- border-color: var(--focus-color);
-}
-
-.redirect-to-login:hover {
- border-color: black !important;
- color: black;
-}
diff --git a/src/app/components/register/register.component.html b/src/app/components/register/register.component.html
index 4e67e0e..d8fa7c4 100644
--- a/src/app/components/register/register.component.html
+++ b/src/app/components/register/register.component.html
@@ -1,65 +1,57 @@
-<div id="content">
- <div class="title">Register</div>
+<main class="centered-content scroll-standalone height-full flex-col flex-center-align-items flex-justify-center">
+ <summary class="title card width-full margin-0 padding-dot2">Register</summary>
- <form [formGroup]="registerUserFormGroup" (ngSubmit)="onSubmit()">
- <hr>
- <!-- Value: {{ registerUserFormGroup.value | json }}
- <hr> -->
-
- <div class="input-selection">
- <input type="text" placeholder="Goshko, is that u?" class="input-field" formControlName="firstName" required>
- <label class="input-field-label">First Name</label>
+ <app-error-bar class="width-full margin-top-dot4"></app-error-bar>
+ <form class="width-full card padding-dot6" [formGroup]="registerUserFormGroup" (ngSubmit)="onSubmit()">
+ <section class="input-selection width-full">
+ <input type="text" placeholder="First Name" class="fancy-input width-full border-faded-slim border-bottom-only" formControlName="firstName" required>
+ <label class="fancy-input-label width-full">First Name</label>
<div class="input-errors">
<label *ngIf="registerUserFormGroup.get('firstName')?.errors?.required" class="error">*Required</label>
<label *ngIf="registerUserFormGroup.get('firstName')?.errors?.minlength" class="error">*Minimum 3 characters</label>
</div>
- </div>
-
- <div class="input-selection">
- <input type="text" placeholder="Trapov? Really??" class="input-field" formControlName="lastName" required>
- <label class="input-field-label">Last Name</label>
-
+ </section>
+ <section class="input-selection">
+ <input type="text" placeholder="Last Name" class="fancy-input width-full border-faded-slim border-bottom-only" formControlName="lastName" required>
+ <label class="fancy-input-label width-full">Last Name</label>
<div class="input-errors">
<label *ngIf="registerUserFormGroup.get('lastName')?.errors?.required" class="error">*Required</label>
<label *ngIf="registerUserFormGroup.get('lastName')?.errors?.minlength" class="error">*Minimum 3 characters</label>
</div>
- </div>
-
- <div class="input-selection">
- <input type="text" placeholder="Think of something cool to flex on other kids" class="input-field" formControlName="username" required>
- <label class="input-field-label">Username</label>
-
+ </section>
+ <section class="input-selection">
+ <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="registerUserFormGroup.get('username')?.errors?.required" class="error">*Required</label>
<label *ngIf="registerUserFormGroup.get('username')?.errors?.minlength" class="error">*Minimum 3 characters</label>
</div>
- </div>
-
- <div class="input-selection">
- <input type="text" placeholder="You expect an email joke? I have none, mail me one" class="input-field" formControlName="email" required>
- <label class="input-field-label">Email</label>
-
+ </section>
+ <section class="input-selection">
+ <input type="text" placeholder="Email" class="fancy-input width-full border-faded-slim border-bottom-only" formControlName="email" required>
+ <label class="fancy-input-label width-full">Email</label>
<div class="input-errors">
<label *ngIf="registerUserFormGroup.get('email')?.errors?.required" class="error">*Required</label>
<label *ngIf="registerUserFormGroup.get('email')?.errors?.email" class="error">*Invalid email</label>
</div>
- </div>
-
- <div class="input-selection">
- <input type="password" placeholder="Make sure it's long & strong (just like my d***)" 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="registerUserFormGroup.get('password')?.errors?.required" class="error">*Required</label>
<label *ngIf="registerUserFormGroup.get('password')?.errors?.minlength" class="error">*Minimum 3 characters</label>
<label *ngIf="registerUserFormGroup.get('password')?.errors?.pattern" class="error">*At least 1 number</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-login" (click)="onRedirectLogin()">Already have an account? Login here</button>
-</div>
+ <button class="fg-focus border-faded-slim padding-dot3 lighter-hover click-effect border-radius-dot3 width-full margin-top-dot4" (click)="onRedirectLogin()">
+ Already have an account? Login here
+ </button>
+</main>
diff --git a/src/app/components/register/register.component.ts b/src/app/components/register/register.component.ts
index 36eaa55..6d84e11 100644
--- a/src/app/components/register/register.component.ts
+++ b/src/app/components/register/register.component.ts
@@ -1,6 +1,6 @@
import { HttpErrorResponse } from '@angular/common/http';
import { Component, OnInit, ViewChild } from '@angular/core';
-import { AbstractControl, FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
+import { FormBuilder, FormControl, FormGroup, Validators } from '@angular/forms';
import { Title } from '@angular/platform-browser';
import { Router } from '@angular/router';
import { TokenService } from 'src/app/services/token.service';
@@ -16,6 +16,7 @@ export class RegisterComponent implements OnInit {
@ViewChild(ErrorBarComponent) private _errorBar: ErrorBarComponent;
private _title = 'Register';
public registerUserFormGroup: 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);
@@ -49,38 +50,23 @@ export class RegisterComponent implements OnInit {
// this.registerUserFormGroup.valueChanges.subscribe(console.log);
}
+ toggleShowPassword(): void {
+ this.showingPassword = !this.showingPassword;
+ }
+
onSubmit(): void {
- this._userService.registerUserRequest(this.registerUserFormGroup).subscribe(
- res => {
+ this._userService.registerUserRequest(this.registerUserFormGroup).subscribe({
+ next: (res: object) => {
this._tokenService.setUserTokenToSessionStorage(res);
this._router.navigate(['/']);
},
- (err: HttpErrorResponse) => {
+ error: (err: HttpErrorResponse) => {
this._errorBar.showError(err);
}
- );
+ });
}
+
onRedirectLogin(): void {
this._router.navigate(['/login']);
}
-
- get firstName(): AbstractControl | null {
- return this.registerUserFormGroup.get('firstName');
- }
-
- get lastName(): AbstractControl | null {
- return this.registerUserFormGroup.get('lastName');
- }
-
- get username(): AbstractControl | null {
- return this.registerUserFormGroup.get('username');
- }
-
- get email(): AbstractControl | null {
- return this.registerUserFormGroup.get('email');
- }
-
- get password(): AbstractControl | null {
- return this.registerUserFormGroup.get('password');
- }
}