Skip to content

Commit

Permalink
feat(auth): add back button (#556)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnixaa committed Jul 6, 2018
1 parent 4715b04 commit 36fc953
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/framework/auth/components/auth.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
height: calc(100vh - 2 * #{$auth-layout-padding});
}

nb-card-header {
a {
text-decoration: none;
i {
font-size: 2rem;
font-weight: bold;
}
}
}

nb-card {
margin: 0;
}
Expand Down
12 changes: 11 additions & 1 deletion src/framework/auth/components/auth.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*/
import { Component, OnDestroy } from '@angular/core';
import { Location } from '@angular/common';

import { NbAuthService } from '../services/auth.service';
import { takeWhile } from 'rxjs/operators';

Expand All @@ -14,6 +16,9 @@ import { takeWhile } from 'rxjs/operators';
<nb-layout>
<nb-layout-column>
<nb-card>
<nb-card-header>
<a href="#" (click)="back()"><i class="nb-arrow-thin-left"></i></a>
</nb-card-header>
<nb-card-body>
<div class="flex-centered col-xl-4 col-lg-6 col-md-8 col-sm-12">
<router-outlet></router-outlet>
Expand All @@ -34,7 +39,7 @@ export class NbAuthComponent implements OnDestroy {
token: string = '';

// showcase of how to use the onAuthenticationChange method
constructor(protected auth: NbAuthService) {
constructor(protected auth: NbAuthService, protected location: Location) {

this.subscription = auth.onAuthenticationChange()
.pipe(takeWhile(() => this.alive))
Expand All @@ -43,6 +48,11 @@ export class NbAuthComponent implements OnDestroy {
});
}

back() {
this.location.back();
return false;
}

ngOnDestroy(): void {
this.alive = false;
}
Expand Down

0 comments on commit 36fc953

Please sign in to comment.