tractatus/public/js/leader-page.js
TheFlow b69b7167a9 feat(leader): WCAG accessibility with 9 accordions, keyboard navigation
- Converted all 9 accordion divs to semantic <button> elements
- Added ARIA attributes: aria-expanded, aria-controls, id for each button
- Accordion content: role="region" and aria-labelledby for screen readers
- Keyboard support: Enter and Space keys toggle accordions (WAI-ARIA pattern)
- Mobile optimization: 44px/48px touch targets, touch-action: manipulation
- iOS tap feedback: -webkit-tap-highlight-color
- Footer i18n: No footer object in leader.json (uses common.json correctly)
- Updated leader-page.js with keyboard handlers and ARIA state management
- Version 1.5.0

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-23 00:19:23 +13:00

48 lines
1.5 KiB
JavaScript

/**
* Leader Page - Accordion Functionality
* Handles expandable/collapsible sections for leadership content
* Implements WAI-ARIA Authoring Practices for accordions
*/
document.addEventListener('DOMContentLoaded', function() {
// Get all accordion buttons
const accordionButtons = document.querySelectorAll('[data-accordion]');
accordionButtons.forEach(button => {
// Click handler
button.addEventListener('click', function() {
const accordionId = this.dataset.accordion;
toggleAccordion(accordionId, this);
});
// Keyboard handler (Enter and Space)
button.addEventListener('keydown', function(e) {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
const accordionId = this.dataset.accordion;
toggleAccordion(accordionId, this);
}
});
});
/**
* Toggle accordion section open/closed
* @param {string} id - Accordion section ID
* @param {HTMLElement} button - The button element that triggered toggle
*/
function toggleAccordion(id, button) {
const content = document.getElementById(id + '-content');
const icon = document.getElementById(id + '-icon');
if (content && icon) {
const isExpanded = content.classList.contains('active');
// Toggle CSS classes for visual state
content.classList.toggle('active');
icon.classList.toggle('active');
// Update ARIA state
button.setAttribute('aria-expanded', isExpanded ? 'false' : 'true');
}
}
});