-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add specific header component for error pages
* current difference to the simple header: logo link with reloading link instead of router link
- Loading branch information
Showing
8 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/app/shell/header/header-error/header-error.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<div class="header header-error container"> | ||
<div class="mid-header"> | ||
<div class="logo-wrapper d-none d-md-block"> | ||
<a | ||
rel="home" | ||
[href]="homeHref" | ||
class="logo" | ||
[attr.aria-label]="'common.home.link' | translate" | ||
data-testing-id="header-home-link-desktop" | ||
></a> | ||
</div> | ||
<div class="logo-wrapper d-md-none"> | ||
<a | ||
rel="home" | ||
[href]="homeHref" | ||
class="mobile-logo" | ||
[attr.aria-label]="'common.home.link' | translate" | ||
data-testing-id="link-home" | ||
></a> | ||
</div> | ||
</div> | ||
</div> |
31 changes: 31 additions & 0 deletions
31
src/app/shell/header/header-error/header-error.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { TranslateModule } from '@ngx-translate/core'; | ||
|
||
import { HeaderErrorComponent } from './header-error.component'; | ||
|
||
describe('Header Error Component', () => { | ||
let component: HeaderErrorComponent; | ||
let fixture: ComponentFixture<HeaderErrorComponent>; | ||
let element: HTMLElement; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [TranslateModule.forRoot()], | ||
declarations: [HeaderErrorComponent], | ||
providers: [{ provide: APP_BASE_HREF, useValue: '/' }], | ||
}).compileComponents(); | ||
}); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(HeaderErrorComponent); | ||
component = fixture.componentInstance; | ||
element = fixture.nativeElement; | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(component).toBeTruthy(); | ||
expect(element).toBeTruthy(); | ||
expect(() => fixture.detectChanges()).not.toThrow(); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
src/app/shell/header/header-error/header-error.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { APP_BASE_HREF } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core'; | ||
|
||
/** | ||
* The page header for error pages - the logo link reloads the app | ||
*/ | ||
@Component({ | ||
selector: 'ish-header-error', | ||
templateUrl: './header-error.component.html', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class HeaderErrorComponent implements OnInit { | ||
constructor(@Inject(APP_BASE_HREF) private baseHref: string) {} | ||
|
||
homeHref: string; | ||
|
||
ngOnInit() { | ||
this.homeHref = this.baseHref && this.baseHref !== '/' ? `${this.baseHref}/home` : '/home'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters