3 ui updates

This commit is contained in:
Armin Abaye
2026-04-13 17:41:27 -04:00
parent 23db21e0bf
commit c7989110eb
17 changed files with 218 additions and 60 deletions
@@ -0,0 +1,25 @@
import { Injectable, signal } from '@angular/core';
export type ToastType = 'success' | 'error' | 'info';
export interface Toast {
id: number;
message: string;
type: ToastType;
}
@Injectable({ providedIn: 'root' })
export class ToastService {
private nextId = 0;
readonly toasts = signal<Toast[]>([]);
show(message: string, type: ToastType = 'success') {
const id = ++this.nextId;
this.toasts.update(list => [...list, { id, message, type }]);
setTimeout(() => this.dismiss(id), 3000);
}
dismiss(id: number) {
this.toasts.update(list => list.filter(t => t.id !== id));
}
}