-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathgroups.ts
More file actions
75 lines (63 loc) · 1.88 KB
/
groups.ts
File metadata and controls
75 lines (63 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { z } from 'zod';
import { axePresetSchema } from './config.js';
/* WCAG presets for rule loading */
const axeWcagTags = [
'wcag2a',
'wcag21a',
'wcag2aa',
'wcag21aa',
'wcag22aa',
] as const;
export const axeWcagTagSchema = z
.enum(axeWcagTags)
.meta({ title: 'AxeWcagTag' });
export type AxeWcagTag = z.infer<typeof axeWcagTagSchema>;
export const axeWcagPresetSchema = axePresetSchema
.extract(['wcag21aa', 'wcag22aa'])
.meta({ title: 'AxeWcagPreset' });
export type AxeWcagPreset = z.infer<typeof axeWcagPresetSchema>;
const WCAG_PRESET_TAGS: Record<AxeWcagPreset, AxeWcagTag[]> = {
wcag21aa: ['wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa'],
wcag22aa: ['wcag2a', 'wcag21a', 'wcag2aa', 'wcag21aa', 'wcag22aa'],
};
export function getWcagPresetTags(preset: AxeWcagPreset): AxeWcagTag[] {
return WCAG_PRESET_TAGS[preset];
}
/* Category groups for all presets */
const axeCategoryGroupSlugs = [
'aria',
'color',
'forms',
'keyboard',
'language',
'name-role-value',
'parsing',
'semantics',
'sensory-and-visual-cues',
'structure',
'tables',
'text-alternatives',
'time-and-media',
] as const;
export const axeCategoryGroupSlugSchema = z
.enum(axeCategoryGroupSlugs)
.meta({ title: 'AxeCategoryGroupSlug' });
export type AxeCategoryGroupSlug = z.infer<typeof axeCategoryGroupSlugSchema>;
export const CATEGORY_GROUPS: Record<AxeCategoryGroupSlug, string> = {
aria: 'ARIA',
color: 'Color & Contrast',
forms: 'Forms',
keyboard: 'Keyboard',
language: 'Language',
'name-role-value': 'Names & Labels',
parsing: 'Parsing',
semantics: 'Semantics',
'sensory-and-visual-cues': 'Visual Cues',
structure: 'Structure',
tables: 'Tables',
'text-alternatives': 'Text Alternatives',
'time-and-media': 'Media',
};
/* Combined exports */
export const axeGroupSlugSchema = axeCategoryGroupSlugSchema;
export type AxeGroupSlug = AxeCategoryGroupSlug;