Skip to content

Commit 08f372c

Browse files
committed
fix(package): improved ngx-auth-firebaseui-login - dynamic color palette
1 parent d1f1724 commit 08f372c

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

src/module/components/ngx-auth-firebaseui-login/ngx-auth-firebaseui-login.component.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

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

2929
<mat-form-field [appearance]="appearance" [@animate]="{ value: '*', params: { x: '50px' } }">
3030
<input matInput type="password" [placeholder]="passwordText" formControlName="password">
31-
<mat-icon matSuffix color="primary">lock</mat-icon>
31+
<mat-icon matSuffix [color]="color">lock</mat-icon>
3232
<mat-error>
3333
{{passwordErrorRequiredText}}
3434
</mat-error>
@@ -46,15 +46,15 @@
4646
[@animate]="{ value: '*', params: { x: '-50px' } }"
4747
mat-button
4848
class="forgot-password"
49-
color="primary"
49+
[color]="color"
5050
type="button">
5151
{{forgotPasswordText}}
5252
</button>
5353
</div>
5454

5555
<button mat-raised-button
5656
id="loginButton"
57-
color="accent"
57+
[color]="colorAccent"
5858
class="submit-button"
5959
aria-label="LOG IN"
6060
[disabled]="loginForm.invalid"
@@ -82,7 +82,7 @@
8282
<button [@animate]="{ value: '*', params: { x: '-100px' } }"
8383
mat-button
8484
id="createAccountButton"
85-
color="primary"
85+
[color]="color"
8686
type="button"
8787
(click)="onCreateAccountRequested.emit()">{{createAccountButtonText}}</button>
8888
</div>

src/module/components/ngx-auth-firebaseui-login/ngx-auth-firebaseui-login.component.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import {Component, EventEmitter, Inject, Input, OnInit, Output, PLATFORM_ID, ViewEncapsulation} from '@angular/core';
22
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
3-
import {MatFormFieldAppearance} from '@angular/material';
3+
import {MatFormFieldAppearance, ThemePalette} from '@angular/material';
44
import {AuthProcessService, AuthProvider} from '../../services/auth-process.service';
55
import {Subscription} from 'rxjs';
66
import {NgxAuthFirebaseuiAnimations} from '../../animations';
7+
import {isPlatformBrowser} from '@angular/common';
78

89
@Component({
910
selector: 'ngx-auth-firebaseui-login',
@@ -47,6 +48,7 @@ export class NgxAuthFirebaseuiLoginComponent implements OnInit {
4748
loginForm: FormGroup;
4849
authProviders = AuthProvider;
4950
onErrorSubscription: Subscription;
51+
authenticationError = false;
5052

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

61+
get color(): string | ThemePalette {
62+
return this.authenticationError ? 'warn' : 'primary';
63+
}
64+
65+
get colorAccent(): string | ThemePalette {
66+
return this.authenticationError ? 'warn' : 'accent';
67+
}
68+
5969
ngOnInit() {
6070

71+
if (isPlatformBrowser(this.platformId)) {
72+
this.onErrorSubscription = this.onError.subscribe(() => this.authenticationError = true);
73+
}
74+
6175
this.updateAuthSnackbarMessages();
6276

6377
this.loginForm = this._formBuilder.group({

0 commit comments

Comments
 (0)