Skip to content

Commit

Permalink
fix(package): improved ngx-auth-firebaseui-login - dynamic color pa…
Browse files Browse the repository at this point in the history
…lette
  • Loading branch information
AnthonyNahas committed Aug 21, 2019
1 parent d1f1724 commit 08f372c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<mat-form-field [appearance]="appearance" [@animate]="{ value: '*', params: { x: '50px' } }">
<input matInput [placeholder]="emailText" formControlName="email">
<mat-icon matSuffix color="primary">email</mat-icon>
<mat-icon matSuffix [color]="color">email</mat-icon>
<mat-error *ngIf="loginForm.get('email').hasError('required')">
{{emailErrorRequiredText}}
</mat-error>
Expand All @@ -28,7 +28,7 @@

<mat-form-field [appearance]="appearance" [@animate]="{ value: '*', params: { x: '50px' } }">
<input matInput type="password" [placeholder]="passwordText" formControlName="password">
<mat-icon matSuffix color="primary">lock</mat-icon>
<mat-icon matSuffix [color]="color">lock</mat-icon>
<mat-error>
{{passwordErrorRequiredText}}
</mat-error>
Expand All @@ -46,15 +46,15 @@
[@animate]="{ value: '*', params: { x: '-50px' } }"
mat-button
class="forgot-password"
color="primary"
[color]="color"
type="button">
{{forgotPasswordText}}
</button>
</div>

<button mat-raised-button
id="loginButton"
color="accent"
[color]="colorAccent"
class="submit-button"
aria-label="LOG IN"
[disabled]="loginForm.invalid"
Expand Down Expand Up @@ -82,7 +82,7 @@
<button [@animate]="{ value: '*', params: { x: '-100px' } }"
mat-button
id="createAccountButton"
color="primary"
[color]="color"
type="button"
(click)="onCreateAccountRequested.emit()">{{createAccountButtonText}}</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {Component, EventEmitter, Inject, Input, OnInit, Output, PLATFORM_ID, ViewEncapsulation} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {MatFormFieldAppearance} from '@angular/material';
import {MatFormFieldAppearance, ThemePalette} from '@angular/material';
import {AuthProcessService, AuthProvider} from '../../services/auth-process.service';
import {Subscription} from 'rxjs';
import {NgxAuthFirebaseuiAnimations} from '../../animations';
import {isPlatformBrowser} from '@angular/common';

@Component({
selector: 'ngx-auth-firebaseui-login',
Expand Down Expand Up @@ -47,6 +48,7 @@ export class NgxAuthFirebaseuiLoginComponent implements OnInit {
loginForm: FormGroup;
authProviders = AuthProvider;
onErrorSubscription: Subscription;
authenticationError = false;

constructor(
@Inject(PLATFORM_ID) private platformId: Object,
Expand All @@ -56,8 +58,20 @@ export class NgxAuthFirebaseuiLoginComponent implements OnInit {
this.onError = authProcess.onErrorEmitter;
}

get color(): string | ThemePalette {
return this.authenticationError ? 'warn' : 'primary';
}

get colorAccent(): string | ThemePalette {
return this.authenticationError ? 'warn' : 'accent';
}

ngOnInit() {

if (isPlatformBrowser(this.platformId)) {
this.onErrorSubscription = this.onError.subscribe(() => this.authenticationError = true);
}

this.updateAuthSnackbarMessages();

this.loginForm = this._formBuilder.group({
Expand Down

0 comments on commit 08f372c

Please sign in to comment.