---
task_id: sprint_4_story_1_task_6
story_id: sprint_4_story_1
sprint_id: sprint_4
status: not_started
type: frontend
assignee: Frontend Developer 1
created_date: 2025-11-05
estimated_hours: 3
---
# Task 6: Implement Responsive Design and Accessibility
## Description
Ensure the Story detail page works flawlessly on all screen sizes (mobile, tablet, desktop) and meets WCAG 2.1 Level AA accessibility standards. This includes responsive layout adjustments, keyboard navigation, ARIA labels, and focus management.
## What to Do
1. Test and fix responsive layout on all breakpoints
2. Implement mobile-specific UI adjustments (sidebar to tabs)
3. Add keyboard navigation support (Tab, Enter, ESC)
4. Add ARIA labels to all interactive elements
5. Implement focus management (dialog open/close)
6. Ensure proper heading hierarchy (h1 → h2 → h3)
7. Test color contrast ratios (WCAG AA: 4.5:1 minimum)
8. Test with screen reader (NVDA/JAWS)
9. Add skip links for keyboard users
10. Run Lighthouse accessibility audit
## Files to Modify
- `app/(dashboard)/stories/[id]/page.tsx` (modify, responsive tweaks)
- `components/projects/story-header.tsx` (modify, accessibility)
- `components/projects/story-metadata-sidebar.tsx` (modify, responsive)
- All related components (add ARIA labels)
## Implementation Details
### Responsive Layout Breakpoints
```typescript
// app/(dashboard)/stories/[id]/page.tsx
// Adjust grid layout for different screens
{/* Main content - full width on mobile, 70% on desktop */}
{/* Story description, acceptance criteria, tasks */}
{/* Sidebar - full width on mobile (at top), fixed width on desktop */}
```
### Mobile-Specific Adjustments
```typescript
// Convert sidebar sections to tabs on mobile
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
function MobileStoryMetadata({ story, parentEpic }: Props) {
return (
Details
Time
Epic
{/* Status, Priority, Assignee */}
{/* Time tracking, Dates */}
{/* Parent Epic card */}
);
}
```
### ARIA Labels and Roles
```typescript
// Story header with accessibility
{story.title}
{story.status}
{story.priority}
Opens a dialog to edit story title, description, and metadata
Permanently deletes this story and all associated tasks
// Main content sections
Description
{story.description}
Acceptance Criteria
{/* Criteria list */}
// Sidebar
```
### Keyboard Navigation
```typescript
// Add keyboard shortcuts
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
// ESC - Go back to Epic
if (e.key === 'Escape' && !isEditDialogOpen && !isDeleteDialogOpen) {
router.push(`/epics/${story.epicId}`);
}
// Cmd/Ctrl + E - Edit Story
if ((e.metaKey || e.ctrlKey) && e.key === 'e') {
e.preventDefault();
setIsEditDialogOpen(true);
}
// Cmd/Ctrl + Backspace - Delete Story
if ((e.metaKey || e.ctrlKey) && e.key === 'Backspace') {
e.preventDefault();
setIsDeleteDialogOpen(true);
}
};
window.addEventListener('keydown', handleKeyDown);
return () => window.removeEventListener('keydown', handleKeyDown);
}, [isEditDialogOpen, isDeleteDialogOpen]);
// Add keyboard shortcut hints
```
### Focus Management
```typescript
// Trap focus in dialogs
import { useFocusTrap } from '@/lib/hooks/use-focus-trap';
function EditStoryDialog({ isOpen, onClose }: Props) {
const dialogRef = useRef(null);
useFocusTrap(dialogRef, isOpen);
// Auto-focus first field when dialog opens
useEffect(() => {
if (isOpen) {
const firstInput = dialogRef.current?.querySelector('input');
firstInput?.focus();
}
}, [isOpen]);
// Return focus to trigger element when dialog closes
const triggerRef = useRef(null);
const handleOpen = () => {
triggerRef.current = document.activeElement as HTMLButtonElement;
setIsOpen(true);
};
const handleClose = () => {
setIsOpen(false);
triggerRef.current?.focus();
};
return (
);
}
```
### Skip Links
```typescript
// Add skip link for keyboard users
Skip to main content
{/* Main content */}
```
## Acceptance Criteria
### Responsive Design
- [ ] Desktop (> 1024px): Two-column layout (content + sidebar)
- [ ] Tablet (640px - 1024px): Two-column layout with narrower sidebar
- [ ] Mobile (< 640px): Single-column layout, sidebar moves to top or tabs
- [ ] All buttons and controls accessible on touch devices
- [ ] No horizontal scrolling on any screen size
- [ ] Text remains readable on all screen sizes (minimum 14px)
### Accessibility (WCAG 2.1 Level AA)
- [ ] All interactive elements keyboard accessible (Tab navigation)
- [ ] Focus indicators visible (2px outline, high contrast)
- [ ] ARIA labels on all buttons, links, and form controls
- [ ] Proper heading hierarchy (h1 → h2 → h3)
- [ ] Color contrast ratio >= 4.5:1 for all text
- [ ] Large text (18px+) contrast ratio >= 3:1
- [ ] Screen reader announces all content correctly
- [ ] Focus trapped in dialogs (cannot Tab outside)
- [ ] Focus returns to trigger element when dialog closes
- [ ] Skip links available for keyboard users
- [ ] Icons have `aria-hidden="true"` (text labels present)
- [ ] Loading states announced to screen readers (`role="status"`)
- [ ] Error messages announced (`role="alert"`)
### Keyboard Navigation
- [ ] Tab - Navigate through interactive elements
- [ ] Enter - Activate buttons and links
- [ ] Space - Toggle checkboxes and buttons
- [ ] ESC - Close dialogs and navigate back
- [ ] Cmd/Ctrl + E - Edit Story (custom shortcut)
- [ ] Cmd/Ctrl + Backspace - Delete Story (custom shortcut)
## Testing
### Manual Testing
**Responsive Design**:
1. Open Story detail page on desktop → Verify two-column layout
2. Resize to tablet width (768px) → Verify layout adjusts
3. Resize to mobile width (375px) → Verify single-column layout
4. Verify sidebar moves to top on mobile
5. Test all buttons clickable on touch device
6. Verify no horizontal scrolling on any screen
7. Test landscape and portrait orientations
**Keyboard Navigation**:
1. Navigate to Story page using only keyboard
2. Press Tab → Verify focus moves through all interactive elements
3. Verify focus indicator visible (blue outline)
4. Press ESC → Verify navigates back to Epic
5. Press Cmd/Ctrl + E → Verify Edit dialog opens
6. Press Tab in dialog → Verify focus trapped
7. Press ESC in dialog → Verify dialog closes and focus returns
**Screen Reader** (NVDA/JAWS):
1. Enable screen reader
2. Navigate to Story page
3. Verify page structure announced (heading hierarchy)
4. Verify all buttons have labels
5. Verify badges announced with context ("Status: In Progress")
6. Verify loading states announced
7. Verify error messages announced
8. Open Edit dialog → Verify form fields labeled correctly
### Automated Testing
**Lighthouse Audit**:
```bash
# Run Lighthouse accessibility audit
npm run lighthouse
# Expected results:
# Accessibility: >= 90 (ideally 100)
# Best Practices: >= 90
# SEO: >= 90
# Performance: >= 80 (acceptable for dynamic content)
```
**axe DevTools**:
```bash
# Install axe DevTools browser extension
# Open Story page
# Run axe scan
# Expected: 0 violations
```
### Color Contrast Testing
```bash
# Test all text colors
# Use browser DevTools > Accessibility > Color contrast
# Required ratios (WCAG AA):
# Normal text (< 18px): 4.5:1
# Large text (>= 18px): 3:1
# UI components: 3:1
# Test combinations:
Story Title (32px): Should pass (large text)
Description (16px): Should pass 4.5:1
Metadata labels (14px): Should pass 4.5:1
Badges: Should pass 3:1 (UI components)
Buttons: Should pass 3:1 (UI components)
```
## Dependencies
**Prerequisites**:
- Task 1, 2, 3, 4, 5 (all components must exist)
- ✅ shadcn/ui components with built-in accessibility
- ✅ Tailwind CSS responsive utilities
- ✅ ARIA attributes support
**Blocks**:
- None (final polish task)
## Estimated Time
3 hours
## Notes
**Testing Tools**:
- Chrome DevTools > Lighthouse (accessibility audit)
- axe DevTools browser extension (automated WCAG testing)
- NVDA/JAWS screen reader (manual testing)
- WAVE browser extension (visual accessibility check)
- Contrast Checker (color contrast ratios)
**Common Accessibility Issues to Avoid**:
- Missing alt text on images
- Insufficient color contrast
- Missing ARIA labels on icon-only buttons
- Broken keyboard navigation (focus trap)
- Missing heading hierarchy (h1 → h3, skip h2)
- Form inputs without labels
- Loading states not announced to screen readers
**Responsive Design Checklist**:
- Test on real devices (iPhone, Android, tablet)
- Test different orientations (portrait, landscape)
- Test different zoom levels (100%, 150%, 200%)
- Verify touch targets >= 44x44px
- No horizontal scrolling on any screen