Services: add toast

This commit is contained in:
Toast 2025-01-29 10:33:53 +01:00
parent 22cc1dcc01
commit 7ee8e7e3ed
9 changed files with 94 additions and 1 deletions

View file

@ -0,0 +1,7 @@
:host {
position: fixed;
top: 0;
right: 0;
margin: 0.5em;
z-index: 1200;
}

View file

@ -0,0 +1,7 @@
@for (toast of toastService.toasts; track toast) {
<ngb-toast
[header]="toast.header || ''" [autohide]="true" [delay]="toast.delay || 5000"
(hidden)="toastService.remove(toast)"
[animation]="true" [class]="toast.htmlClass"
>{{ toast.body }}</ngb-toast>
}

View file

@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ToastContainerComponent } from './toast-container.component';
describe('ToastContainerComponent', () => {
let component: ToastContainerComponent;
let fixture: ComponentFixture<ToastContainerComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [ToastContainerComponent]
})
.compileComponents();
fixture = TestBed.createComponent(ToastContainerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View file

@ -0,0 +1,15 @@
import {Component, inject} from '@angular/core';
import {ToastService} from '../../../services/toast/toast.service';
import {NgbToast} from '@ng-bootstrap/ng-bootstrap';
@Component({
selector: 'app-toast-container',
imports: [
NgbToast
],
templateUrl: './toast-container.component.html',
styleUrl: './toast-container.component.css'
})
export class ToastContainerComponent {
toastService: ToastService = inject(ToastService);
}