Skip to content

Commit

Permalink
feat(package): added animations to the ngx-auth-firebaseui component
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Aug 18, 2019
1 parent 6539538 commit 27b7704
Show file tree
Hide file tree
Showing 11 changed files with 376 additions and 283 deletions.
Binary file added assets/v3.4.0/login.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/v3.4.0/login_x10.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
497 changes: 250 additions & 247 deletions demo/src/app/home/home.component.html

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions src/module/animations/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {animate, animateChild, animation, query, stagger, state, style, transition, trigger, useAnimation} from '@angular/animations';

const customAnimation = animation(
[
style({
opacity: '{{opacity}}',
transform: 'scale({{scale}}) translate3d({{x}}, {{y}}, {{z}})'
}),
animate('{{duration}} {{delay}} cubic-bezier(0.0, 0.0, 0.2, 1)', style('*'))
],
{
params: {
duration: '200ms',
delay: '0ms',
opacity: '0',
scale: '1',
x: '0',
y: '0',
z: '0'
}
}
);

export const NgxAuthFirebaseuiAnimations = [
trigger('animate', [transition('void => *', [useAnimation(customAnimation)])]),

trigger('animateStagger', [
state('50', style('*')),
state('100', style('*')),
state('200', style('*')),

transition('void => 50', query('@*', [stagger('50ms', [animateChild()])], {optional: true})),
transition('void => 100', query('@*', [stagger('100ms', [animateChild()])], {optional: true})),
transition('void => 200', query('@*', [stagger('200ms', [animateChild()])], {optional: true}))
]),
];
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

<div id="login-form-wrapper" fxLayout="column" fxLayoutAlign="center center">

<!-- <div id="login-form" [@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}">-->
<div id="login-form">
<div id="login-form" [@animateStagger]="{ value: '50' }">

<div *ngIf="logoUrl" class="logo">
<img [src]="logoUrl" alt="logo">
<img [src]="logoUrl" alt="logo" [@animate]="{ value: '*', params: { x: '50px' } }">
</div>

<div class="title">{{titleText}}</div>
<div class="title" [@animate]="{ value: '*', params: { x: '-50px' } }">{{titleText}}</div>

<form name="loginForm" [formGroup]="loginForm" novalidate>
<form name="loginForm" [formGroup]="loginForm" novalidate
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}">

<mat-form-field [appearance]="appearance">
<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-error *ngIf="loginForm.get('email').hasError('required')">
Expand All @@ -26,21 +26,24 @@
</mat-error>
</mat-form-field>

<mat-form-field [appearance]="appearance">
<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-error>
{{passwordErrorRequiredText}}
</mat-error>
</mat-form-field>

<div class="remember-forgot-password" fxLayout="row" fxLayout.xs="column"
fxLayoutAlign="space-between center">
<div class="remember-forgot-password"
fxLayout="row" fxLayout.xs="column"
fxLayoutAlign="space-between center"
[@animate]="{ value: '*', params: { x: '50px' } }">
<mat-checkbox class="remember-me" aria-label="Remember Me">
{{rememberMeText}}
</mat-checkbox>

<button *ngIf="resetPasswordEnabled"
[@animate]="{ value: '*', params: { x: '-50px' } }"
mat-button
class="forgot-password"
color="primary"
Expand All @@ -61,7 +64,7 @@

</form>

<div class="separator">
<div class="separator" [@animate]="{ value: '*', params: { z: '50px', delay: '50ms', scale: '0.2' } }">
<span class="text">{{orLabelText}}</span>
</div>

Expand All @@ -70,17 +73,19 @@
theme="raised"
[providers]="providers"></ngx-auth-firebaseui-providers>

<div class="register" fxLayout="column" fxLayoutAlign="center center">
<span class="text">{{dontHaveAnAccountText}}</span>
<button mat-button
<div class="register"
fxLayout="column" fxLayoutAlign="center center"
[@animateStagger]="{ value: '100' }">
<span class="text" [@animate]="{ value: '*', params: { x: '100px' } }">
{{dontHaveAnAccountText}}
</span>
<button [@animate]="{ value: '*', params: { x: '-100px' } }"
mat-button
id="createAccountButton"
color="primary"
type="button"
(click)="onCreateAccountRequested.emit()">{{createAccountButtonText}}</button>
</div>

</div>

</div>

</div>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ ngx-auth-firebaseui-login {
}

.logo {
width: 128px;
width: 150px;
height: 150px;
margin: 32px auto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {MatFormFieldAppearance} from '@angular/material';
import {AuthProcessService, AuthProvider} from '../../services/auth-process.service';
import {Subscription} from 'rxjs';
import {NgxAuthFirebaseuiAnimations} from '../../animations';

@Component({
selector: 'ngx-auth-firebaseui-login',
templateUrl: './ngx-auth-firebaseui-login.component.html',
styleUrls: ['./ngx-auth-firebaseui-login.component.scss'],
encapsulation: ViewEncapsulation.None,
animations: NgxAuthFirebaseuiAnimations
})
export class NgxAuthFirebaseuiLoginComponent implements OnInit {

Expand Down
51 changes: 35 additions & 16 deletions src/module/components/ngx-auth-firebaseui/auth.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
<mat-card>
<mat-card-title>{{signInCardTitleText}}</mat-card-title>
<mat-card-content>
<form [formGroup]="signInFormGroup"
<form [@animateStagger]="{ value: '50' }"
[formGroup]="signInFormGroup"
(ngSubmit)="signInFormGroup.valid &&
authProcess.signInWith
(authProviders.EmailAndPassword,
{email:signInFormGroup.value.email, password: signInFormGroup.value.password})">
<div fxLayout="column" fxLayoutAlign="center">
<mat-form-field [appearance]="appearance">
<mat-form-field [@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
[appearance]="appearance">
<mat-label>{{emailText}}</mat-label>
<input matInput
formControlName="email"
Expand All @@ -25,7 +27,8 @@
</mat-error>
</mat-form-field>

<mat-form-field [appearance]="appearance">
<mat-form-field [@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
[appearance]="appearance">
<mat-label>{{passwordText}}</mat-label>
<input matInput [type]="togglePass.type" [minlength]="min" [maxlength]="max" formControlName="password"
required/>
Expand All @@ -44,7 +47,8 @@
</mat-error>
</mat-form-field>

<button mat-raised-button
<button [@animate]="{ value: '*', params: { x: '50px' } }"
mat-raised-button
style="margin-top: 20px"
type="submit"
class="space-top"
Expand All @@ -57,6 +61,7 @@

<div fxLayoutAlign="center">
<button *ngIf="resetPasswordEnabled"
[@animate]="{ value: '*', params: { x: '-50px' } }"
mat-button
class="space-top"
[color]="color"
Expand All @@ -67,7 +72,8 @@

</mat-card-content>
<mat-card-footer *ngIf="authProcess.isLoading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
<mat-progress-bar [@animate]="{ value: '*', params: { z: '50px', delay: '50ms', scale: '0.2' } }"
mode="indeterminate"></mat-progress-bar>
</mat-card-footer>
</mat-card>
</mat-tab>
Expand All @@ -79,11 +85,13 @@
<div *ngIf="!authProcess.emailConfirmationSent;then register else confirm"></div>
<ng-template #register>
<mat-card-content fxLayout="column" fxLayoutAlign="center">
<form [formGroup]="signUpFormGroup" (ngSubmit)="signUpFormGroup.valid &&
<form [@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
[formGroup]="signUpFormGroup" (ngSubmit)="signUpFormGroup.valid &&
processLegalSignUP(authProvider.EmailAndPassword)">
<div fxLayout="column" fxLayoutAlign="center">
<!--name-->
<mat-form-field [appearance]="appearance">
<mat-form-field [@animate]="{ value: '*', params: { x: '50px' } }"
[appearance]="appearance">
<!--labels will work only with @angular/[email protected] -->
<mat-label>{{nameText}}</mat-label>
<input
Expand All @@ -108,7 +116,8 @@
</mat-form-field>

<!--email-->
<mat-form-field [appearance]="appearance">
<mat-form-field [@animate]="{ value: '*', params: { x: '50px' } }"
[appearance]="appearance">
<mat-label>{{emailText}}</mat-label>
<input matInput
type="email"
Expand All @@ -125,7 +134,8 @@

<!--password-->
<div fxLayout="column">
<mat-form-field [appearance]="appearance">
<mat-form-field [@animate]="{ value: '*', params: { x: '50px' } }"
[appearance]="appearance">
<mat-label>{{passwordText}}</mat-label>
<input
matInput
Expand Down Expand Up @@ -172,7 +182,8 @@

</div>

<button mat-raised-button
<button [@animate]="{ value: '*', params: { x: '100px' } }"
mat-raised-button
style="margin-top: 20px"
type="submit"
[color]="color">
Expand All @@ -183,6 +194,7 @@
</form>

<button *ngIf="guestEnabled"
[@animate]="{ value: '*', params: { x: '-100px' } }"
mat-button
style="margin-top: 20px"
[color]="color"
Expand All @@ -194,7 +206,8 @@
</mat-card-content>

<mat-card-footer *ngIf="authProcess.isLoading">
<mat-progress-bar mode="indeterminate"></mat-progress-bar>
<mat-progress-bar [@animate]="{ value: '*', params: { z: '50px', delay: '50ms', scale: '0.2' } }"
mode="indeterminate"></mat-progress-bar>
</mat-card-footer>

</ng-template>
Expand All @@ -213,7 +226,8 @@

<!--Reset password tab-->
<mat-tab *ngIf="passwordResetWished" [label]="resetPasswordTabText">
<form [formGroup]="resetPasswordFormGroup" (ngSubmit)="resetPasswordFormGroup.valid && resetPassword()">
<form [@animateStagger]="{ value: '50' }"
[formGroup]="resetPasswordFormGroup" (ngSubmit)="resetPasswordFormGroup.valid && resetPassword()">

<mat-card>
<mat-card-header fxLayoutAlign="end">
Expand All @@ -227,7 +241,8 @@
</mat-card-header>

<mat-card-content>
<mat-form-field class="full-width" [appearance]="appearance">
<mat-form-field class="full-width" [appearance]="appearance"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}">
<mat-label> {{ resetPasswordTabText }} </mat-label>
<input matInput
[readonly]="passReset"
Expand All @@ -244,18 +259,22 @@
</mat-form-field>
</mat-card-content>
<mat-card-actions fxLayoutAlign="center">
<button mat-raised-button
<button [@animate]="{ value: '*', params: { x: '50px' } }"
mat-raised-button
type="submit"
[color]="color"
[disabled]="passReset">
{{resetPasswordActionButtonText}}
</button>
</mat-card-actions>
<mat-card-footer *ngIf="passReset" fxLayoutAlign="center">
<p>{{resetPasswordInstructionsText}}</p>
<p [@animate]="{ value: '*', params: { x: '-50px' } }">{{resetPasswordInstructionsText}}</p>
</mat-card-footer>
<mat-card-footer>
<mat-progress-bar *ngIf="authProcess.isLoading" mode="indeterminate"></mat-progress-bar>
<mat-progress-bar *ngIf="authProcess.isLoading"
[@animate]="{ value: '*', params: { z: '50px', delay: '50ms', scale: '0.2' } }"
mode="indeterminate">
</mat-progress-bar>
</mat-card-footer>
</mat-card>
</form>
Expand Down
4 changes: 3 additions & 1 deletion src/module/components/ngx-auth-firebaseui/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {LegalityDialogComponent} from '../../components/legality-dialog/legality
import {LegalityDialogParams, LegalityDialogResult} from '../../interfaces/legality.dialog.intreface';
import {NgxAuthFirebaseUIConfig, NgxAuthFirebaseUIConfigToken} from '../../ngx-auth-firebase-u-i.module';
import {MatPasswordStrengthComponent} from '@angular-material-extensions/password-strength';
import {NgxAuthFirebaseuiAnimations} from '../../animations';


export const EMAIL_REGEX = new RegExp(['^(([^<>()[\\]\\\.,;:\\s@\"]+(\\.[^<>()\\[\\]\\\.,;:\\s@\"]+)*)',
Expand All @@ -36,7 +37,8 @@ export const PHONE_NUMBER_REGEX = new RegExp(/^\+(?:[0-9] ?){6,14}[0-9]$/);
@Component({
selector: 'ngx-auth-firebaseui',
templateUrl: 'auth.component.html',
styleUrls: ['auth.component.scss']
styleUrls: ['auth.component.scss'],
animations: NgxAuthFirebaseuiAnimations
})
export class AuthComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy {

Expand Down
Loading

0 comments on commit 27b7704

Please sign in to comment.