import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './index.js'; import type { USAModal } from './usa-modal.js'; const meta: Meta = { title: 'Feedback/Modal', component: 'usa-modal', parameters: { layout: 'padded', docs: { description: { component: ` The USA Modal component provides accessible dialog windows for displaying important information, confirmations, and forms without navigating away from the current page. It includes focus trapping, keyboard navigation, and proper ARIA attributes. ## Features - Focus management and trapping - Keyboard navigation (Tab, Escape) - Backdrop click to close (configurable) - Force action mode for critical dialogs - Large modal variant for complex content - Built-in or external trigger buttons - Full USWDS compliance `, }, }, }, argTypes: { heading: { control: 'text', description: 'Modal title/heading text', }, description: { control: 'text', description: 'Description text below heading', }, triggerText: { control: 'text', description: 'Text for the built-in trigger button', }, showTrigger: { control: 'boolean', description: 'Whether to show the built-in trigger button', }, large: { control: 'boolean', description: 'Use large modal variant', }, forceAction: { control: 'boolean', description: 'Prevent closing without action (no X button, no Escape)', }, primaryButtonText: { control: 'text', description: 'Text for primary action button', }, secondaryButtonText: { control: 'text', description: 'Text for secondary action button', }, showSecondaryButton: { control: 'boolean', description: 'Show secondary action button', }, }, }; export default meta; type Story = StoryObj; export const Default: Story = { render: (args) => html` `, args: { heading: 'Modal Heading', description: 'This is a basic modal dialog with default settings.', triggerText: 'Open Modal', primaryButtonText: 'Continue', secondaryButtonText: 'Cancel', showTrigger: true, large: false, forceAction: false, showSecondaryButton: true, }, }; export const LargeModal: Story = { render: (args) => html` `, args: { heading: 'Large Modal Example', description: 'This modal demonstrates the large variant with more horizontal space for tables, forms, or detailed content.', triggerText: 'Open Large Modal', large: true, showSecondaryButton: true, }, }; export const ForceActionModal: Story = { render: (args) => html` `, args: { heading: 'Confirm Critical Action', description: 'This modal requires you to choose an action. You cannot close it by clicking outside or pressing Escape.', triggerText: 'Open Force Action Modal', forceAction: true, primaryButtonText: 'Confirm', secondaryButtonText: 'Cancel', showSecondaryButton: true, }, }; export const SingleActionModal: Story = { render: (args) => html` `, args: { heading: 'Information Notice', description: 'This modal has only one action button, useful for simple notifications.', triggerText: 'Show Notice', primaryButtonText: 'Got it', showSecondaryButton: false, }, }; // ============================================================================= // SLOT-BASED CUSTOMIZATION EXAMPLES // These stories show how to use slots for advanced customization // ============================================================================= /** * FORM IN MODAL * Real-world example: User feedback form with proper USWDS form styling */ export const FormExample: Story = { parameters: { docs: { description: { story: ` **Real-world example: A feedback form inside a modal** This shows: - Using \`slot="body"\` to add a complete form - Proper USWDS form classes and structure - Large modal for better form layout - How the form appears inside the modal body `, }, }, }, render: () => html`
`, }; /** * CONFIRMATION WITH DETAILS * Real-world example: Delete confirmation with item details */ export const ConfirmationWithDetails: Story = { parameters: { docs: { description: { story: ` **Real-world example: Confirmation dialog with details** This shows: - Using \`slot="body"\` to add detailed information - Force action mode for critical decisions - Clear primary/secondary button labels - Structured content with lists and emphasis `, }, }, }, render: () => html`
  • All personal information and profile data
  • 12 saved projects and associated files
  • Comment history (324 comments)
  • Account settings and preferences
`, }; /** * MULTI-STEP ACTIONS * Real-world example: Custom footer with multiple action options */ export const MultiStepActions: Story = { parameters: { docs: { description: { story: ` **Real-world example: Save with multiple options** This shows: - Using \`slot="footer"\` to create custom button groups - Multiple action buttons (Save, Save as Draft, Cancel) - Proper USWDS button variants and styling - Required \`data-close-modal\` attribute on all buttons `, }, }, }, render: () => html`

You have unsaved changes to "Project Proposal - Draft 3.docx"

Last saved: 10 minutes ago

`, }; /** * RICH CONTENT DISPLAY * Real-world example: Terms and conditions with formatted content */ export const RichContentExample: Story = { parameters: { docs: { description: { story: ` **Real-world example: Terms and conditions display** This shows: - Using \`slot="body"\` for long-form content - Proper USWDS prose styling - Large modal for better readability - Structured content with headings and lists `, }, }, }, render: () => html`

1. Acceptance of Terms

By accessing and using this service, you accept and agree to be bound by the terms and provision of this agreement.

2. Privacy Policy

Your use of our service is also governed by our Privacy Policy, which includes:

  • How we collect and use your personal information
  • Your rights regarding your data
  • How we protect your information

3. User Responsibilities

You agree to:

  • Provide accurate and complete information
  • Maintain the security of your account
  • Comply with all applicable laws and regulations

Last updated: January 15, 2024

`, }; /** * ANNOUNCEMENT WITH BRANDING * Real-world example: Feature announcement with custom heading */ export const BrandedAnnouncement: Story = { parameters: { docs: { description: { story: ` **Real-world example: Feature announcement with branding** This shows: - Using \`slot="heading"\` for custom heading with tags/badges - Using \`slot="description"\` for rich formatted intro - Using \`slot="body"\` for the main content - Alert component nested inside modal - Complete visual customization while maintaining USWDS structure `, }, }, }, render: () => html` NEW Version 2.0 Released!

We've launched major improvements!

Thank you for your patience. Here's what's new in version 2.0:

  • 🚀 Enhanced Performance: Pages load 50% faster with optimized code
  • 🎨 Modern Design: Refreshed interface with improved accessibility
  • 📊 Advanced Analytics: New reporting dashboard with real-time insights
  • 🔒 Better Security: End-to-end encryption for all data
`, };