import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './index.ts'; import type { USAAccordion, AccordionItem } from './usa-accordion.js'; const sampleItems: AccordionItem[] = [ { id: 'accordion-1', title: 'Getting Started', content: `

Welcome to our platform! Here's everything you need to know to get started:

`, expanded: false, }, { id: 'accordion-2', title: 'Account Management', content: `

Manage your account settings and preferences:

`, expanded: false, }, { id: 'accordion-3', title: 'Support & Help', content: `

Get help when you need it:

`, expanded: true, }, ]; const meta: Meta = { title: 'Structure/Accordion', component: 'usa-accordion', parameters: { layout: 'padded', docs: { description: { component: ` # USA Accordion The USA Accordion component uses official USWDS styling and behavior. This component allows users to show and hide sections of related content on a page. ## Usage Guidelines - Follow USWDS design system guidelines - Component uses official USWDS CSS classes - Accessibility features are built-in - Supports keyboard navigation ## Events - \`accordion-toggle\` - Dispatched when accordion item is toggled with detail containing item, index, expanded state, and all items ## Accessibility - Uses proper ARIA roles and attributes - Keyboard navigation support (Enter and Space keys) - Screen reader compatible - Proper heading structure for content hierarchy `, }, }, }, argTypes: { multiselectable: { control: { type: 'boolean' }, description: 'Whether multiple accordion items can be open at the same time', }, bordered: { control: { type: 'boolean' }, description: 'Whether to show borders around accordion items', }, items: { control: { type: 'object' }, description: 'Array of accordion items with id, title, content, and optional expanded state', }, }, args: { multiselectable: false, bordered: false, items: sampleItems, }, }; export default meta; type Story = StoryObj; export const Default: Story = { render: (args) => html` `, }; export const Multiselectable: Story = { args: { multiselectable: true, items: sampleItems.map((item) => ({ ...item, expanded: false })), }, render: (args) => html` `, }; export const Bordered: Story = { args: { bordered: true, items: sampleItems.map((item) => ({ ...item, expanded: false })), }, render: (args) => html` `, }; export const SingleItem: Story = { args: { items: [ { id: 'single-item', title: 'Single Accordion Item', content: '

This is a single accordion item with some content. You can put any HTML content here including lists, links, and other elements.

', expanded: false, }, ], }, render: (args) => html` `, }; export const FAQ: Story = { args: { multiselectable: true, items: [ { id: 'faq-1', title: 'What are the office hours?', content: `

Our office hours are:

We are closed on national holidays.

`, expanded: false, }, { id: 'faq-2', title: 'How can I contact customer service?', content: `

You can reach our customer service team through multiple channels:

`, expanded: false, }, { id: 'faq-3', title: 'Is my personal information secure?', content: `

Yes, we take data security very seriously. Our security measures include:

Read our complete Privacy Policy for more details.

`, expanded: false, }, { id: 'faq-4', title: 'How long does processing take?', content: `

Processing times vary by service type:

Service Standard Processing Expedited Processing
Document Requests 5-10 business days 2-3 business days
Permit Applications 15-20 business days 7-10 business days
Background Checks 30-45 business days 15-20 business days

Note: Processing times may be longer during peak periods.

`, expanded: false, }, ], }, render: (args) => html` `, }; // eslint-disable-next-line @typescript-eslint/no-unused-vars export const CustomContent: Story = { parameters: { controls: { disable: true }, docs: { description: { story: 'Demonstrates using the default slot for custom content after accordion items, including expand/collapse controls.', }, }, }, // ESLint has trouble parsing inline onclick handlers within Lit template literals // These handlers are necessary for Storybook docs mode compatibility /* eslint-disable */ render: () => html`
This section contains custom HTML content with rich formatting.

  • Feature 1: Detailed description of the first feature
  • Feature 2: Information about the second capability
  • Feature 3: Additional functionality notes

Learn more about this topic

`, expanded: false, }, { id: 'custom-2', title: 'Section 2: Technical Details', content: `

Technical specifications and implementation details:

Property Value
Version 3.8.0
Framework Lit Element
CSS USWDS Official
`, expanded: false, }, { id: 'custom-3', title: 'Section 3: Examples', content: `

Here are some practical examples:

Example 1: Basic Usage

const element = document.createElement('usa-accordion');

Example 2: With Properties

element.multiselectable = true;
`, expanded: false, }, ]} >

Accordion Controls

Use these buttons to expand or collapse all accordion sections at once:

Note: This demonstrates using the default slot for custom content. You can add any HTML elements including buttons, forms, or additional information.

`, /* eslint-enable */ };