import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './index.ts'; import type { USAButton } from './usa-button.js'; const meta: Meta = { title: 'Actions/Button', component: 'usa-button', parameters: { layout: 'padded', docs: { description: { component: ` # USA Button The USA Button component provides consistent styling and behavior for buttons across applications. Based on the USWDS Button component, it supports multiple variants, sizes, and states. ## Usage Guidelines - Use primary buttons for the most important actions - Use secondary buttons for less important actions - Use outline buttons for alternative actions - Always provide clear, descriptive button text - Ensure buttons have appropriate contrast and focus states ## Accessibility - Buttons automatically include proper ARIA attributes - Focus management is handled automatically - Screen reader support is built-in - Keyboard navigation works out of the box `, }, }, }, argTypes: { variant: { control: { type: 'select' }, options: ['primary', 'secondary', 'accent-cool', 'accent-warm', 'base', 'outline', 'inverse'], description: 'Button style variant', }, size: { control: { type: 'select' }, options: ['small', 'medium', 'big'], description: 'Button size', }, disabled: { control: { type: 'boolean' }, description: 'Whether the button is disabled', }, type: { control: { type: 'select' }, options: ['button', 'submit', 'reset'], description: 'Button type attribute', }, ariaLabel: { control: { type: 'text' }, description: 'ARIA label for accessibility', }, ariaPressed: { control: { type: 'select' }, options: [null, 'true', 'false'], description: 'ARIA pressed state for toggle buttons', }, onclick: { action: 'clicked' }, onfocus: { action: 'focused' }, onblur: { action: 'blurred' }, }, args: { variant: 'primary', size: 'medium', disabled: false, type: 'button', }, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { variant: 'primary', }, render: (args) => html` Primary Button `, }; export const Secondary: Story = { args: { variant: 'secondary', }, render: (args) => html` Secondary Button `, }; export const Outline: Story = { args: { variant: 'outline', }, render: (args) => html` Outline Button `, }; export const Sizes: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`
Small Medium Big
`, }; export const AllVariants: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`
Primary Secondary Accent Cool Accent Warm Base Outline
`, }; export const Disabled: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`
Disabled Primary Disabled Secondary Disabled Outline
`, }; export const AccessibilityFeatures: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`

ARIA Labels

× Save

Form Integration

Try the keyboard (Tab, Space, Enter) and form submission:

Submit Form Reset Form Regular Button

Keyboard Navigation

Use Tab to navigate, Space or Enter to activate:

Focus me with Tab Then this one Can't focus (disabled)
`, }; export const FormExample: Story = { parameters: { controls: { disable: true }, // Static demo - no interactive controls needed }, render: () => html`
{ e.preventDefault(); alert('Form submitted!'); }} @reset=${() => { alert('Form reset!'); }} >

Form with USWDS Buttons

Submit Reset
`, }; // Interactive Demo Stories export const InteractiveDemo: Story = { parameters: { controls: { disable: true }, // Complex demo - uses action handlers for interaction actions: { handles: ['click', 'focus', 'blur', 'mousedown', 'mouseup'], }, }, render: () => html`

Actions Panel Testing

Click buttons below to test Actions panel functionality

Output: Click any button - check both console and Actions panel below.

HTML Button Tests

Lit Template Tests

USA Button Components

Primary Secondary Outline
`, };