Skip to content
TheChatArchiveThe Chat Archive
Step 3.5 Flash· unknownHugging Face Frontier Reasoning Traces

Compose a storybook documentation schema linking accessibility notes, responsive…

  1. User

    Compose a storybook documentation schema linking accessibility notes, responsive behavior, and performance budgets.

  2. Assistant

    Hmm, the user wants a storybook documentation schema that integrates accessibility, responsive behavior, and performance budgets. This is a fairly technical request, likely from a frontend developer or designer working on a design system. They need a structured way to document components that covers multiple important dimensions beyond just visual appearance.

    I should provide a clear, actionable schema that links these three areas in a practical way. Storybook's addon ecosystem already has tools for accessibility (A11y), responsiveness (Viewport), and performance (Performance), so the schema should leverage those. The key is to define how they interconnect in documentation, not just list them separately.

    I'll propose a template with dedicated fields for each area, but also show how they relate—like how responsive breakpoints affect accessibility (e.g., touch targets on mobile) or how performance impacts perceived responsiveness. The user probably needs this for team consistency, so I'll include concrete examples and a checklist format to make it usable.

    The tone should be professional but approachable, avoiding fluff. Since this is for documentation, clarity and precision matter more than storytelling.

    Storybook Documentation Schema: Integrated Accessibility, Responsiveness & Performance

    Overview

    A unified documentation framework for UI components that explicitly links accessibility requirements, responsive behavior, and performance budgets into a single, coherent narrative. This schema ensures these critical quality attributes are designed, built, and verified together—not as afterthoughts.


    Schema Structure

    1. Component Header

    • Component Name: [Button]
    • Primary Purpose: [Trigger an action]
    • Key User Scenarios: [Form submission, navigation, dialog close]
    • Dependencies: [Icon library, theming system]

    2. Core Specification (The "What & Why")

    2.1 Accessibility Notes

    • ARIA Roles & States:
      • Default role: [button]
      • States: [aria-pressed for toggle, aria-disabled when disabled]
      • Linked to: Performance—ARIA updates must be synchronous for screen reader announcements.
    • Keyboard Interaction:
      • Enter/Space activation
      • Focus visible outline (2px minimum)
      • Linked to: Responsive—focus styles must work on touch devices (no hover-only states).
    • Semantic HTML: <button> preferred over <div> for native accessibility.
    • Color Contrast: Minimum 4.5:1 (AA) for text/background. Performance: High-contrast colors must not increase paint time by >5%.
    • Screen Reader Testing: Verified with VoiceOver (iOS), NVDA (Windows), TalkBack (Android).
    • Cognitive Load: Label clarity (avoid "Click Here").

    2.2 Responsive Behavior

    • Breakpoint Strategy:
      • Mobile (<768px): Full-width, large touch target (min 44×44px)
      • Tablet (768–1024px): Compact, icon+text
      • Desktop (>1024px): Standard, hover effects
      • Linked to: Accessibility—touch targets meet WCAG 2.5.5; hover states have focus equivalents.
    • Adaptive Content:
      • Text truncation with aria-label for full text.
      • Icon-only variant requires aria-label.
    • Orientation Changes: Layout shifts <100ms (linked to performance).
    • Input Method Agnostic: Works with mouse, touch, keyboard, voice.

    2.3 Performance Budgets

    • Initial Load:
      • JavaScript: < 3KB gzipped (for button variants)
      • CSS: < 0.5KB (component-specific styles)
    • Interaction Metrics:
      • First Input Delay (FID) for button activation: < 100ms
      • Total Blocking Time (TBT) on page with 10 buttons: < 150ms
    • Rendering:
      • Layout shift (CLS) on button load: < 0.001
      • Paint time for button state changes: < 16ms (60fps)
    • Network:
      • Icon fonts vs. SVG: SVG preferred for <10 icons (fewer requests).
      • Linked to: Accessibility—SVGs must have <title> for screen readers; responsive—SVG scales without pixelation.

    3. Integration Matrix

    ScenarioAccessibility CheckResponsive CheckPerformance Check
    Mobile Touch ActivationTouch target ≥44×44px, no hover-only stylesFull-width on small screensActivation response <100ms
    High Contrast ModeColors meet 7:1 contrast (AAA)Layout doesn’t breakNo repaints on theme switch
    Slow 3G NetworkText remains readable (no icon-only reliance)Buttons remain tappable (no layout collapse)JS loads async, no render-blocking
    Screen Reader NavigationFocus order logical, ARIA live regions for updatesN/AAnnouncements occur within 200ms of state change

    4. Storybook Implementation

    4.1 Addons Required

    • @storybook/addon-a11y: Automates axe-core checks.
    • @storybook/addon-viewport: Tests responsive breakpoints.
    • @storybook/addon-performance (custom): Injects budgets into tests.

    4.2 CSF (Component Story Format) Example

    export default {
      title: 'Components/Button',
      parameters: {
        // Link all three dimensions in metadata
        a11y: { 
          manual: true, // For complex interactions
          config: { rules: { 'color-contrast': { enabled: false } } } // Exception documented
        },
        viewport: {
          viewports: { mobile: 375, tablet: 768, desktop: 1024 },
          defaultViewport: 'mobile'
        },
        performance: {
          budgets: {
            js: 3000, // bytes
            css: 500,
            fid: 100 // ms
          }
        }
      }
    };
    
    // Stories with explicit scenarios
    export const MobileTouchTarget = {
      args: { size: 'large', fullWidth: true },
      parameters: {
        a11y: { 
          notes: 'Touch target 44×44px verified via Chrome DevTools Emulation'
        },
        viewport: { defaultViewport: 'mobile' },
        performance: { 
          metrics: { fid: '85ms' } // Measured in test
        }
      }
    };
    

    4.3 Notes Field Pattern

    Use Storybook’s notes parameter to link all three:

    parameters: {
      notes: `
      ### Accessibility
      - Role: button
      - Focus: visible outline, tabindex=0
      ### Responsive
      - Mobile: full-width, 44px height
      - Desktop: inline, 32px height
      ### Performance
      - Budget: 2KB JS, 0.2KB CSS
      - CLS impact: 0 (static button)
      - **Linked:** Touch target size increases paint area by 12% on mobile (tested).
      `
    }
    

    5. Testing Checklist

    5.1 Automated

    • A11y: Axe-core passes for all stories.
    • Responsive: Layout stable at all breakpoints (no overflow).
    • Performance: Storybook runtime metrics within budgets.

    5.2 Manual Verification

    • Keyboard navigation: Tab order logical, focus visible.
    • Screen reader: Announces label, state changes.
    • Network throttling (3G): Buttons remain usable, no jank.
    • High contrast mode: All states visible.
    • Zoom 200%: No content clipping, touch targets adequate.

    6. Governance & Maintenance

    6.1 Change Impact Assessment

    When modifying a component:

    1. Accessibility Impact: Does ARIA change? Note in PR.
    2. Responsive Impact: New breakpoint? Update viewports in Storybook.
    3. Performance Impact: Size increase? Update budgets in schema.

    6.2 Regression Monitoring

    • Set up CI to:
      • Run @storybook/a11y on all stories.
      • Capture Lighthouse performance scores per story.
      • Detect layout shifts via storybook-addon-perf.

    6.3 Documentation Updates

    • Any change to:
      • Accessibility: Update notes.a11y section.
      • Responsive: Update notes.responsive with new breakpoints.
      • Performance: Log actual vs. budget in notes.performance.

    7. Example: Accessible, Responsive, Fast Button

    ## Button Component
    
    ### Accessibility
    - Native `<button>` element.
    - `aria-pressed` for toggle state.
    - Focus ring: 2px solid blue (#0066CC) on dark/light backgrounds.
    
    ### Responsive
    | Viewport   | Padding | Icon/Text | Touch Target |
    |------------|---------|-----------|--------------|
    | Mobile     | 16px    | Stacked   | 48×48px      |
    | Tablet+    | 12px    | Inline    | 32×32px      |
    
    ### Performance
    - **Budget:** 1.8KB JS, 0.3KB CSS.
    - **Measured:** 1.2KB JS (tree-shaken), FID 62ms on 3G.
    - **Trade-off:** Icon SVG inline (no request) but adds 0.2KB. Justified by zero-latency display.
    
    ### Linked Considerations
    - Mobile touch target size increases click area → potential CLS if not pre-sized. **Solution:** `min-height` in CSS.
    - High-contrast mode requires focus ring color adjustment → CSS custom property (`--focus-color`) used, no JS overhead.
    

    Benefits of This Schema

    1. Prevents Siloed Thinking: Developers see accessibility and performance as responsive design constraints.
    2. Quantifiable Trade-offs: "We increased touch target size by 10px, which added 0.5KB to CSS but kept CLS at 0."
    3. Testable in Storybook: Each story validates all three attributes.
    4. Onboarding Clarity: New team members understand the "why" behind decisions.
    5. Audit Trail: Changes documented with impact across all domains.

    Adoption Roadmap

    1. Phase 1: Implement schema for 5 high-impact components (Button, Input, Modal, Navigation, Card).
    2. Phase 2: Integrate with CI/CD—fail builds on budget breaches or a11y regressions.
    3. Phase 3: Extend to design team—Figma components include accessibility/performance annotations mirroring this schema.
    4. Phase 4: Automate budget tracking via storybook-addon-performance dashboards.

    Final Note: This schema treats accessibility, responsiveness, and performance as interdependent requirements—not separate checkboxes. A component that performs well but isn’t accessible fails users. A responsive component that’s slow fails in real-world conditions. Documentation must reflect this reality.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.