From d9764bfc0e659caf7e7d8966b37a624e0fddf892 Mon Sep 17 00:00:00 2001 From: Polianin Nikita Date: Fri, 16 Feb 2024 10:35:55 +0300 Subject: [PATCH] style: add a better loader color display --- src/components/notification/notification.component.html | 4 ++-- src/components/notification/notification.component.ts | 4 ++++ src/services/open-notify.service.ts | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/notification/notification.component.html b/src/components/notification/notification.component.html index a7c5dbd..9d17851 100644 --- a/src/components/notification/notification.component.html +++ b/src/components/notification/notification.component.html @@ -1,11 +1,11 @@
{{ data.message }} - +
@if (showProgressBar) { - + } diff --git a/src/components/notification/notification.component.ts b/src/components/notification/notification.component.ts index f065398..d74d56b 100644 --- a/src/components/notification/notification.component.ts +++ b/src/components/notification/notification.component.ts @@ -19,12 +19,16 @@ import {MatIconButton} from "@angular/material/button"; export class NotificationComponent { showProgressBar: boolean = false; progress: number = 100; + color: string = "primary"; constructor(@Inject(MAT_SNACK_BAR_DATA) public data: any, private snackBarRef: MatSnackBarRef) { if (data.duration) { this.startProgress(data.duration); this.showProgressBar = true; } + if (data.color) { + this.color = data.color; + } } dismiss(): void { diff --git a/src/services/open-notify.service.ts b/src/services/open-notify.service.ts index de07ea9..c935dff 100644 --- a/src/services/open-notify.service.ts +++ b/src/services/open-notify.service.ts @@ -43,7 +43,12 @@ export class OpenNotifyService { open(message: string, color: NotifyColor = NotifyColor.Basic, duration: number = 5000) { this.setColorClass = color; this._snackBar.openFromComponent(NotificationComponent, { - data: {message: message, duration: duration, className: this.colorClass}, + data: { + message: message, + duration: duration, + className: this.colorClass, + color: color === NotifyColor.Danger ? "accent" : "primary" + }, duration: duration, verticalPosition: 'top', horizontalPosition: 'center',