add notification service + component

This commit is contained in:
X4Lo committed 2024-04-03 21:41:28 +00:00
1 parent 939a6e32ef
commit 9512e5bd28
5 files changed
+189

No files matched your search

@@ -0,0 +1,16 @@
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.notification {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 1050; /* Ensure it's above other content */
margin-bottom: 20px; /* Adjust based on size and desired spacing */
animation: fadeIn 1s ease-out; /* Use the fadeIn animation, lasts 1 second */
}
.notif-back {
background-color: aliceblue;
}
@@ -0,0 +1,13 @@
<div class="notification">
<div class="alert alert-border-success alert-dismissible fade show notif-back">
<div class="d-flex align-items-center">
<div class="font-35 text-success"><span class="material-icons-outlined fs-2">check_circle</span>
</div>
<div class="ms-3">
<h6 class="mb-0 text-success">{{title}}</h6>
<div class="">{{message}}</div>
</div>
</div>
<button type="button" class="btn-close"></button>
</div>
</div>
@@ -0,0 +1,21 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NotificationPopupComponent } from './notification-popup.component';
describe('NotificationPopupComponent', () => {
let component: NotificationPopupComponent;
let fixture: ComponentFixture<NotificationPopupComponent>;
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [NotificationPopupComponent]
});
fixture = TestBed.createComponent(NotificationPopupComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
@@ -0,0 +1,30 @@
import { Component } from '@angular/core';
@Component({
selector: 'app-notification-popup',
templateUrl: './notification-popup.component.html',
styleUrls: ['./notification-popup.component.css'],
})
export class NotificationPopupComponent {
show: boolean = false;
title: string = 'Alert';
message: string = 'Alert Message...';
type: string = 'alert';
constructor() {}
ngOnInit(): void {}
public showNotification(
title: string,
message: string,
type: string = 'alert',
timeout: number = 3000
): void {
this.title = title;
this.message = message;
this.type = type;
this.show = true;
setTimeout(() => (this.show = false), timeout);
}
}