-
Notifications
You must be signed in to change notification settings - Fork 841
/
accessibility_example.js
149 lines (140 loc) Β· 4.21 KB
/
accessibility_example.js
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import React from 'react';
import { renderToHtml } from '../../services';
import { GuideSectionTypes } from '../../components';
import {
EuiCallOut,
EuiCode,
EuiLink,
EuiKeyboardAccessible,
EuiSkipLink,
} from '../../../../src/components';
import KeyboardAccessible from './keyboard_accessible';
import ScreenReaderOnly from './screen_reader';
import SkipLink from './skip_link';
const keyboardAccessibleSource = require('!!raw-loader!./keyboard_accessible');
const keyboardAccessibleHtml = renderToHtml(KeyboardAccessible);
const keyboardAccessibleSnippet = `<EuiKeyboardAccessible>
<!-- interactive child element -->
</EuiKeyboardAccessible>`;
const screenReaderOnlyHtml = renderToHtml(ScreenReaderOnly);
const screenReaderOnlySource = require('!!raw-loader!./screen_reader');
const screenReaderOnlySnippet = [
`<EuiScreenReaderOnly>
<!-- visually hidden content -->
</EuiScreenReaderOnly>
`,
`<EuiScreenReaderOnly showOnFocus>
<!-- visually hidden content, displayed on focus -->
</EuiScreenReaderOnly>
`,
];
const skipLinkHtml = renderToHtml(SkipLink);
const skipLinkSource = require('!!raw-loader!./skip_link');
const skipLinkSnippet = [
`<EuiSkipLink destinationId="myAnchorId">
Skip to content
</EuiSkipLink>
`,
`<EuiSkipLink destinationId="myAnchorId" position="fixed">
Skip to main content
</EuiSkipLink>
`,
];
import { ScreenReaderOnlyDocsComponent } from './props';
export const AccessibilityExample = {
title: 'Accessibility',
sections: [
{
title: 'Keyboard accessible',
source: [
{
type: GuideSectionTypes.JS,
code: keyboardAccessibleSource,
},
{
type: GuideSectionTypes.HTML,
code: keyboardAccessibleHtml,
},
],
text: (
<p>
You can make interactive elements keyboard-accessible with the{' '}
<strong>EuiKeyboardAccessible</strong> component. This is necessary
for non-button elements and <EuiCode>a</EuiCode> tags without{' '}
<EuiCode>href</EuiCode> attributes.
</p>
),
props: { EuiKeyboardAccessible },
snippet: keyboardAccessibleSnippet,
demo: <KeyboardAccessible />,
},
{
title: 'Screen reader only',
source: [
{
type: GuideSectionTypes.JS,
code: screenReaderOnlySource,
},
{
type: GuideSectionTypes.HTML,
code: screenReaderOnlyHtml,
},
],
text: (
<div>
<p>
Use the <strong>EuiScreenReaderOnly</strong> component to visually
hide elements while still allowing them to be read by screen
readers. In certain cases, you may want to use the{' '}
<EuiCode>showOnFocus</EuiCode> prop to display screen reader-only
content when in focus.
</p>
<EuiCallOut
color="warning"
iconType="accessibility"
title="WebAIM recommendation for screen reader-only content">
<p>
"In most cases, if content (particularly content that
provides functionality or interactivity) is important enough to
provide to screen reader users, it should probably be made
available to all users."{' '}
<EuiLink
href="http://webaim.org/techniques/css/invisiblecontent/"
external>
Learn more about invisible content
</EuiLink>
</p>
</EuiCallOut>
</div>
),
props: {
EuiScreenReaderOnly: ScreenReaderOnlyDocsComponent,
},
snippet: screenReaderOnlySnippet,
demo: <ScreenReaderOnly />,
},
{
title: 'Skip link',
source: [
{
type: GuideSectionTypes.JS,
code: skipLinkSource,
},
{
type: GuideSectionTypes.HTML,
code: skipLinkHtml,
},
],
text: (
<p>
The <strong>EuiSkipLink</strong> component allows users to bypass
navigation, or ornamental elements, and quickly reach the main content
of the page.
</p>
),
props: { EuiSkipLink },
snippet: skipLinkSnippet,
demo: <SkipLink />,
},
],
};