import {Component, Input, Output} from '@angular/core';
import {AuthProcessService, AuthProvider} from '../../services/auth-process.service';
import {NgxAuthFirebaseuiAnimations} from '../../animations';
export enum Theme {
DEFAULT = 'default',
CLASSIC = 'classic',
STROKED = 'stroked',
FAB = 'fab',
MINI_FAB = 'mini-fab',
RAISED = 'raised',
}
export enum Layout {
ROW = 'row',
COLUMN = 'column'
}
@Component({
selector: 'ngx-auth-firebaseui-providers',
templateUrl: 'auth.providers.component.html',
styleUrls: ['auth.providers.component.scss'],
animations: NgxAuthFirebaseuiAnimations
})
export class AuthProvidersComponent {
@Input() theme: Theme; // theme: string = Theme.DEFAULT;
@Input() layout: string = Layout.ROW;
@Input() providers: AuthProvider[] | AuthProvider = AuthProvider.ALL; // google, facebook, twitter, github, microsoft, yahoo
@Output() onSuccess: any;
@Output() onError: any;
themes = Theme;
authProvider = AuthProvider;
constructor(public authProcess: AuthProcessService) {
this.onSuccess = authProcess.onSuccessEmitter;
this.onError = authProcess.onErrorEmitter;
}
}
<div [ngSwitch]="theme" [@animateStagger]="{ value: '50' }">
<!--default icon buttons-->
<div *ngSwitchDefault
[fxLayout]="layout"
fxLayout.xs="column"
[fxLayoutAlign]="layout == 'row' ? 'space-around center' : 'stretch'">
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Google)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Google)">
<mat-icon svgIcon="google-colored"></mat-icon>
Google
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Facebook)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="facebook-filled"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Facebook)">
<mat-icon svgIcon="facebook"></mat-icon>
Facebook
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Twitter)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="twitter-filled"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Twitter)">
<mat-icon svgIcon="twitter"></mat-icon>
Twitter
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Github)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Github)">
<mat-icon svgIcon="github"></mat-icon>
GitHub
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Microsoft)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Microsoft)">
<mat-icon svgIcon="microsoft"></mat-icon>
Microsoft
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Yahoo)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Yahoo)">
<mat-icon svgIcon="yahoo"></mat-icon>
Yahoo
</button>
</div>
<!--classic-->
<div *ngSwitchCase="themes.CLASSIC"
class="buttons-classic"
[fxLayout]="layout"
fxLayout.xs="column"
[fxLayoutAlign]="layout == 'row' ? 'space-around center' : 'stretch'">
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Google)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="google-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Google)">
Google
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Facebook)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="facebook-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Facebook)">
Facebook
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Twitter)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="twitter-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Twitter)">
Twitter
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Github)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="github-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Github)">
GitHub
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Microsoft)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="microsoft-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Microsoft)">
Microsoft
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Yahoo)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-button
class="yahoo-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Yahoo)">
Yahoo
</button>
</div>
<!--stroked-->
<div *ngSwitchCase="themes.STROKED"
class="buttons-classic"
[fxLayout]="layout"
fxLayout.xs="column"
[fxLayoutAlign]="layout == 'row' ? 'space-around center' : 'stretch'">
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Google)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-stroked-button
class="google-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Google)">
Google
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Facebook)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-stroked-button
class="facebook-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Facebook)">
Facebook
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Twitter)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-stroked-button
class="twitter-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Twitter)">
Twitter
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Github)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-stroked-button
class="github-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Github)">
GitHub
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Microsoft)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-stroked-button
class="microsoft-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Microsoft)">
Microsoft
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Yahoo)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-stroked-button
class="yahoo-classic"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Yahoo)">
Yahoo
</button>
</div>
<!--raised-->
<div *ngSwitchCase="themes.RAISED"
class="buttons-raised"
[fxLayout]="layout"
fxLayout.xs="column"
[fxLayoutAlign]="layout == 'row' ? 'space-around center' : 'stretch'">
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Google)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-raised-button
class="google-raised"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Google)">
Google
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Facebook)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-raised-button
class="facebook-raised"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Facebook)">
Facebook
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Twitter)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-raised-button
class="twitter-raised"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Twitter)">
Twitter
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Github)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-raised-button
class="github-raised"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Github)">
GitHub
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Microsoft)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-raised-button
class="microsoft-raised"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Microsoft)">
Microsoft
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Yahoo)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-raised-button
class="yahoo-raised"
[ngClass.xs]="{'space-full-xs':true}"
(click)="authProcess.signInWith(authProvider.Yahoo)">
Yahoo
</button>
</div>
<!--fab-->
<div *ngSwitchCase="themes.FAB"
class="buttons-raised"
[fxLayout]="layout"
[fxLayoutAlign]="layout == 'row' ? 'space-around center' : 'stretch'">
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Google)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-fab
class="google-raised"
(click)="authProcess.signInWith(authProvider.Google)">
<mat-icon svgIcon="google"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Facebook)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-fab
class="facebook-raised"
(click)="authProcess.signInWith(authProvider.Facebook)">
<mat-icon svgIcon="facebook"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Twitter)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-fab
class="twitter-raised"
(click)="authProcess.signInWith(authProvider.Twitter)">
<mat-icon svgIcon="twitter"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Github)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-fab
class="github-raised"
(click)="authProcess.signInWith(authProvider.Github)">
<mat-icon svgIcon="github"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Microsoft)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-fab
class="microsoft"
(click)="authProcess.signInWith(authProvider.Microsoft)">
<mat-icon svgIcon="microsoft"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Yahoo)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-fab
class="yahoo-raised"
(click)="authProcess.signInWith(authProvider.Yahoo)">
<mat-icon svgIcon="yahoo"></mat-icon>
</button>
</div>
<!--mini-fab-->
<div *ngSwitchCase="themes.MINI_FAB"
class="buttons-raised"
[fxLayout]="layout"
fxLayoutAlign.xs="center center"
[fxLayoutAlign]="layout == 'row' ? 'space-around center' : 'stretch'">
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Google)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-mini-fab
class="google-raised"
fxFlexAlign="center"
(click)="authProcess.signInWith(authProvider.Google)">
<mat-icon svgIcon="google"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Facebook)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-mini-fab
class="facebook-raised"
(click)="authProcess.signInWith(authProvider.Facebook)">
<mat-icon svgIcon="facebook"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Twitter)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-mini-fab
class="twitter-raised"
(click)="authProcess.signInWith(authProvider.Twitter)">
<mat-icon svgIcon="twitter" class="icon-white"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Github)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-mini-fab
class="github-raised"
(click)="authProcess.signInWith(authProvider.Github)">
<mat-icon svgIcon="github"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Microsoft)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-mini-fab
class="microsoft"
(click)="authProcess.signInWith(authProvider.Microsoft)">
<mat-icon svgIcon="microsoft"></mat-icon>
</button>
<button *ngIf="providers === authProvider.ALL || providers.includes(authProvider.Yahoo)"
[@animate]="{value:'*',params:{duration:'300ms',y:'100px'}}"
mat-mini-fab
class="yahoo-raised"
(click)="authProcess.signInWith(authProvider.Yahoo)">
<mat-icon svgIcon="yahoo"></mat-icon>
</button>
</div>
</div>