import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { faPlay, faStop, faRedo } from '@fortawesome/free-solid-svg-icons'; import { ToastComponent } from '../../../../../ui-essentials/src/lib/components/feedback/toast/toast.component'; @Component({ selector: 'ui-toast-demo', standalone: true, imports: [CommonModule, ToastComponent, FontAwesomeModule], template: `

Toast Demo

Toast notifications provide contextual feedback messages for user actions.

Sizes

@for (size of sizes; track size) {
This is a {{ size }} toast message.
}

Variants

@for (variant of variants; track variant) {
{{ getVariantMessage(variant) }}
}

Configuration Options

This toast cannot be manually dismissed.
This toast has no icon displayed.
This toast shows a progress indicator.

Interactive Examples

Toast Controls

@for (toast of activeToasts; track toast.id) { {{ toast.message }} }

Demo Statistics

Toasts Shown: {{ toastCount }}
Currently Active: {{ activeToasts.length }}
Auto Dismissed: {{ expiredCount }}
Manually Dismissed: {{ dismissedCount }}
`, styleUrl: './toast-demo.component.scss' }) export class ToastDemoComponent { sizes = ['sm', 'md', 'lg'] as const; variants = ['primary', 'success', 'warning', 'danger', 'info'] as const; // Icons readonly faPlay = faPlay; readonly faStop = faStop; readonly faRedo = faRedo; // Toast management activeToasts: any[] = []; private nextToastId = 1; // Statistics toastCount = 0; expiredCount = 0; dismissedCount = 0; getVariantTitle(variant: string): string { const titles = { primary: 'Primary Toast', success: 'Success Toast', warning: 'Warning Toast', danger: 'Error Toast', info: 'Information Toast' }; return titles[variant as keyof typeof titles] || 'Toast'; } getVariantMessage(variant: string): string { const messages = { primary: 'This is a primary notification message.', success: 'Operation completed successfully!', warning: 'Please review your input carefully.', danger: 'An error occurred during processing.', info: 'Here is some helpful information.' }; return messages[variant as keyof typeof messages] || 'Toast message'; } showToast(variant: any, title: string, message: string): void { const toast = { id: this.nextToastId++, variant, title, message, size: 'md' as const, duration: 4000, autoDismiss: true, showProgress: true }; this.activeToasts.push(toast); this.toastCount++; } removeToast(id: number): void { const index = this.activeToasts.findIndex(toast => toast.id === id); if (index > -1) { this.activeToasts.splice(index, 1); } } clearToasts(): void { this.dismissedCount += this.activeToasts.length; this.activeToasts = []; } resetStats(): void { this.toastCount = 0; this.expiredCount = 0; this.dismissedCount = 0; this.activeToasts = []; this.nextToastId = 1; } }