codebyplan 1.13.48 → 1.13.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/cli.js +2 -1
  2. package/package.json +1 -1
  3. package/templates/agents/cbp-round-executor.md +8 -6
  4. package/templates/agents/cbp-stripe-agent.md +173 -0
  5. package/templates/agents/cbp-task-planner.md +2 -2
  6. package/templates/hooks/cbp-skill-context-guard.sh +52 -0
  7. package/templates/hooks/cbp-test-hooks.sh +144 -0
  8. package/templates/hooks/hooks.json +9 -0
  9. package/templates/rules/model-invocation-convention.md +40 -0
  10. package/templates/rules/parallel-waves.md +1 -1
  11. package/templates/rules/task-routing-recommendation.md +1 -1
  12. package/templates/settings.project.base.json +15 -1
  13. package/templates/skills/cbp-build-cc-settings/reference/cbp-permission-policy.md +42 -0
  14. package/templates/skills/cbp-clear-continue/SKILL.md +86 -0
  15. package/templates/skills/cbp-clear-prep/SKILL.md +121 -0
  16. package/templates/skills/cbp-round-execute/SKILL.md +9 -1
  17. package/templates/skills/cbp-round-start/SKILL.md +1 -1
  18. package/templates/skills/cbp-stripe/SKILL.md +116 -0
  19. package/templates/skills/cbp-stripe/reference/billing.md +106 -0
  20. package/templates/skills/cbp-stripe/reference/connect.md +105 -0
  21. package/templates/skills/cbp-stripe/reference/payments.md +107 -0
  22. package/templates/skills/cbp-stripe/reference/security.md +117 -0
  23. package/templates/skills/cbp-stripe/reference/stripe-mcp-setup.md +59 -0
  24. package/templates/skills/cbp-stripe/reference/tax.md +96 -0
  25. package/templates/skills/cbp-stripe/reference/treasury.md +87 -0
  26. package/templates/skills/cbp-task-check/SKILL.md +12 -5
  27. package/templates/skills/cbp-task-complete/SKILL.md +9 -11
  28. package/templates/skills/cbp-task-complete/reference/checkpoint-done-branching.md +14 -21
  29. package/templates/skills/cbp-task-complete/reference/next-step-heuristic.md +4 -6
  30. package/templates/skills/cbp-task-testing/SKILL.md +9 -14
  31. package/templates/skills/cbp-frontend-a11y/SKILL.md +0 -108
  32. package/templates/skills/cbp-frontend-a11y/reference/aria-roles-states.md +0 -130
  33. package/templates/skills/cbp-frontend-a11y/reference/contrast-visual.md +0 -122
  34. package/templates/skills/cbp-frontend-a11y/reference/keyboard-patterns.md +0 -154
  35. package/templates/skills/cbp-frontend-a11y/reference/semantic-html.md +0 -111
@@ -1,108 +0,0 @@
1
- ---
2
- name: cbp-frontend-a11y
3
- description: Pre-implementation accessibility playbook loaded BEFORE writing UI / styling code. Produces a per-component checklist of WCAG 2.1 AA obligations from semantic HTML, ARIA roles/states, keyboard patterns, and contrast requirements.
4
- effort: xhigh
5
- ---
6
-
7
- # Frontend Accessibility (Pre-Implementation Playbook)
8
-
9
- Loaded by `round-executor` Step 2.6 BEFORE any UI or styling file is written, AFTER `frontend-design` has committed to an aesthetic direction. Produces a concrete pre-write checklist — not a post-implementation audit.
10
-
11
- ## When this skill fires
12
-
13
- Invoked when the wave's `skill_preloads[]` contains `"frontend-a11y"` (set by planner Phase 5.6 when `wave.files[]` includes UI-bearing paths). See `rules/frontend-accessibility-invocation.md` for the trigger gate.
14
-
15
- If none of the wave files are UI-bearing, skip — proceed to Step 3.
16
-
17
- ## Phase 1: Read tokens and sibling components
18
-
19
- 1. Identify design tokens from the plan's context or `frontend-design` output — colour tokens are needed for contrast checks.
20
- 2. Glob for sibling components in the same directory as files being authored. Read 1-2 examples to understand existing `aria-*` usage, `role` attributes, keyboard handlers, focus management patterns.
21
- 3. Note the established a11y posture: does the codebase already use `role="dialog"` patterns? Does it trap focus in modals? Are there custom keyboard handlers?
22
-
23
- ## Phase 2: Detect the stack
24
-
25
- Read the planner's `test_strategy.platform` or grep for signal files:
26
-
27
- | Signal | Stack |
28
- |--------|-------|
29
- | `next.config.ts` | Next.js (App Router) |
30
- | `expo` in deps | React Native / Expo |
31
- | `tauri.conf.json` | Tauri web view |
32
-
33
- Load the matching reference doc from `reference/` (relative to this SKILL.md):
34
-
35
- - Next.js / web: read `reference/semantic-html.md`, `reference/aria-roles-states.md`, `reference/keyboard-patterns.md`, `reference/contrast-visual.md`
36
- - React Native: read `reference/aria-roles-states.md`, `reference/contrast-visual.md` (semantic HTML n/a for RN)
37
- - Tauri web view: same as Next.js / web
38
-
39
- ## Phase 3: Load reference docs
40
-
41
- For the detected stack, read EACH applicable reference doc in sequence. Do not skip — the pre-write checklist is derived from their combined content.
42
-
43
- Reference docs (paths relative to this SKILL.md):
44
-
45
- - `reference/semantic-html.md` — landmark roles, heading hierarchy, element semantics, anti-patterns
46
- - `reference/aria-roles-states.md` — role table, aria-label vs aria-labelledby, live regions, expanded/pressed/hidden
47
- - `reference/keyboard-patterns.md` — focus management, tab order, Esc, arrow keys, focus traps, type-ahead
48
- - `reference/contrast-visual.md` — WCAG 2.1 AA ratios, focus-visible, colour-only state, reduced-motion, touch targets
49
-
50
- ## Phase 4: Commit to per-component obligations
51
-
52
- For each component or element type in `wave.files[]`, derive explicit obligations from the reference docs. Group by component:
53
-
54
- ```
55
- Component: <ComponentName> (<path>)
56
- - Semantic: [e.g. "use <button> not <div onClick>"]
57
- - ARIA: [e.g. "aria-expanded on disclosure trigger"]
58
- - Keyboard: [e.g. "Esc closes; focus returns to trigger"]
59
- - Contrast: [e.g. "border token needs 3:1 vs background — verify"]
60
- - Touch: [e.g. "min 44x44px tap target on mobile"]
61
- ```
62
-
63
- Unknown component types get the universal checklist from Phase 5.
64
-
65
- ## Phase 5: Universal guidelines (applied to every component)
66
-
67
- Regardless of component type, every UI component must satisfy:
68
-
69
- 1. Every interactive element is keyboard-reachable and activatable (Enter/Space for buttons, Enter for links)
70
- 2. Focus-visible is never removed via `outline: none` without a custom indicator meeting 3:1 contrast
71
- 3. No state conveyed via colour alone — icon + text + colour
72
- 4. `prefers-reduced-motion` media query wraps any animation
73
- 5. Touch targets ≥ 44×44 CSS px
74
- 6. Images have `alt` text (decorative images use `alt=""`)
75
- 7. Form inputs have associated `<label htmlFor>` or `aria-label`
76
-
77
- ## Phase 6: Output pre-write checklist
78
-
79
- Produce a flat checklist in `round.context.frontend_a11y_checklist`:
80
-
81
- ```yaml
82
- frontend_a11y_checklist:
83
- - component: "<ComponentName>"
84
- file: "<path>"
85
- items:
86
- - "[Semantic] use <button> not <div onClick>"
87
- - "[ARIA] aria-expanded on trigger; aria-controls referencing panel id"
88
- - "[Keyboard] Esc closes panel; focus returns to trigger"
89
- - "[Contrast] verify focus ring token meets 3:1 vs background"
90
- - "[Touch] min 44x44px on mobile breakpoint"
91
- ```
92
-
93
- The executor consults this checklist when authoring each component in Step 3.
94
-
95
- ## Output back to round-executor
96
-
97
- ```yaml
98
- round.context.frontend_a11y_loaded: true
99
- round.context.frontend_a11y_checklist: [per-component checklist items]
100
- ```
101
-
102
- ## Integration
103
-
104
- - **Invoked by**: `round-executor` Step 2.6 (when `"frontend-a11y"` in `wave.skill_preloads[]`)
105
- - **Reads**: `reference/semantic-html.md`, `reference/aria-roles-states.md`, `reference/keyboard-patterns.md`, `reference/contrast-visual.md`
106
- - **Output consumed by**: `round-executor` Step 3 (implementation guidance)
107
- - **Pairs with**: `frontend-design` (invoked first in Step 2.6), `frontend-ui` + `frontend-ux` (post-implementation Step 3.8)
108
- - **Trigger rule**: `rules/frontend-accessibility-invocation.md`
@@ -1,130 +0,0 @@
1
- # ARIA Roles, States, and Properties Reference
2
-
3
- **Golden rule**: Prefer native HTML semantics. ARIA fills gaps — it does not replace semantic elements. An `<input type="checkbox">` is always better than `<div role="checkbox">`.
4
-
5
- ## When to Add a Role
6
-
7
- Use `role` ONLY when no native HTML element maps to the semantic need:
8
-
9
- | Pattern | Native element | ARIA role (fallback) |
10
- |---------|---------------|----------------------|
11
- | Dialog / modal | — | `role="dialog"` + `aria-modal="true"` |
12
- | Alerting status message | — | `role="status"` or `role="alert"` |
13
- | Tab list | — | `role="tablist"`, `role="tab"`, `role="tabpanel"` |
14
- | Custom listbox | — | `role="listbox"`, `role="option"` |
15
- | Progress indicator | `<progress>` | `role="progressbar"` if `<progress>` unstyled |
16
- | Tooltip | `title` attr (limited) | `role="tooltip"` + `aria-describedby` |
17
-
18
- ## aria-label vs aria-labelledby vs aria-describedby
19
-
20
- | Attribute | Use when | Priority |
21
- |-----------|----------|----------|
22
- | `aria-labelledby` | A visible text element names this element | Highest — overrides aria-label and native label |
23
- | `aria-label` | No visible text label exists (icon buttons, close buttons) | Medium |
24
- | `aria-describedby` | Additional descriptive text supplements the label | Lowest — supplementary, not a primary name |
25
-
26
- Examples:
27
- ```jsx
28
- // Icon button — no visible label
29
- <button aria-label="Close dialog">
30
- <Icon name="x" aria-hidden="true" />
31
- </button>
32
-
33
- // Element labelled by visible heading
34
- <section aria-labelledby="billing-heading">
35
- <h2 id="billing-heading">Billing</h2>
36
- </section>
37
-
38
- // Field with hint text
39
- <input id="password" aria-describedby="password-hint" />
40
- <span id="password-hint">Must be at least 8 characters</span>
41
- ```
42
-
43
- ## Live Regions
44
-
45
- Announce dynamic content changes to screen readers without moving focus.
46
-
47
- | Role / Attribute | Urgency | Use for |
48
- |-----------------|---------|---------|
49
- | `aria-live="polite"` | Waits for user to be idle | Status messages, form validation summaries, search result counts |
50
- | `aria-live="assertive"` | Interrupts immediately | Critical errors, session timeout warnings |
51
- | `role="status"` | Same as `aria-live="polite"` | Status messages (shorthand) |
52
- | `role="alert"` | Same as `aria-live="assertive"` | Error alerts (shorthand) |
53
-
54
- Anti-pattern: using `role="alert"` for non-urgent messages — screen reader interruptions are disruptive. Reserve for true emergencies.
55
-
56
- ```jsx
57
- // Status (polite)
58
- <div role="status" aria-live="polite">{statusMessage}</div>
59
-
60
- // Error (assertive)
61
- <div role="alert">{errorMessage}</div>
62
- ```
63
-
64
- ## Common State Attributes
65
-
66
- | Attribute | Values | Use for |
67
- |-----------|--------|---------|
68
- | `aria-expanded` | `true` / `false` | Disclosure triggers (accordion, dropdown, menu) |
69
- | `aria-pressed` | `true` / `false` / `"mixed"` | Toggle buttons (bold, like, mute) |
70
- | `aria-hidden` | `true` | Decorative elements, icon-only images — removes from accessibility tree |
71
- | `aria-checked` | `true` / `false` / `"mixed"` | Custom checkbox/radio when not using `<input type="checkbox">` |
72
- | `aria-disabled` | `true` | Visually disabled but still focusable (use sparingly) |
73
- | `aria-selected` | `true` / `false` | Selected tab, selected option in listbox |
74
- | `aria-current` | `"page"` / `"step"` / `true` | Current item in nav, current step in wizard |
75
-
76
- ```jsx
77
- // Accordion trigger
78
- <button
79
- aria-expanded={isOpen}
80
- aria-controls="panel-1"
81
- >
82
- Section title
83
- </button>
84
- <div id="panel-1" hidden={!isOpen}>...</div>
85
-
86
- // Toggle button
87
- <button
88
- aria-pressed={isBold}
89
- onClick={() => setIsBold(!isBold)}
90
- >
91
- Bold
92
- </button>
93
-
94
- // Decorative icon
95
- <svg aria-hidden="true" focusable="false">...</svg>
96
- ```
97
-
98
- ## aria-hidden Usage Rules
99
-
100
- - `aria-hidden="true"` removes element and ALL descendants from accessibility tree
101
- - Never place `aria-hidden="true"` on a focusable element (keyboard users still reach it)
102
- - Common correct uses: decorative icons, background images, duplicate visible text (when the accessible name comes from aria-label)
103
-
104
- ```jsx
105
- // Correct: icon inside labelled button
106
- <button aria-label="Delete">
107
- <TrashIcon aria-hidden="true" />
108
- </button>
109
-
110
- // Wrong: aria-hidden on focusable element
111
- <button aria-hidden="true">...</button> // users can still Tab to it
112
- ```
113
-
114
- ## Dialog Pattern
115
-
116
- ```jsx
117
- <dialog
118
- role="dialog"
119
- aria-modal="true"
120
- aria-labelledby="dialog-title"
121
- aria-describedby="dialog-description"
122
- >
123
- <h2 id="dialog-title">Confirm deletion</h2>
124
- <p id="dialog-description">This action cannot be undone.</p>
125
- <button onClick={onConfirm}>Delete</button>
126
- <button onClick={onClose}>Cancel</button>
127
- </dialog>
128
- ```
129
-
130
- Focus must move INTO the dialog on open and RETURN to the trigger on close. See `keyboard-patterns.md` for focus trap implementation.
@@ -1,122 +0,0 @@
1
- # Contrast and Visual Accessibility Reference
2
-
3
- ## WCAG 2.1 AA Contrast Requirements
4
-
5
- All text and UI components must meet these minimum contrast ratios:
6
-
7
- | Content type | Minimum ratio | Standard |
8
- |-------------|--------------|---------|
9
- | Normal text (< 18pt / < 14pt bold) | **4.5:1** | WCAG 2.1 AA SC 1.4.3 |
10
- | Large text (≥ 18pt / ≥ 14pt bold) | **3:1** | WCAG 2.1 AA SC 1.4.3 |
11
- | UI components (borders, icons, form controls) | **3:1** | WCAG 2.1 AA SC 1.4.11 |
12
- | Graphical objects (data chart elements, icons conveying meaning) | **3:1** | WCAG 2.1 AA SC 1.4.11 |
13
-
14
- **Decorative** elements (purely ornamental, no meaning) are EXEMPT.
15
-
16
- ### Verification
17
-
18
- Use design tokens from `packages/design-tokens/` to derive hex values, then verify with a contrast checker:
19
-
20
- - Browser DevTools Accessibility panel
21
- - `npx @accessibility-checker/cli` against the rendered component
22
- - Design-tool plugins (Figma Contrast, Stark)
23
-
24
- If a token pair is new, record the ratio in a comment in the SCSS: `/* contrast: 5.2:1 vs --color-surface */`.
25
-
26
- ## Focus Visible
27
-
28
- Focus indicators must NEVER be suppressed via `outline: none` or `outline: 0` without providing a replacement that meets **3:1 contrast** against adjacent colour:
29
-
30
- ```scss
31
- // Anti-pattern — removes all visible focus indicator
32
- &:focus {
33
- outline: none; // WCAG failure
34
- }
35
-
36
- // Correct — custom focus ring that meets 3:1 contrast
37
- &:focus-visible {
38
- outline: 2px solid var(--color-focus-ring); // 3:1 minimum
39
- outline-offset: 2px;
40
- }
41
- ```
42
-
43
- Use `:focus-visible` (not `:focus`) for the custom ring — `:focus-visible` suppresses the ring for mouse clicks while preserving it for keyboard navigation.
44
-
45
- The WCAG 2.2 enhanced criterion (SC 2.4.11, AAA) requires 3:1 contrast + 2px outline area. Target this for new components.
46
-
47
- ## Colour-Only State Communication
48
-
49
- State conveyed through colour alone is a WCAG 2.1 AA failure (SC 1.4.1). Always pair colour with at least one of: icon, text label, pattern, or shape.
50
-
51
- | Anti-pattern | Fix |
52
- |-------------|-----|
53
- | Red border = error (colour only) | Red border + error icon + "Invalid email" text |
54
- | Green = online (colour only) | Green dot + "Online" text label |
55
- | Yellow = warning (colour only) | Yellow background + warning icon + descriptive text |
56
- | Active nav item is blue (colour only) | Blue + `aria-current="page"` + underline or bold weight |
57
-
58
- ## prefers-reduced-motion
59
-
60
- Users with vestibular disorders may configure `prefers-reduced-motion: reduce` in their OS. Honour it:
61
-
62
- ```scss
63
- @keyframes slideIn {
64
- from { transform: translateX(-100%); }
65
- to { transform: translateX(0); }
66
- }
67
-
68
- .panel {
69
- animation: slideIn 300ms ease-out;
70
-
71
- @media (prefers-reduced-motion: reduce) {
72
- animation: none;
73
- // Provide instant appearance or a fade (no translate/scale/spin)
74
- }
75
- }
76
- ```
77
-
78
- For JavaScript-driven animations:
79
-
80
- ```ts
81
- const prefersReduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
82
- if (!prefersReduced) {
83
- // run animation
84
- }
85
- ```
86
-
87
- Transitions that solely affect `opacity` (fade) are generally safe — opacity changes do not trigger vestibular responses. Transforms (`translate`, `scale`, `rotate`) and large motion sweeps are the primary triggers.
88
-
89
- ## Touch Target Size
90
-
91
- Interactive elements must have a minimum tap target of **44 × 44 CSS px** (Apple HIG / WCAG 2.5.5 AAA, de-facto standard):
92
-
93
- ```scss
94
- .icon-button {
95
- min-width: 44px;
96
- min-height: 44px;
97
- display: flex;
98
- align-items: center;
99
- justify-content: center;
100
- }
101
- ```
102
-
103
- When the visible icon is smaller (e.g. 24px), expand the tap target with padding:
104
-
105
- ```scss
106
- .icon-button {
107
- padding: 10px; // 24px icon + 2×10px padding = 44px touch target
108
- }
109
- ```
110
-
111
- On mobile breakpoints specifically, verify that adjacent interactive elements have at least 8px spacing between tap target edges to prevent accidental activation.
112
-
113
- ## Text Resizing
114
-
115
- Users who increase browser text size up to 200% must be able to read and use all content without horizontal scroll (WCAG 1.4.4). Use relative units:
116
-
117
- - `font-size`: `rem` (relative to browser root, respects user preference)
118
- - `line-height`: unitless (e.g. `1.5`) or `em`
119
- - Container widths: `max-width` in `ch` or `%`, never fixed `px` for reading columns
120
- - Spacing: `em` for component-internal spacing; `rem` for layout spacing
121
-
122
- Avoid `px` for font sizes on text elements that users may need to scale.
@@ -1,154 +0,0 @@
1
- # Keyboard Interaction Patterns Reference
2
-
3
- Every interactive component must be fully operable with a keyboard alone. Mouse-only patterns are WCAG 2.1 AA failures (Success Criterion 2.1.1).
4
-
5
- ## Focus Management
6
-
7
- ### On Mount (Dialog / Modal / Drawer)
8
-
9
- When a dialog, modal, or drawer opens:
10
-
11
- 1. Move focus to the FIRST interactive element inside (or to the dialog container if no interactive element exists — ensure `tabindex="0"` on the container in that case)
12
- 2. For modals with a clear primary action: move focus to the primary action button
13
- 3. For forms: move focus to the first form field
14
-
15
- ```jsx
16
- // Using useEffect + ref
17
- const modalRef = useRef<HTMLDivElement>(null);
18
-
19
- useEffect(() => {
20
- if (isOpen) {
21
- // Focus the first focusable element inside
22
- const firstFocusable = modalRef.current?.querySelector<HTMLElement>(
23
- 'button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'
24
- );
25
- firstFocusable?.focus();
26
- }
27
- }, [isOpen]);
28
- ```
29
-
30
- ### On Close (Dialog / Modal / Drawer)
31
-
32
- When a dialog, modal, or drawer closes:
33
-
34
- 1. Return focus to the element that TRIGGERED the opening (save a ref to it before opening)
35
- 2. If the trigger no longer exists (deleted row), focus the nearest logical element
36
-
37
- ```jsx
38
- const triggerRef = useRef<HTMLButtonElement>(null);
39
-
40
- const handleClose = () => {
41
- setIsOpen(false);
42
- // Return focus to trigger
43
- triggerRef.current?.focus();
44
- };
45
- ```
46
-
47
- ## Tab Order
48
-
49
- - Tab order must follow the logical reading/interaction order — typically top-left to bottom-right
50
- - Never use `tabindex > 0` — it creates a separate tab order before natural DOM order, confusing all keyboard users
51
- - `tabindex="0"` adds a non-interactive element to natural tab order (use sparingly — prefer interactive elements)
52
- - `tabindex="-1"` removes from natural tab order but allows programmatic `.focus()` (correct for modal containers)
53
-
54
- ## Esc Key
55
-
56
- Any overlay, popover, dropdown, or modal MUST close on `Escape`:
57
-
58
- ```jsx
59
- useEffect(() => {
60
- const handleKeyDown = (e: KeyboardEvent) => {
61
- if (e.key === 'Escape') {
62
- onClose();
63
- }
64
- };
65
- if (isOpen) {
66
- document.addEventListener('keydown', handleKeyDown);
67
- return () => document.removeEventListener('keydown', handleKeyDown);
68
- }
69
- }, [isOpen, onClose]);
70
- ```
71
-
72
- ## Arrow Key Navigation
73
-
74
- For composite widgets (menu, listbox, radio group, tabs, grid), arrow keys navigate BETWEEN items — Tab moves focus OUT of the widget entirely.
75
-
76
- | Widget | Keys |
77
- |--------|------|
78
- | Menu / dropdown | `↑`/`↓` between items, `Home`/`End` to first/last |
79
- | Tabs | `←`/`→` between tabs (horizontal) or `↑`/`↓` (vertical) |
80
- | Listbox | `↑`/`↓` between options, `Home`/`End` |
81
- | Grid | `↑`/`↓`/`←`/`→` between cells |
82
- | Radio group | `↑`/`↓` or `←`/`→` between radios; selection follows focus |
83
-
84
- ## Focus Traps (Modal)
85
-
86
- While a modal is open, Tab and Shift+Tab must cycle WITHIN the modal — not escape to the page behind:
87
-
88
- ```jsx
89
- const FOCUSABLE_SELECTORS =
90
- 'button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
91
-
92
- const handleTabKey = (e: KeyboardEvent) => {
93
- const focusableEls = Array.from(
94
- modalRef.current?.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTORS) ?? []
95
- );
96
- const first = focusableEls[0];
97
- const last = focusableEls[focusableEls.length - 1];
98
-
99
- if (e.shiftKey && document.activeElement === first) {
100
- e.preventDefault();
101
- last.focus();
102
- } else if (!e.shiftKey && document.activeElement === last) {
103
- e.preventDefault();
104
- first.focus();
105
- }
106
- };
107
- ```
108
-
109
- Library alternative: `focus-trap-react` handles this pattern with accessibility compliance. If it is already in `package.json`, use it.
110
-
111
- ## Type-Ahead (Listbox / Menu)
112
-
113
- When a user types a character while focus is inside a listbox or menu, focus jumps to the first item whose label starts with that character. Implement only when `role="listbox"` or `role="menu"` is used with custom keyboard handling — native `<select>` has this built in.
114
-
115
- ## Enter and Space Activation
116
-
117
- | Element | Enter | Space |
118
- |---------|-------|-------|
119
- | `<button>` | Activates | Activates |
120
- | `<a href>` | Follows link | Scrolls page (native browser) |
121
- | `<input type="checkbox">` | n/a | Toggles |
122
- | `role="button"` | Must activate | Must activate |
123
- | `role="menuitem"` | Activates | Activates |
124
-
125
- For custom `role="button"` on a non-button element:
126
- ```jsx
127
- <div
128
- role="button"
129
- tabIndex={0}
130
- onKeyDown={(e) => {
131
- if (e.key === 'Enter' || e.key === ' ') {
132
- e.preventDefault();
133
- handleActivate();
134
- }
135
- }}
136
- onClick={handleActivate}
137
- >
138
- Custom button
139
- </div>
140
- ```
141
-
142
- Prefer `<button>` — it handles Enter/Space natively and avoids this boilerplate.
143
-
144
- ## Skip Links
145
-
146
- For pages with repeated navigation (header nav present on every page), provide a skip-to-main-content link as the first focusable element:
147
-
148
- ```jsx
149
- <a href="#main-content" className={styles.skipLink}>
150
- Skip to main content
151
- </a>
152
- ```
153
-
154
- Visible on focus (via CSS), hidden otherwise. The `<main id="main-content">` is the target.
@@ -1,111 +0,0 @@
1
- # Semantic HTML Reference
2
-
3
- Use native HTML semantics first. ARIA is a gap-filler for when no native element meets the need — not a replacement.
4
-
5
- ## Landmark Roles
6
-
7
- | Element | Role | Notes |
8
- |---------|------|-------|
9
- | `<main>` | `main` | Exactly ONE per page |
10
- | `<nav>` | `navigation` | Multiple allowed; each needs an `aria-label` |
11
- | `<header>` | `banner` (at page scope) | In a sectioning element it becomes generic |
12
- | `<footer>` | `contentinfo` (at page scope) | |
13
- | `<aside>` | `complementary` | |
14
- | `<section>` | `region` (only when it has an `aria-labelledby`) | Without label, it's generic |
15
-
16
- Anti-pattern: `<div role="main">` — use `<main>` instead.
17
-
18
- ## Heading Hierarchy
19
-
20
- - One `<h1>` per page — the page title or primary content heading
21
- - Never skip levels: `h1 → h2 → h3`, not `h1 → h3`
22
- - Headings convey structure, not visual size — use CSS for size; use the correct level for hierarchy
23
- - Empty headings (`<h2></h2>`) violate WCAG 2.4.6
24
-
25
- ## `<button>` vs `<a>`
26
-
27
- | Use | Element |
28
- |-----|---------|
29
- | Triggers an action (submit, open modal, toggle) | `<button>` |
30
- | Navigates to a URL | `<a href="...">` |
31
- | Downloads a file | `<a href="..." download>` |
32
-
33
- Anti-patterns:
34
- - `<div onClick={doAction}>` — not keyboard accessible; use `<button>`
35
- - `<button onClick={() => router.push('/path')}>` — use `<a href="/path">`; or `<Link href="/path">` in Next.js
36
- - `<a href="#">` with an onClick — use `<button>` if no real URL
37
-
38
- ## Form Elements
39
-
40
- ```html
41
- <!-- Correct: explicit association -->
42
- <label htmlFor="email-input">Email</label>
43
- <input id="email-input" type="email" name="email" />
44
-
45
- <!-- Correct: implicit wrapping -->
46
- <label>
47
- Email
48
- <input type="email" name="email" />
49
- </label>
50
-
51
- <!-- Anti-pattern: no association -->
52
- <span>Email</span>
53
- <input type="email" name="email" />
54
- ```
55
-
56
- For fieldsets with radio/checkbox groups:
57
- ```html
58
- <fieldset>
59
- <legend>Preferred contact method</legend>
60
- <label><input type="radio" name="contact" value="email" /> Email</label>
61
- <label><input type="radio" name="contact" value="phone" /> Phone</label>
62
- </fieldset>
63
- ```
64
-
65
- ## Lists
66
-
67
- Use `<ul>/<ol>/<li>` for lists of items — screen readers announce item count and position.
68
-
69
- Anti-pattern: `<div class="list"><div class="item">...</div></div>` — no count/position announced.
70
-
71
- Exception: `list-style: none` on `<ul>` removes list semantics in Safari/VoiceOver. Add `role="list"` when list-style is suppressed:
72
- ```jsx
73
- <ul role="list" style={{ listStyle: 'none' }}>
74
- ```
75
-
76
- ## Tables
77
-
78
- For data tables (not layout):
79
- ```html
80
- <table>
81
- <caption>Monthly sales by region</caption>
82
- <thead>
83
- <tr>
84
- <th scope="col">Region</th>
85
- <th scope="col">Sales</th>
86
- </tr>
87
- </thead>
88
- <tbody>
89
- <tr>
90
- <th scope="row">North</th>
91
- <td>$12,000</td>
92
- </tr>
93
- </tbody>
94
- </table>
95
- ```
96
-
97
- `<caption>` is the table's accessible name. `scope="col"/"row"` associates headers with cells.
98
-
99
- Never use `<table>` for visual layout — use CSS Grid or Flexbox.
100
-
101
- ## Anti-Pattern Quick-Reference
102
-
103
- | Anti-pattern | Fix |
104
- |-------------|-----|
105
- | `<div onClick>` | `<button>` or `<a>` |
106
- | `<span onClick>` | `<button>` |
107
- | `<img>` missing `alt` | Add `alt="description"` or `alt=""` for decorative |
108
- | `<input>` missing label | Add `<label htmlFor>` or `aria-label` |
109
- | `<h1>` used for styling | Use CSS; pick correct heading level |
110
- | `<table>` for layout | Use CSS Grid/Flexbox |
111
- | Empty `<button>` (icon only) | Add `aria-label="Close"` |