import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './index.js'; import type { USASummaryBox } from './usa-summary-box.js'; const meta: Meta = { title: 'Data Display/Summary Box', component: 'usa-summary-box', parameters: { layout: 'padded', docs: { description: { component: ` The USA Summary Box component provides a prominent way to highlight key information, important announcements, or critical summaries. It follows USWDS design patterns with proper semantic structure and accessibility features. ## Features - Semantic heading elements (h1-h6) - Support for both property and slot content - HTML content rendering with unsafeHTML - Light DOM for USWDS CSS compatibility - Accessibility-compliant implementation `, }, }, }, argTypes: { heading: { control: 'text', description: 'Main heading text for the summary box', }, headingLevel: { control: 'select', options: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'], description: 'Semantic heading level for accessibility', }, content: { control: 'text', description: 'HTML content to display (alternative to slot content)', }, }, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { heading: 'Important Information', headingLevel: 'h3', }, render: (args) => html`

This is the default summary box with slot content. Use summary boxes to highlight key information that users need to know.

`, }; export const AllHeadingLevels: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`

This summary box uses an H1 heading, typically for page-level summaries.

This summary box uses an H2 heading, typically for major section summaries.

This summary box uses an H3 heading (default), typically for subsection summaries.

This summary box uses an H4 heading, typically for minor section summaries.

This summary box uses an H5 heading, typically for detailed subsection summaries.

This summary box uses an H6 heading, typically for the most detailed summary level.

`, }; export const WithHTMLContent: Story = { args: { heading: 'Benefits Summary', headingLevel: 'h2', content: `

Nutrition Assistance Program helps eligible families purchase nutritious food.

Income limits and eligibility requirements apply.

`, }, }; export const WithSlotContent: Story = { args: { heading: 'Small Business Resources', headingLevel: 'h3', }, render: (args) => html`

The Business Support Center provides resources for entrepreneurs and small business owners.

Available Programs:

  • Business Loans: Low-interest financing for business expansion and working capital
  • Mentorship Programs: Free business mentoring and workshops
  • Innovation Funding: Research and development funding for innovative businesses
  • Contracting Opportunities: Networking and contract opportunities

Support Available: Financial assistance programs available for eligible businesses.

Find Local Help: Contact your nearest District Office or Resource Partner

Explore Loan Programs | Find a Mentor | Business Contracting

`, }; export const MixedContent: Story = { args: { heading: 'Content Flexibility Demo', headingLevel: 'h3', content: '

This content comes from the content property. It will override any slot content.

', }, render: (args) => html`

This slot content will not be displayed when the content property has a value.

Toggle the content property in the controls to see slot content.

`, }; export const WithoutHeading: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`

This summary box has no heading - just content. This might be useful for simpler announcements or when the heading is part of the content itself.

Self-Contained Content

The content includes its own heading structure and formatting.

`, }; export const AccessibilityShowcase: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`

Proper Heading Hierarchy

Summary boxes maintain semantic heading structure for screen readers:

This summary uses H3, following the page's H2 above.

This summary uses H4, creating proper hierarchy.

Accessibility Features

  • Semantic HTML: Uses proper heading elements (h1-h6)
  • Screen Reader Support: Content is announced in logical order
  • Keyboard Navigation: All interactive elements are focusable
  • Color Independence: Information is not conveyed by color alone
  • Focus Management: Clear focus indicators for all interactive elements

Test with keyboard navigation: Test Link

`, }; export const InteractiveDemo: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`

Interactive Summary Box Demo

Use the Storybook controls panel to modify the summary box properties in real-time:

  • heading: Change the summary box title
  • headingLevel: Test different semantic heading levels
  • content: Add HTML content (overrides slot content)

This is the default slot content. It will be replaced if you add content via the property control.

Try it: Use the controls panel to modify this summary box's properties!

`, };