@atlaskit/ads-mcp 0.2.5 → 0.4.0

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 (57) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +57 -1
  3. package/dist/cjs/index.js +16 -5
  4. package/dist/cjs/instructions.js +1 -1
  5. package/dist/cjs/tools/analyze-accessibility/index.js +483 -0
  6. package/dist/cjs/tools/get-accessibility-guidelines/index.js +204 -0
  7. package/dist/cjs/tools/{get-icons → get-all-icons}/index.js +6 -6
  8. package/dist/cjs/tools/{get-tokens → get-all-tokens}/index.js +7 -8
  9. package/dist/cjs/tools/search-icons/index.js +138 -0
  10. package/dist/cjs/tools/search-tokens/index.js +106 -0
  11. package/dist/cjs/tools/suggest-accessibility-fixes/fixes.js +387 -0
  12. package/dist/cjs/tools/suggest-accessibility-fixes/index.js +185 -0
  13. package/dist/cjs/tools/suggest-accessibility-fixes/keywords.js +34 -0
  14. package/dist/es2019/index.js +16 -5
  15. package/dist/es2019/instructions.js +12 -1
  16. package/dist/es2019/tools/analyze-accessibility/index.js +457 -0
  17. package/dist/es2019/tools/get-accessibility-guidelines/index.js +312 -0
  18. package/dist/es2019/tools/{get-icons → get-all-icons}/index.js +4 -4
  19. package/dist/es2019/tools/get-all-tokens/index.js +34 -0
  20. package/dist/es2019/tools/search-icons/index.js +126 -0
  21. package/dist/es2019/tools/search-tokens/index.js +96 -0
  22. package/dist/es2019/tools/suggest-accessibility-fixes/fixes.js +705 -0
  23. package/dist/es2019/tools/suggest-accessibility-fixes/index.js +143 -0
  24. package/dist/es2019/tools/suggest-accessibility-fixes/keywords.js +28 -0
  25. package/dist/esm/index.js +16 -5
  26. package/dist/esm/instructions.js +1 -1
  27. package/dist/esm/tools/analyze-accessibility/index.js +476 -0
  28. package/dist/esm/tools/get-accessibility-guidelines/index.js +197 -0
  29. package/dist/esm/tools/{get-icons → get-all-icons}/index.js +5 -5
  30. package/dist/esm/tools/{get-tokens → get-all-tokens}/index.js +6 -7
  31. package/dist/esm/tools/search-icons/index.js +131 -0
  32. package/dist/esm/tools/search-tokens/index.js +99 -0
  33. package/dist/esm/tools/suggest-accessibility-fixes/fixes.js +381 -0
  34. package/dist/esm/tools/suggest-accessibility-fixes/index.js +178 -0
  35. package/dist/esm/tools/suggest-accessibility-fixes/keywords.js +28 -0
  36. package/dist/types/instructions.d.ts +1 -1
  37. package/dist/types/tools/analyze-accessibility/index.d.ts +56 -0
  38. package/dist/types/tools/get-accessibility-guidelines/index.d.ts +26 -0
  39. package/dist/{types-ts4.5/tools/get-tokens → types/tools/get-all-icons}/index.d.ts +2 -2
  40. package/dist/types/tools/{get-tokens → get-all-tokens}/index.d.ts +2 -2
  41. package/dist/types/tools/search-icons/index.d.ts +38 -0
  42. package/dist/types/tools/search-tokens/index.d.ts +38 -0
  43. package/dist/types/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
  44. package/dist/types/tools/suggest-accessibility-fixes/index.d.ts +28 -0
  45. package/dist/types/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
  46. package/dist/types-ts4.5/instructions.d.ts +1 -1
  47. package/dist/types-ts4.5/tools/analyze-accessibility/index.d.ts +56 -0
  48. package/dist/types-ts4.5/tools/get-accessibility-guidelines/index.d.ts +26 -0
  49. package/dist/types-ts4.5/tools/{get-icons → get-all-icons}/index.d.ts +2 -2
  50. package/dist/{types/tools/get-icons → types-ts4.5/tools/get-all-tokens}/index.d.ts +2 -2
  51. package/dist/types-ts4.5/tools/search-icons/index.d.ts +38 -0
  52. package/dist/types-ts4.5/tools/search-tokens/index.d.ts +38 -0
  53. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/fixes.d.ts +17 -0
  54. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/index.d.ts +28 -0
  55. package/dist/types-ts4.5/tools/suggest-accessibility-fixes/keywords.d.ts +12 -0
  56. package/package.json +10 -3
  57. package/dist/es2019/tools/get-tokens/index.js +0 -35
@@ -0,0 +1,705 @@
1
+ // Comprehensive fix suggestions for common accessibility violations
2
+ export const accessibilityFixes = {
3
+ 'button missing label': {
4
+ title: 'Button Missing Accessible Label',
5
+ description: 'Buttons need accessible labels for screen readers',
6
+ fixes: [{
7
+ title: 'Use aria-label prop',
8
+ description: 'Add aria-label for icon-only buttons',
9
+ before: `<button onClick={handleClose}>
10
+ <CloseIcon />
11
+ </button>`,
12
+ after: `import { Button } from '@atlaskit/button';
13
+
14
+ <Button aria-label="Close dialog" onClick={handleClose}>
15
+ <CloseIcon />
16
+ </Button>`,
17
+ explanation: 'The aria-label provides a text description for screen readers while keeping the visual design clean.'
18
+ }, {
19
+ title: 'Use VisuallyHidden component',
20
+ description: 'Add screen reader text while keeping visual design',
21
+ before: `<button onClick={handleSave}>
22
+ <SaveIcon />
23
+ </button>`,
24
+ after: `import { Button } from '@atlaskit/button';
25
+ import { VisuallyHidden } from '@atlaskit/visually-hidden';
26
+
27
+ <Button onClick={handleSave}>
28
+ <SaveIcon />
29
+ <VisuallyHidden>Save changes</VisuallyHidden>
30
+ </Button>`,
31
+ explanation: 'VisuallyHidden makes text available to screen readers but hides it visually.'
32
+ }],
33
+ bestPractices: ['Always provide descriptive labels', 'Use aria-label for icon-only buttons', 'Use VisuallyHidden for additional context', 'Test with screen readers']
34
+ },
35
+ 'image missing alt': {
36
+ title: 'Image Missing Alt Text',
37
+ description: 'Images need alt text for screen readers',
38
+ fixes: [{
39
+ title: 'Add descriptive alt text',
40
+ description: 'Provide meaningful alt text for informative images',
41
+ before: `<img src="chart.png" />`,
42
+ after: `import { Image } from '@atlaskit/image';
43
+
44
+ <Image
45
+ src="chart.png"
46
+ alt="Bar chart showing Q4 sales increased 25% over Q3"
47
+ />`,
48
+ explanation: 'Alt text should describe the purpose and content of the image.'
49
+ }, {
50
+ title: 'Empty alt for decorative images',
51
+ description: 'Use empty alt for purely decorative images',
52
+ before: `<img src="decorative.jpg" />`,
53
+ after: `import { Image } from '@atlaskit/image';
54
+
55
+ <Image src="decorative.jpg" alt="" />`,
56
+ explanation: 'Empty alt tells screen readers to skip decorative images.'
57
+ }],
58
+ bestPractices: ['Keep alt text under 125 characters', 'Describe purpose, not just content', 'Use empty alt for decorative images', 'Don\'t start with "Image of..."']
59
+ },
60
+ 'clickable div': {
61
+ title: 'Clickable Div Without Accessibility',
62
+ description: 'Div elements with click handlers need proper accessibility',
63
+ fixes: [{
64
+ title: 'Use Focusable component',
65
+ description: 'Convert to accessible interactive element',
66
+ before: `<div onClick={handleClick}>
67
+ Interactive content
68
+ </div>`,
69
+ after: `import { Focusable } from '@atlaskit/primitives/compiled';
70
+
71
+ <Focusable
72
+ as="div"
73
+ onClick={handleClick}
74
+ onKeyDown={(e) => {
75
+ if (e.key === 'Enter' || e.key === ' ') {
76
+ handleClick();
77
+ }
78
+ }}
79
+ >
80
+ Interactive content
81
+ </Focusable>`,
82
+ explanation: 'Focusable provides keyboard navigation and focus management.'
83
+ }, {
84
+ title: 'Use Button component',
85
+ description: 'Convert to semantic button element',
86
+ before: `<div onClick={handleClick}>
87
+ Click me
88
+ </div>`,
89
+ after: `import { Button } from '@atlaskit/button';
90
+
91
+ <Button onClick={handleClick}>
92
+ Click me
93
+ </Button>`,
94
+ explanation: 'Button provides full accessibility out of the box.'
95
+ }],
96
+ bestPractices: ['Use semantic HTML elements when possible', 'Add keyboard support for custom elements', 'Ensure focus indicators are visible', 'Test with keyboard navigation']
97
+ },
98
+ 'input missing label': {
99
+ title: 'Input Missing Associated Label',
100
+ description: 'Input elements need associated labels',
101
+ fixes: [{
102
+ title: 'Use TextField component',
103
+ description: 'Use ADS TextField for automatic labeling',
104
+ before: `<input type="email" />`,
105
+ after: `import { TextField } from '@atlaskit/textfield';
106
+
107
+ <TextField
108
+ label="Email address"
109
+ type="email"
110
+ id="email-input"
111
+ />`,
112
+ explanation: 'TextField handles label association automatically.'
113
+ }, {
114
+ title: 'Manual label association',
115
+ description: 'Associate label with input using id and htmlFor',
116
+ before: `<input type="email" />
117
+ <label>Email address</label>`,
118
+ after: `<label htmlFor="email-input">Email address</label>
119
+ <input
120
+ type="email"
121
+ id="email-input"
122
+ aria-describedby="email-help"
123
+ />
124
+ <div id="email-help">Enter your work email address</div>`,
125
+ explanation: 'Use id and htmlFor to associate labels with inputs.'
126
+ }],
127
+ bestPractices: ['Always associate labels with inputs', 'Use descriptive label text', 'Provide helpful descriptions', 'Test with screen readers']
128
+ },
129
+ 'hardcoded colors': {
130
+ title: 'Hardcoded Color Values',
131
+ description: 'Hardcoded colors may not meet contrast requirements',
132
+ fixes: [{
133
+ title: 'Use design tokens',
134
+ description: 'Replace hardcoded colors with design tokens',
135
+ before: `color: '#ff0000'`,
136
+ after: `import { token } from '@atlaskit/tokens';
137
+
138
+ color: token('color.text.danger')`,
139
+ explanation: 'Design tokens ensure consistent contrast ratios.'
140
+ }, {
141
+ title: 'Use Text component',
142
+ description: 'Use Text component with color prop',
143
+ before: `<span style={{ color: '#ff0000' }}>Error message</span>`,
144
+ after: `import { Text } from '@atlaskit/primitives/compiled';
145
+
146
+ <Text color="color.text.danger">Error message</Text>`,
147
+ explanation: 'Text component handles color and contrast automatically.'
148
+ }],
149
+ bestPractices: ['Use design tokens for all colors', 'Test contrast ratios', "Don't rely on color alone", 'Test with high contrast mode']
150
+ },
151
+ 'missing focus indicator': {
152
+ title: 'Missing Focus Indicator',
153
+ description: 'Interactive elements need visible focus indicators',
154
+ fixes: [{
155
+ title: 'Use Focusable component',
156
+ description: 'Focusable provides built-in focus indicators',
157
+ before: `<div onClick={handleClick}>
158
+ Interactive content
159
+ </div>`,
160
+ after: `import { Focusable } from '@atlaskit/primitives/compiled';
161
+
162
+ <Focusable as="div" onClick={handleClick}>
163
+ Interactive content
164
+ </Focusable>`,
165
+ explanation: 'Focusable includes visible focus indicators.'
166
+ }, {
167
+ title: 'Custom focus styles',
168
+ description: 'Add custom focus styles with xcss',
169
+ before: `<button onClick={handleClick}>
170
+ Click me
171
+ </button>`,
172
+ after: `import { Focusable } from '@atlaskit/primitives/compiled';
173
+
174
+ <Focusable
175
+ as="button"
176
+ onClick={handleClick}
177
+ xcss={{
178
+ ':focus-visible': {
179
+ outline: '2px solid token(color.border.focus)',
180
+ outlineOffset: '2px',
181
+ },
182
+ }}
183
+ >
184
+ Click me
185
+ </Focusable>`,
186
+ explanation: 'Custom focus styles ensure visibility in all themes.'
187
+ }],
188
+ bestPractices: ['Always provide visible focus indicators', 'Test focus indicators in all themes', 'Ensure sufficient contrast for focus indicators', 'Test with keyboard navigation']
189
+ },
190
+ 'form validation': {
191
+ title: 'Form Validation Accessibility',
192
+ description: 'Form validation needs proper accessibility support',
193
+ fixes: [{
194
+ title: 'Use TextField with validation',
195
+ description: 'TextField provides built-in validation support',
196
+ before: `<input type="password" />
197
+ <div>Password too short</div>`,
198
+ after: `import { TextField } from '@atlaskit/textfield';
199
+
200
+ <TextField
201
+ type="password"
202
+ label="Password"
203
+ isInvalid
204
+ aria-invalid="true"
205
+ aria-describedby="password-error"
206
+ />
207
+ <div id="password-error" role="alert">
208
+ Password must be at least 8 characters long
209
+ </div>`,
210
+ explanation: 'TextField with aria-invalid and aria-describedby provides proper validation feedback.'
211
+ }, {
212
+ title: 'Use MessageWrapper',
213
+ description: 'MessageWrapper for form validation announcements',
214
+ before: `<input type="email" />
215
+ <div>Invalid email format</div>`,
216
+ after: `import { TextField } from '@atlaskit/textfield';
217
+ import { MessageWrapper } from '@atlaskit/form';
218
+
219
+ <MessageWrapper>
220
+ <TextField
221
+ type="email"
222
+ label="Email"
223
+ isInvalid
224
+ aria-describedby="email-error"
225
+ />
226
+ <div id="email-error" role="alert">
227
+ Please enter a valid email address
228
+ </div>
229
+ </MessageWrapper>`,
230
+ explanation: 'MessageWrapper provides proper announcement of validation messages.'
231
+ }],
232
+ bestPractices: ['Use aria-invalid for validation state', 'Provide clear error messages', 'Use role="alert" for important messages', 'Test validation with screen readers']
233
+ },
234
+ 'keyboard navigation': {
235
+ title: 'Missing Keyboard Navigation',
236
+ description: 'Interactive elements need keyboard support',
237
+ fixes: [{
238
+ title: 'Add keyboard event handlers',
239
+ description: 'Support Enter and Space for activation',
240
+ before: `<div onClick={handleClick}>
241
+ Click me
242
+ </div>`,
243
+ after: `import { Focusable } from '@atlaskit/primitives/compiled';
244
+
245
+ <Focusable
246
+ as="div"
247
+ onClick={handleClick}
248
+ onKeyDown={(e) => {
249
+ if (e.key === 'Enter' || e.key === ' ') {
250
+ e.preventDefault();
251
+ handleClick();
252
+ }
253
+ }}
254
+ >
255
+ Click me
256
+ </Focusable>`,
257
+ explanation: 'Keyboard handlers make elements accessible to keyboard users.'
258
+ }, {
259
+ title: 'Use Button component',
260
+ description: 'Button provides full keyboard support',
261
+ before: `<div onClick={handleClick}>
262
+ Submit
263
+ </div>`,
264
+ after: `import { Button } from '@atlaskit/button';
265
+
266
+ <Button onClick={handleClick}>
267
+ Submit
268
+ </Button>`,
269
+ explanation: 'Button supports Enter, Space, and other keyboard interactions.'
270
+ }],
271
+ bestPractices: ['Support Enter and Space for activation', 'Support Escape for closing/canceling', 'Ensure logical tab order', 'Test with keyboard navigation only']
272
+ },
273
+ 'form missing label': {
274
+ title: 'Form Input Missing Label',
275
+ description: 'Form inputs must have accessible labels (WCAG 3.3.2)',
276
+ fixes: [{
277
+ title: 'Use Label component',
278
+ description: 'Add proper form label using ADS Label component',
279
+ before: `<Textfield placeholder="Enter your email" />`,
280
+ after: `import { Label } from '@atlaskit/form';
281
+ import { Textfield } from '@atlaskit/textfield';
282
+
283
+ <Label htmlFor="email">Email address</Label>
284
+ <Textfield id="email" placeholder="Enter your email" />`,
285
+ explanation: 'Labels create a programmatic association between text and form controls.'
286
+ }, {
287
+ title: 'Use aria-label for compact layouts',
288
+ description: 'When visual labels cannot be used, add aria-label',
289
+ before: `<Textfield placeholder="Search..." />`,
290
+ after: `<Textfield
291
+ placeholder="Search..."
292
+ aria-label="Search products"
293
+ />`,
294
+ explanation: 'aria-label provides an accessible name when visual labels are not feasible.'
295
+ }],
296
+ bestPractices: ['Always associate labels with form controls', 'Use descriptive label text', 'Prefer visible labels over aria-label', 'Group related fields with fieldset/legend']
297
+ },
298
+ 'heading structure': {
299
+ title: 'Improper Heading Structure',
300
+ description: 'Headings must follow logical hierarchy (WCAG 1.3.1, 2.4.6)',
301
+ fixes: [{
302
+ title: 'Use proper heading hierarchy',
303
+ description: 'Structure headings in logical order without skipping levels',
304
+ before: `<h1>Page Title</h1>
305
+ <h3>Section Title</h3>
306
+ <h2>Another Section</h2>`,
307
+ after: `import { Heading } from '@atlaskit/heading';
308
+
309
+ <Heading level="h1">Page Title</Heading>
310
+ <Heading level="h2">Section Title</Heading>
311
+ <Heading level="h3">Subsection Title</Heading>`,
312
+ explanation: 'Logical heading structure helps screen readers understand content hierarchy.'
313
+ }, {
314
+ title: 'Add section landmarks',
315
+ description: 'Use semantic HTML5 elements for page structure',
316
+ before: `<div>
317
+ <h2>Navigation</h2>
318
+ <div>Main content here</div>
319
+ </div>`,
320
+ after: `<main>
321
+ <nav aria-label="Main navigation">
322
+ <Heading level="h2">Navigation</Heading>
323
+ </nav>
324
+ <section>
325
+ <Heading level="h2">Main Content</Heading>
326
+ <div>Main content here</div>
327
+ </section>
328
+ </main>`,
329
+ explanation: 'Landmarks provide navigation structure for assistive technologies.'
330
+ }],
331
+ bestPractices: ['Start with h1 and increment sequentially', 'Use only one h1 per page', 'Make headings descriptive', 'Use landmarks (main, nav, section, aside)']
332
+ },
333
+ 'color contrast': {
334
+ title: 'Insufficient Color Contrast',
335
+ description: 'Text must meet minimum contrast ratios (WCAG 1.4.3, 1.4.11)',
336
+ fixes: [{
337
+ title: 'Use ADS design tokens',
338
+ description: 'Use design system tokens that meet contrast requirements',
339
+ before: `const styles = css({
340
+ color: '#999999',
341
+ backgroundColor: '#ffffff',
342
+ });`,
343
+ after: `import { token } from '@atlaskit/tokens';
344
+
345
+ const styles = css({
346
+ color: token('color.text'),
347
+ backgroundColor: token('color.background.neutral'),
348
+ });`,
349
+ explanation: 'ADS tokens ensure WCAG compliant contrast ratios across all themes.'
350
+ }, {
351
+ title: 'Use high contrast tokens for better accessibility',
352
+ description: 'Choose high contrast variants when available',
353
+ before: `color: token('color.text.subtle')`,
354
+ after: `color: token('color.text')`,
355
+ explanation: 'Standard text tokens provide better contrast than subtle variants.'
356
+ }],
357
+ bestPractices: ['Use ADS design tokens', 'Test with contrast checkers', 'Minimum 4.5:1 for normal text', 'Minimum 3:1 for large text and UI components']
358
+ },
359
+ 'focus management': {
360
+ title: 'Missing Focus Management',
361
+ description: 'Focus must be visible and properly managed (WCAG 2.4.3, 2.4.7)',
362
+ fixes: [{
363
+ title: 'Add focus management to modals',
364
+ description: 'Trap focus within modal dialogs',
365
+ before: `<Modal>
366
+ <div>Modal content</div>
367
+ </Modal>`,
368
+ after: `import { Modal, ModalDialog, ModalHeader, ModalTitle } from '@atlaskit/modal-dialog';
369
+
370
+ <Modal onClose={handleClose}>
371
+ <ModalDialog>
372
+ <ModalHeader>
373
+ <ModalTitle>Modal Title</ModalTitle>
374
+ </ModalHeader>
375
+ <div>Modal content</div>
376
+ </ModalDialog>
377
+ </Modal>`,
378
+ explanation: 'ADS Modal components automatically manage focus trapping and restoration.'
379
+ }, {
380
+ title: 'Restore focus after actions',
381
+ description: 'Return focus to logical location after destructive actions',
382
+ before: `const handleDelete = () => {
383
+ deleteItem();
384
+ // No focus management
385
+ };`,
386
+ after: `const handleDelete = () => {
387
+ deleteItem();
388
+ // Focus previous item or parent container
389
+ const nextFocusTarget = previousElement || parentContainer;
390
+ nextFocusTarget?.focus();
391
+ };`,
392
+ explanation: 'Restoring focus helps users maintain their place in the interface.'
393
+ }],
394
+ bestPractices: ['Ensure focus is always visible', 'Trap focus in modals and dialogs', 'Restore focus after modal closes', 'Provide skip links for keyboard users']
395
+ },
396
+ 'link accessibility': {
397
+ title: 'Link Accessibility Issues',
398
+ description: 'Links must have clear purpose and accessible names (WCAG 2.4.4, 2.5.3)',
399
+ fixes: [{
400
+ title: 'Make link text descriptive',
401
+ description: 'Avoid generic link text like "click here" or "read more"',
402
+ before: `<Link href="/docs">Click here</Link>`,
403
+ after: `import { Link } from '@atlaskit/link';
404
+
405
+ <Link href="/docs">View documentation</Link>`,
406
+ explanation: 'Descriptive link text helps users understand where the link leads.'
407
+ }, {
408
+ title: 'Add context for ambiguous links',
409
+ description: 'Provide additional context using aria-label or surrounding text',
410
+ before: `<Link href="/edit">Edit</Link>`,
411
+ after: `<Link href="/edit" aria-label="Edit user profile">Edit</Link>`,
412
+ explanation: 'Additional context clarifies the action when link text alone is insufficient.'
413
+ }],
414
+ bestPractices: ['Use descriptive link text', 'Avoid "click here" or "read more"', 'Ensure link purpose is clear from context', 'Use aria-label for additional context when needed']
415
+ },
416
+ 'table accessibility': {
417
+ title: 'Table Accessibility Issues',
418
+ description: 'Tables need proper headers and structure (WCAG 1.3.1)',
419
+ fixes: [{
420
+ title: 'Add table headers',
421
+ description: 'Use th elements and scope attributes for table headers',
422
+ before: `<table>
423
+ <tr>
424
+ <td>Name</td>
425
+ <td>Email</td>
426
+ </tr>
427
+ </table>`,
428
+ after: `<table>
429
+ <thead>
430
+ <tr>
431
+ <th scope="col">Name</th>
432
+ <th scope="col">Email</th>
433
+ </tr>
434
+ </thead>
435
+ <tbody>
436
+ <tr>
437
+ <td>John Doe</td>
438
+ <td>john@example.com</td>
439
+ </tr>
440
+ </tbody>
441
+ </table>`,
442
+ explanation: 'Table headers with scope attributes help screen readers navigate table data.'
443
+ }, {
444
+ title: 'Add table caption',
445
+ description: 'Provide table caption for complex tables',
446
+ before: `<table>
447
+ <thead>...</thead>
448
+ </table>`,
449
+ after: `<table>
450
+ <caption>User account information by department</caption>
451
+ <thead>...</thead>
452
+ </table>`,
453
+ explanation: "Captions provide context about the table's purpose and structure."
454
+ }],
455
+ bestPractices: ['Use th elements for headers', 'Add scope attributes (col, row)', 'Provide table captions when helpful', 'Use thead, tbody, tfoot for structure']
456
+ },
457
+ 'error handling': {
458
+ title: 'Inaccessible Error Handling',
459
+ description: 'Errors must be clearly identified and suggested (WCAG 3.3.1, 3.3.3)',
460
+ fixes: [{
461
+ title: 'Use ADS form validation',
462
+ description: 'Implement accessible error messages with proper associations',
463
+ before: `<Textfield placeholder="Email" />
464
+ <div>Invalid email format</div>`,
465
+ after: `import { ErrorMessage, Field } from '@atlaskit/form';
466
+
467
+ <Field name="email" label="Email">
468
+ {({ fieldProps, error }) => (
469
+ <>
470
+ <Textfield
471
+ {...fieldProps}
472
+ placeholder="Enter your email"
473
+ aria-invalid={error ? 'true' : 'false'}
474
+ />
475
+ {error && (
476
+ <ErrorMessage>{error}</ErrorMessage>
477
+ )}
478
+ </>
479
+ )}
480
+ </Field>`,
481
+ explanation: 'ADS Form components properly associate errors with form controls.'
482
+ }, {
483
+ title: 'Announce errors to screen readers',
484
+ description: 'Use live regions to announce dynamic errors',
485
+ before: `const [error, setError] = useState('');
486
+ return <div>{error}</div>;`,
487
+ after: `const [error, setError] = useState('');
488
+ return (
489
+ <div
490
+ role="alert"
491
+ aria-live="polite"
492
+ aria-atomic="true"
493
+ >
494
+ {error}
495
+ </div>
496
+ );`,
497
+ explanation: 'Live regions announce error changes to screen readers immediately.'
498
+ }],
499
+ bestPractices: ['Associate errors with form controls', 'Use role="alert" for critical errors', 'Provide helpful error suggestions', 'Show errors inline with fields']
500
+ },
501
+ 'language identification': {
502
+ title: 'Missing Language Identification',
503
+ description: 'Page and content language must be identified (WCAG 3.1.1, 3.1.2)',
504
+ fixes: [{
505
+ title: 'Set page language',
506
+ description: 'Add lang attribute to html element',
507
+ before: `<html>
508
+ <head>...</head>
509
+ </html>`,
510
+ after: `<html lang="en">
511
+ <head>...</head>
512
+ </html>`,
513
+ explanation: 'The lang attribute helps screen readers pronounce content correctly.'
514
+ }, {
515
+ title: 'Mark language changes',
516
+ description: 'Identify when content changes language',
517
+ before: `<p>Welcome to our site. Bienvenidos a nuestro sitio.</p>`,
518
+ after: `<p>Welcome to our site. <span lang="es">Bienvenidos a nuestro sitio.</span></p>`,
519
+ explanation: 'Language changes help screen readers switch pronunciation rules.'
520
+ }],
521
+ bestPractices: ['Set lang attribute on html element', 'Mark language changes in content', 'Use valid language codes (en, es, fr, etc.)', 'Consider regional variants (en-US, en-GB)']
522
+ },
523
+ 'touch target size': {
524
+ title: 'Touch Targets Too Small',
525
+ description: 'Touch targets must be at least 24x24 CSS pixels (WCAG 2.5.8)',
526
+ fixes: [{
527
+ title: 'Increase button size',
528
+ description: 'Use ADS button variants that meet size requirements',
529
+ before: `<button style={{ padding: '2px 4px' }}>X</button>`,
530
+ after: `import { Button } from '@atlaskit/button';
531
+
532
+ <Button
533
+ appearance="subtle"
534
+ spacing="compact"
535
+ aria-label="Close"
536
+ >
537
+ X
538
+ </Button>`,
539
+ explanation: 'ADS buttons automatically meet minimum touch target size requirements.'
540
+ }, {
541
+ title: 'Add adequate spacing',
542
+ description: 'Ensure sufficient space between interactive elements',
543
+ before: `<div>
544
+ <Button>Save</Button><Button>Cancel</Button>
545
+ </div>`,
546
+ after: `import { Stack } from '@atlaskit/stack';
547
+
548
+ <Stack direction="horizontal" space="space.100">
549
+ <Button>Save</Button>
550
+ <Button>Cancel</Button>
551
+ </Stack>`,
552
+ explanation: 'Adequate spacing prevents accidental activation of adjacent controls.'
553
+ }],
554
+ bestPractices: ['Minimum 24x24 CSS pixels for touch targets', 'Provide adequate spacing between targets', 'Use ADS components that meet size requirements', 'Test on actual devices']
555
+ },
556
+ 'motion and animation': {
557
+ title: 'Motion and Animation Issues',
558
+ description: 'Respect user motion preferences (WCAG 2.3.1, 2.2.2)',
559
+ fixes: [{
560
+ title: 'Respect reduced motion preference',
561
+ description: 'Disable animations when user prefers reduced motion',
562
+ before: `const styles = css({
563
+ transition: 'transform 0.3s ease',
564
+ '&:hover': {
565
+ transform: 'scale(1.1)',
566
+ },
567
+ });`,
568
+ after: `const styles = css({
569
+ transition: 'transform 0.3s ease',
570
+ '&:hover': {
571
+ transform: 'scale(1.1)',
572
+ },
573
+ '@media (prefers-reduced-motion: reduce)': {
574
+ transition: 'none',
575
+ '&:hover': {
576
+ transform: 'none',
577
+ },
578
+ },
579
+ });`,
580
+ explanation: 'Respecting motion preferences prevents vestibular disorders and distractions.'
581
+ }, {
582
+ title: 'Provide controls for auto-playing content',
583
+ description: 'Allow users to pause auto-playing animations',
584
+ before: `<div className="auto-rotating-carousel">
585
+ {/* Auto-rotating content */}
586
+ </div>`,
587
+ after: `import { Button } from '@atlaskit/button';
588
+
589
+ <div>
590
+ <Button onClick={toggleAutoplay}>
591
+ {isPlaying ? 'Pause' : 'Play'} carousel
592
+ </Button>
593
+ <div className={isPlaying ? 'auto-rotating-carousel' : 'static-carousel'}>
594
+ {/* Controllable content */}
595
+ </div>
596
+ </div>`,
597
+ explanation: 'User controls prevent motion from interfering with reading or concentration.'
598
+ }],
599
+ bestPractices: ['Respect prefers-reduced-motion setting', 'Provide pause controls for auto-playing content', 'Avoid flashing more than 3 times per second', 'Make motion optional when possible']
600
+ },
601
+ 'live regions': {
602
+ title: 'Missing Live Region Announcements',
603
+ description: 'Dynamic content changes need announcements (WCAG 4.1.3)',
604
+ fixes: [{
605
+ title: 'Add status announcements',
606
+ description: 'Announce non-critical status updates',
607
+ before: `const [saved, setSaved] = useState(false);
608
+ return saved ? <div>Saved!</div> : null;`,
609
+ after: `const [saved, setSaved] = useState(false);
610
+ return saved ? (
611
+ <div
612
+ role="status"
613
+ aria-live="polite"
614
+ aria-atomic="true"
615
+ >
616
+ Document saved successfully!
617
+ </div>
618
+ ) : null;`,
619
+ explanation: 'Status updates are announced to screen readers without interrupting.'
620
+ }, {
621
+ title: 'Use alert for critical messages',
622
+ description: 'Immediately announce critical information',
623
+ before: `const [error, setError] = useState('');
624
+ return error ? <div>{error}</div> : null;`,
625
+ after: `const [error, setError] = useState('');
626
+ return error ? (
627
+ <div
628
+ role="alert"
629
+ aria-live="assertive"
630
+ >
631
+ {error}
632
+ </div>
633
+ ) : null;`,
634
+ explanation: 'Alerts immediately interrupt screen readers for critical information.'
635
+ }],
636
+ bestPractices: ['Use role="status" for non-critical updates', 'Use role="alert" for critical messages', 'Keep announcements concise and clear', 'Test with screen readers']
637
+ },
638
+ 'skip navigation': {
639
+ title: 'Missing Skip Navigation',
640
+ description: 'Provide bypass mechanisms for repetitive content (WCAG 2.4.1)',
641
+ fixes: [{
642
+ title: 'Add skip to main content link',
643
+ description: 'Provide skip link to main content area',
644
+ before: `<nav>
645
+ <ul><!-- navigation items --></ul>
646
+ </nav>
647
+ <main><!-- main content --></main>`,
648
+ after: `import { SkipLinks, SkipLinksItem } from '@atlaskit/skip-links';
649
+
650
+ <SkipLinks>
651
+ <SkipLinksItem href="#main-content">
652
+ Skip to main content
653
+ </SkipLinksItem>
654
+ </SkipLinks>
655
+ <nav>
656
+ <ul><!-- navigation items --></ul>
657
+ </nav>
658
+ <main id="main-content"><!-- main content --></main>`,
659
+ explanation: 'Skip links allow keyboard users to bypass repetitive navigation.'
660
+ }, {
661
+ title: 'Add multiple skip options',
662
+ description: 'Provide skip links for different page sections',
663
+ before: `<header><!-- header content --></header>
664
+ <nav><!-- navigation --></nav>
665
+ <main><!-- main content --></main>`,
666
+ after: `<SkipLinks>
667
+ <SkipLinksItem href="#main-content">
668
+ Skip to main content
669
+ </SkipLinksItem>
670
+ <SkipLinksItem href="#navigation">
671
+ Skip to navigation
672
+ </SkipLinksItem>
673
+ </SkipLinks>
674
+ <header><!-- header content --></header>
675
+ <nav id="navigation"><!-- navigation --></nav>
676
+ <main id="main-content"><!-- main content --></main>`,
677
+ explanation: 'Multiple skip options provide flexibility for different user needs.'
678
+ }],
679
+ bestPractices: ['Provide skip to main content link', 'Make skip links visible when focused', 'Use descriptive skip link text', 'Test skip links with keyboard navigation']
680
+ },
681
+ 'page titles': {
682
+ title: 'Missing or Poor Page Titles',
683
+ description: 'Pages must have descriptive titles (WCAG 2.4.2)',
684
+ fixes: [{
685
+ title: 'Add descriptive page titles',
686
+ description: 'Use clear, unique titles that describe page content',
687
+ before: `<title>Page</title>`,
688
+ after: `<title>User Profile Settings - MyApp</title>`,
689
+ explanation: 'Descriptive titles help users understand their current location.'
690
+ }, {
691
+ title: 'Update titles dynamically',
692
+ description: 'Change titles based on current page state',
693
+ before: `// Static title only
694
+ <title>Dashboard</title>`,
695
+ after: `// Dynamic title updates
696
+ useEffect(() => {
697
+ document.title = error
698
+ ? \`Error - Dashboard - MyApp\`
699
+ : \`Dashboard - MyApp\`;
700
+ }, [error]);`,
701
+ explanation: 'Dynamic titles reflect current page state and context.'
702
+ }],
703
+ bestPractices: ['Use unique titles for each page', 'Put most specific information first', 'Include site name at the end', 'Update titles for single-page apps']
704
+ }
705
+ };