import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './index.ts'; import type { USAAlert } from './usa-alert.js'; const meta: Meta = { title: 'Feedback/Alert', component: 'usa-alert', parameters: { layout: 'padded', docs: { description: { component: ` The **Alert** component communicates system status messages to users. It provides feedback about the results of user actions or system processes. This implementation matches USWDS specification exactly. ## Features - **Multiple Types**: Info, warning, error, success, and emergency variants - **Accessible**: Proper ARIA roles and screen reader support - **Flexible Content**: Supports headings and custom HTML content via slots - **Styling Options**: Slim variant and no-icon option - **USWDS Compliant**: Uses official USWDS classes and structure ## Usage Guidelines Use alerts to: - Notify users of successful actions - Warn about potential issues - Display error messages - Provide important system information - Communicate urgent updates Note: This component follows USWDS specification and does not include dismissible functionality. `, }, }, }, argTypes: { variant: { control: 'select', options: ['info', 'warning', 'error', 'success', 'emergency'], description: 'Type of alert that determines color and icon', }, heading: { control: 'text', description: 'Optional heading for the alert', }, slim: { control: 'boolean', description: 'Use slim styling for less prominent alerts', }, noIcon: { control: 'boolean', description: 'Remove the default icon', }, }, }; export default meta; type Story = StoryObj; // Default story export const Default: Story = { args: { variant: 'info', heading: 'Information', }, render: (args) => html` This is an informational message for users. `, }; // All alert types export const Info: Story = { args: { variant: 'info', heading: 'Information', }, render: (args) => html` This is useful information that may help users understand what they need to do next. `, }; export const Success: Story = { args: { variant: 'success', heading: 'Success', }, render: (args) => html` Your action was completed successfully. `, }; export const Warning: Story = { args: { variant: 'warning', heading: 'Warning', }, render: (args) => html` Please review the information below carefully. `, }; export const Error: Story = { args: { variant: 'error', heading: 'Error', }, render: (args) => html` There was an error processing your request. `, }; export const Emergency: Story = { args: { variant: 'emergency', heading: 'Emergency Alert', }, render: (args) => html` This is an urgent notification requiring immediate attention. `, }; // Variations export const SlimAlert: Story = { name: 'Slim Alert', args: { variant: 'info', slim: true, }, render: (args) => html` This is a slim alert for less prominent notifications. `, }; export const NoIcon: Story = { name: 'No Icon', args: { variant: 'success', heading: 'Success (No Icon)', noIcon: true, }, render: (args) => html` This alert has no icon. `, }; // Message only (no heading) export const MessageOnly: Story = { name: 'Message Only', args: { variant: 'info', }, render: (args) => html` This alert has only a message with no heading. `, }; // Heading only (no message) export const HeadingOnly: Story = { name: 'Heading Only', args: { variant: 'success', heading: 'Operation Complete', }, render: (args) => html` `, }; // Custom content via slot export const CustomContent: Story = { name: 'Custom Content', args: { variant: 'info', heading: 'Custom Content', }, render: (args) => html`

This alert contains custom HTML content including:

  • A bulleted list
  • A link
  • Bold text

You can put any HTML content in the slot.

`, }; // Multiple alerts - Static demo showing multiple alerts together export const MultipleAlerts: Story = { name: 'Multiple Alerts', parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`
Your changes have been saved. Please review your input before continuing. New features are available in your account.
`, }; // Form validation example - Static demo showing form validation pattern export const FormValidation: Story = { name: 'Form Validation', parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`
  • Email address is required
  • Password must be at least 8 characters
  • Phone number format is invalid
Form submitted successfully!
`, }; // Interactive Demo - Complex interactive example with buttons export const InteractiveDemo: Story = { name: 'Interactive Demo', parameters: { controls: { disable: true }, // Complex demo - uses custom buttons for interaction }, render: () => html`

Alert Demo

Click buttons below to see different alert types:

`, };