From ce9c72016da27ca5430ff484922bbe91f9a8d581 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Wed, 27 Jan 2021 07:08:31 +0100 Subject: [PATCH] Add back button --- projects/common/src/fm/common.module.ts | 4 ++- .../back-button/back-button.component.html | 4 +++ .../back-button/back-button.component.scss | 12 +++++++++ .../back-button/back-button.component.spec.ts | 25 +++++++++++++++++++ .../back-button/back-button.component.ts | 18 +++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 projects/common/src/fm/components/back-button/back-button.component.html create mode 100644 projects/common/src/fm/components/back-button/back-button.component.scss create mode 100644 projects/common/src/fm/components/back-button/back-button.component.spec.ts create mode 100644 projects/common/src/fm/components/back-button/back-button.component.ts diff --git a/projects/common/src/fm/common.module.ts b/projects/common/src/fm/common.module.ts index bd08884..007b100 100644 --- a/projects/common/src/fm/common.module.ts +++ b/projects/common/src/fm/common.module.ts @@ -56,6 +56,7 @@ import { SecureOAuthStorage} from './shared/secureOAuthStorage'; import { GradientComponent } from './components/gradient/gradient.component'; import { GradientSelectComponent } from './components/gradient-select/gradient-select.component'; import { AppMenuComponent } from './components/app-menu/app-menu.component'; +import { BackButtonComponent } from './components/back-button/back-button.component'; export { SafePipe, @@ -128,7 +129,8 @@ export { UserMenuComponent, GradientComponent, GradientSelectComponent, - AppMenuComponent + AppMenuComponent, + BackButtonComponent ], exports: [ NgbModule, diff --git a/projects/common/src/fm/components/back-button/back-button.component.html b/projects/common/src/fm/components/back-button/back-button.component.html new file mode 100644 index 0000000..91f49e7 --- /dev/null +++ b/projects/common/src/fm/components/back-button/back-button.component.html @@ -0,0 +1,4 @@ +
+ Back +
+ \ No newline at end of file diff --git a/projects/common/src/fm/components/back-button/back-button.component.scss b/projects/common/src/fm/components/back-button/back-button.component.scss new file mode 100644 index 0000000..a76decf --- /dev/null +++ b/projects/common/src/fm/components/back-button/back-button.component.scss @@ -0,0 +1,12 @@ +@import "../../../../node_modules/bootstrap"; + +.back-button { + cursor: default; + color: $primary; + display: inline; +} + +.back-button:hover { + cursor: pointer; + color: $secondary; +} diff --git a/projects/common/src/fm/components/back-button/back-button.component.spec.ts b/projects/common/src/fm/components/back-button/back-button.component.spec.ts new file mode 100644 index 0000000..30d11e5 --- /dev/null +++ b/projects/common/src/fm/components/back-button/back-button.component.spec.ts @@ -0,0 +1,25 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { BackButtonComponent } from './back-button.component'; + +describe('BackButtonComponent', () => { + let component: BackButtonComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ BackButtonComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(BackButtonComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/common/src/fm/components/back-button/back-button.component.ts b/projects/common/src/fm/components/back-button/back-button.component.ts new file mode 100644 index 0000000..c4630cf --- /dev/null +++ b/projects/common/src/fm/components/back-button/back-button.component.ts @@ -0,0 +1,18 @@ +import {Component, HostListener} from '@angular/core'; +import {Location} from "@angular/common"; + +@Component({ + selector: 'fm-back-button', + templateUrl: './back-button.component.html', + styleUrls: ['./back-button.component.scss'] +}) +export class BackButtonComponent { + + @HostListener('click') + onBackClicked() { + this.location.back(); + } + + constructor(private location: Location) { } + +}