import type { Meta, StoryObj } from '@storybook/web-components-vite'; import { html } from 'lit'; import './index.ts'; import type { USABanner } from './usa-banner.js'; const meta: Meta = { title: 'Feedback/Banner', component: 'usa-banner', parameters: { layout: 'padded', docs: { description: { component: ` The Banner component provides website information and security notices. It helps users understand website authenticity and security features. The banner is collapsible, allowing users to expand it to read detailed information about domains and HTTPS security features. `, }, }, }, argTypes: { flagImageSrc: { control: 'text', description: 'Source URL for the U.S. flag image', }, flagImageAlt: { control: 'text', description: 'Alt text for the flag image', }, dotGovIconSrc: { control: 'text', description: 'Source URL for the .gov icon', }, httpsIconSrc: { control: 'text', description: 'Source URL for the HTTPS/lock icon', }, headerText: { control: 'text', description: 'Main banner header text', }, actionText: { control: 'text', description: 'Action text for toggle button', }, expanded: { control: 'boolean', description: 'Whether banner content is expanded', }, }, }; export default meta; type Story = StoryObj; export const Default: Story = { args: { flagImageSrc: '/img/us_flag_small.png', flagImageAlt: 'U.S. flag', dotGovIconSrc: '/img/icon-dot-gov.svg', httpsIconSrc: '/img/icon-https.svg', headerText: 'An official website of the United States government', actionText: "Here's how you know", expanded: false, }, }; export const Expanded: Story = { args: { ...Default.args, expanded: true, }, }; export const CustomHeaderText: Story = { args: { ...Default.args, headerText: 'This is an official U.S. government website', actionText: 'Learn more about government websites', }, }; export const CustomImages: Story = { args: { ...Default.args, flagImageSrc: '/img/us_flag_small.png', dotGovIconSrc: '/img/icon-dot-gov.svg', httpsIconSrc: '/img/icon-https.svg', }, render: (args) => html`

Note: This story demonstrates using local image paths. The images are served from the public/img directory via Storybook's static files configuration.

`, }; export const DifferentLanguage: Story = { args: { flagImageSrc: '/img/us_flag_small.png', flagImageAlt: 'Bandera de EE.UU.', dotGovIconSrc: '/img/icon-dot-gov.svg', httpsIconSrc: '/img/icon-https.svg', headerText: 'Un sitio web oficial del gobierno de Estados Unidos', actionText: 'Así es como usted puede verificarlo', expanded: false, }, }; export const AlwaysExpanded: Story = { args: { ...Default.args, expanded: true, }, render: (args) => html`

Note: This story shows the banner in its expanded state to demonstrate the full content.

`, }; export const InteractiveDemo: Story = { args: { ...Default.args, }, render: (args) => html` { console.log('Banner toggled:', e.detail); const status = document.getElementById('banner-status'); if (status) { status.textContent = `Banner is now ${e.detail.expanded ? 'expanded' : 'collapsed'}`; setTimeout(() => { if (status) status.textContent = ''; }, 3000); } }} >

Government Banner Testing Guide

Banner Features:

  • Helps users identify website authenticity
  • Explains domain and HTTPS security features
  • Builds user trust in digital services
  • Provides clear security information

Accessibility Features:

  • Screen reader compatible with proper ARIA attributes
  • Keyboard navigation support (Tab, Enter, Space)
  • High contrast design for visual accessibility
  • Semantic HTML structure for assistive technologies

Interactive Testing:

  • Click "Here's how you know" to toggle content
  • Use keyboard navigation (Tab to button, Enter/Space to toggle)
  • Test with screen readers
  • Verify all images have proper alt text
  • Check banner content for government requirements
`, }; export const MobileFriendly: Story = { args: { ...Default.args, }, parameters: { viewport: { defaultViewport: 'mobile1', }, }, render: (args) => html`

Mobile View: The banner adapts to smaller screens while maintaining all required information and functionality.

Test the toggle functionality and ensure all text remains readable on mobile devices.

`, }; export const KeyboardNavigation: Story = { args: { ...Default.args, }, render: (args) => html`

Keyboard Navigation Demo

Instructions:

  1. Press Tab to focus the toggle button
  2. Press Enter or Space to expand/collapse
  3. Use Tab to continue navigation after the banner

This button helps test Tab order and keyboard navigation flow.

`, }; export const CustomStylingExample: Story = { args: { ...Default.args, }, render: (args) => html`

Custom Styling Example

This example shows how you can customize the banner appearance while maintaining USWDS compliance:

  • Added colored bottom border
  • Enhanced header text font weight
  • Custom focus indicator styling

Note: Always ensure customizations maintain accessibility guidelines.

`, };