Skip to content

Commit 5fd07f6

Browse files
authored
Feat | add error selectors (#1480)
* feat(notification): add alert type attribute * feat(load-async): add alert type attribute * feat(not-found): add alert type * refactor(error-selectors): update to use enums instead of strings
1 parent 0c9c70e commit 5fd07f6

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

projects/components/src/load-async/wrapper/load-async-wrapper.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ChangeDetectionStrategy, Component, Inject, InjectionToken, TemplateRef
22
import { IconType } from '@hypertrace/assets-library';
33
import { Observable } from 'rxjs';
44
import { switchMap, tap } from 'rxjs/operators';
5+
import { NotificationMode } from '../../notification/notification.component';
56
import { LoadAsyncStateType } from '../load-async-state.type';
67
import { AsyncState, LoadAsyncConfig, LoadAsyncContext, LoaderType } from '../load-async.service';
78

@@ -21,6 +22,13 @@ export const ASYNC_WRAPPER_PARAMETERS$ = new InjectionToken<Observable<LoadAsync
2122
</ng-container>
2223
<ng-container *ngSwitchDefault>
2324
<ht-message-display
25+
aria-live="polite"
26+
role="alert"
27+
[attr.data-alert-type]="
28+
state.type === '${LoadAsyncStateType.GenericError}'
29+
? '${NotificationMode.Failure}'
30+
: '${NotificationMode.Info}'
31+
"
2432
[icon]="this.icon"
2533
[title]="this.title"
2634
[description]="this.description"

projects/components/src/not-found/not-found.component.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
22
import { ImagesAssetPath } from '@hypertrace/assets-library';
33
import { NavigationService } from '@hypertrace/common';
44
import { ButtonRole, ButtonStyle } from '../button/button';
5+
import { NotificationMode } from '../notification/notification.component';
56

67
@Component({
78
selector: 'ht-not-found',
89
changeDetection: ChangeDetectionStrategy.OnPush,
910
styleUrls: ['./not-found.component.scss'],
1011
template: `
1112
<div class="not-found-container fill-container">
12-
<div class="not-found-content">
13+
<div
14+
class="not-found-content"
15+
role="alert"
16+
aria-live="assertive"
17+
[attr.data-alert-type]="'${NotificationMode.Failure}'"
18+
>
1319
<img class="not-found-image" src="${ImagesAssetPath.ErrorPage}" loading="lazy" alt="not found page" />
1420
<div class="not-found-message-wrapper">
1521
<div class="not-found-text-wrapper">
@@ -30,6 +36,7 @@ import { ButtonRole, ButtonStyle } from '../button/button';
3036
})
3137
export class NotFoundComponent {
3238
public constructor(private readonly navService: NavigationService) {}
39+
3340
public goHome(): void {
3441
this.navService.navigateToHome();
3542
}

projects/components/src/notification/notification.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IconSize } from '../icon/icon-size';
1010
styleUrls: ['./notification.component.scss'],
1111
changeDetection: ChangeDetectionStrategy.OnPush,
1212
template: `
13-
<div class="notification-container">
13+
<div class="notification-container" role="alert" aria-live="polite" [attr.data-alert-type]="this.data.mode">
1414
<ht-icon
1515
[ngClass]="this.data.mode"
1616
class="status-icon"

0 commit comments

Comments
 (0)