Services: add toast
This commit is contained in:
parent
22cc1dcc01
commit
7ee8e7e3ed
9 changed files with 94 additions and 1 deletions
|
|
@ -0,0 +1,7 @@
|
|||
:host {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: 0.5em;
|
||||
z-index: 1200;
|
||||
}
|
||||
|
|
@ -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>
|
||||
}
|
||||
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue