Skip to content

Latest commit

 

History

History
54 lines (41 loc) · 2.85 KB

File metadata and controls

54 lines (41 loc) · 2.85 KB

RiskGauge Color-Blind Safe Patterns (v7)

Summary

Added color-blind safe patterns to RiskGauge sector arcs to distinguish risk levels beyond color alone, complying with WCAG 1.4.1 (Use of Color).

Changes Made

1. src/styles/patterns.css

Added three new pattern classes for risk level sectors:

  • .risk-gauge-pattern--high: Diagonal stripes (stroke-dasharray: 4, 3)
  • .risk-gauge-pattern--medium: Dots pattern (stroke-dasharray: 1, 6 with round caps)
  • .risk-gauge-pattern--low: Crosshatch-like alternating dashes (stroke-dasharray: 8, 4)

Each pattern uses CSS stroke-dasharray to create distinct visual textures that work alongside the existing color coding (success/warning/error).

Added @media (forced-colors: active) override to ensure patterns work in high-contrast mode by falling back to solid CanvasText strokes.

2. src/components/RiskGauge.tsx

  • Imported ../styles/patterns.css to load the pattern definitions
  • Updated sector arc path element to include both risk-gauge-sector-arc and the appropriate pattern class (risk-gauge-pattern--${sector.id})
  • No API changes - this is a visual enhancement only

3. src/components/RiskGauge.test.tsx

Added focused test: "each sector arc has a color-blind safe pattern class"

  • Verifies that high, medium, and low sector arcs receive their respective pattern classes
  • Ensures the pattern classes are correctly applied based on sector ID

Visual Changes

  • High risk zone (70-100): Green with diagonal stripe pattern
  • Medium risk zone (50-69): Amber with dot pattern
  • Low risk zone (0-49): Red with alternating dash pattern

These patterns provide additional visual distinction for users with color vision deficiencies while maintaining the existing color semantics for sighted users.

Accessibility Impact

  • Improves WCAG 1.4.1 compliance by providing non-color differentiation
  • Patterns are subtle and don't interfere with the existing color coding
  • High-contrast mode override ensures compatibility with Windows high-contrast themes
  • No changes to screen reader behavior or keyboard navigation

Testing

  • Added unit test to verify pattern classes are applied correctly
  • Test verifies each sector (high, medium, low) receives its corresponding pattern class
  • Existing accessibility tests continue to pass

Browser Compatibility

  • Uses standard CSS stroke-dasharray property with wide browser support
  • Patterns degrade gracefully in browsers that don't support dasharray (falls back to solid color)
  • High-contrast mode override ensures visibility in forced-colors environments

Notes

  • Patterns are applied via CSS classes only - no JavaScript logic changes
  • The implementation follows the existing pattern established in patterns.css for other components (e.g., RepaymentVisualizer)
  • Design tokens and dark-mode consistency are maintained through the use of existing color variables