import { Component } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; import { AlertComponent } from "../../../../../ui-essentials/src/public-api"; @Component({ selector: 'ui-alert-demo', standalone: true, imports: [CommonModule, FontAwesomeModule, AlertComponent], template: `

Alert Demo

Sizes

@for (size of sizes; track size) { This is a {{ size }} size alert component demonstration. }

Variants

This is a primary alert for general information or neutral messages. Your action was completed successfully! Everything worked as expected. Please review this information carefully before proceeding. Something went wrong. Please check your input and try again. Here's some helpful information you might want to know.

Without Icons

This alert doesn't show an icon for a cleaner look. This warning alert has no title and no icon.

Dismissible Alerts

@for (dismissibleAlert of dismissibleAlerts; track dismissibleAlert.id) { {{ dismissibleAlert.message }} } @if (dismissibleAlerts.length === 0) {

All dismissible alerts have been dismissed.

}

Without Titles

This is an informational alert without a title. The message stands on its own. This is a dismissible error alert without a title.

Bold Titles

This alert has a bold title to emphasize importance. Bold titles help draw attention to critical messages.

Interactive Examples

Your form has been submitted and will be processed within 24 hours. Don't forget to confirm your email address to complete your subscription.

Size & Variant Combinations

@for (variant of variants; track variant) {

{{ variant | titlecase }}

@for (size of sizes; track size) { {{ variant | titlecase }} {{ size }} alert }
}

Accessibility Features

  • Screen Reader Support: Proper ARIA labels and live regions
  • Keyboard Navigation: Dismissible alerts can be closed with Enter or Space
  • Focus Management: Clear focus indicators on dismiss button
  • Semantic HTML: Proper heading hierarchy and content structure
`, styleUrl: './alert-demo.component.scss' }) export class AlertDemoComponent { sizes = ['sm', 'md', 'lg'] as const; variants = ['primary', 'success', 'warning', 'danger', 'info'] as const; dismissibleAlerts = [ { id: 1, variant: 'success' as const, title: 'Task Completed', message: 'Your task has been completed successfully and saved to your dashboard.' }, { id: 2, variant: 'warning' as const, title: 'Session Expiring', message: 'Your session will expire in 5 minutes. Please save your work.' }, { id: 3, variant: 'info' as const, title: 'New Feature Available', message: 'Check out our new dashboard analytics feature in the sidebar menu.' } ]; private originalDismissibleAlerts = [...this.dismissibleAlerts]; dismissAlert(id: number): void { this.dismissibleAlerts = this.dismissibleAlerts.filter(alert => alert.id !== id); console.log(`Alert with ID ${id} dismissed`); } resetDismissibleAlerts(): void { this.dismissibleAlerts = [...this.originalDismissibleAlerts]; } handleAlertDismissed(type: string): void { console.log(`${type} alert dismissed`); } }