-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.html
252 lines (229 loc) · 7.72 KB
/
index.html
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
<!DOCTYPE html>
<html lang="en-us" class="no-js">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta charset="utf-8" />
<title>
Progressively enhanced ARIA accordions
</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<style>
body, html { font-family: arial; font-size: 16px; margin: 0; padding: 0; }
h1, h2, h3, h4 ,h5 ,h6, p { margin-top: 0; } hr { margin: 40px 0; }
p, li { line-height: 1.4; margin: 0 0 16px; } button, html [type="button"], [type="reset"], [type="submit"] { -webkit-appearance: button; cursor: pointer; font-family: inherit; font-style: inherit; } input[type="submit"]::-moz-focus-inner, button[type="submit"]::-moz-focus-inner, button:-moz-focusring, input:-moz-focusring { outline: 0; } button::-moz-focus-inner, input::-moz-focus-inner { border: 0; padding: 0; } code,kbd { background: #efefef; font-size: .825em; padding: 2px 4px; display: inline-block; line-height: 1; }
.content-area { padding: 2em 1.25em }
.content-area + .content-area { padding-top: 0; margin-top: -1.5em; }
.page { max-width: 700px; margin: auto; }
pre { display: block; }
pre code {
background: #fafafa;
border: 1px solid #666;
display: block;
padding: .55em;
}
.demo-heading {
margin-top: 2em;
padding-top: 2em;
border-top: 1px solid;
}
.demo-heading span { display: block; }
</style>
<script>
// remove no-js and add 'js' to the HTML
document.documentElement.className = document.documentElement.className.replace('no-js', 'js');
</script>
<link rel="stylesheet" href="assets/css/aria.accordion.css" />
</head>
<body>
<div class="page">
<header class="content-area">
<h1 class="txt-up-3">
Progressively enhanced ARIA accordions
</h1>
<p>
See the <a href="https://github.com/scottaohara/accessible_accordions">source code for this demo on GitHub</a>.
</p>
</header>
<main class="content-area">
<p>
The following accordion examples are enhanced from a basic HTML pattern of <span style="white-space: nowrap;">container > heading + sub-container</span>.
</p>
<p>For example:</p>
<pre><code><div class="accordion" data-aria-accordion>
<h2 data-aria-accordion-heading>Heading of my panel</h2>
<div data-aria-accordion-panel>
<p>Content goes here</p>
</div>
</div></code></pre>
<p>
So without JavaScript, they will retain an appropriate document structure and the content will be completely accessible.
</p>
<h2 class="demo-heading">
<span>Demo 1:</span>
No default opened panel & ability to open multiple panels at a time.
</h2>
<div data-aria-accordion
data-multi
data-transition
data-default="none"
id="accGen">
<h3 data-aria-accordion-heading>
Chapter 1
</h3>
<div data-aria-accordion-panel>
<p>
Here is the first panel of content.
</p>
<p>
This particular accordion example can have multiple opened panels at a time, or every panel closed.
</p>
</div>
<h3 data-aria-accordion-heading>
Chapter 2
</h3>
<div data-aria-accordion-panel>
<p>
By using the <code>data-multi</code> attribute, multiple
panels can be opened at once.
</p>
</div>
<h3 data-aria-accordion-heading>
Chapter 3
</h3>
<div data-aria-accordion-panel>
<p>
The <code>data-default="none"</code> attribute is used to
indicate that no panel will be open by default, when the
accordion is initially rendered.
</p>
</div>
</div>
<h2 class="demo-heading">
<span>Demo 2:</span>
Constantly opened panel & nested accordion example
</h2>
<div data-aria-accordion data-constant>
<h3 data-aria-accordion-heading>
Chapter 4
</h3>
<div data-aria-accordion-panel>
<p>
Using the <code>data-constant</code> attribute on the parent
accordion wrapper will require that an accordion panel
be perpetually set to open.
</p>
</div>
<h3 data-aria-accordion-heading>
Chapter 5
</h3>
<div data-aria-accordion-panel>
<p>
When panels are open, their corresponding trigger (button) will
be announced as "dimmed" or "unavailable", so it's clear that
while the trigger exists, it can't presently be activated.
</p>
</div>
<h2 data-aria-accordion-heading>
Chapter 6
</h2>
<div data-aria-accordion-panel>
<p>
Sometimes accordions are desired within accordions. Typically
this should be advised against, as it can create a more
complex UX than should really be necessary.
</p>
<div data-aria-accordion data-transition>
<h3 data-aria-accordion-heading>
Chapter 6.1
</h3>
<div data-aria-accordion-panel>
<p>
As an example of how nested accordions need to
be considered their own component, and not related
to the parent accordion panel set, this accordion
functions independently and differently than
the parent accordion.
</p>
</div>
<h3 data-aria-accordion-heading>
Chapter 6.2
</h3>
<div data-aria-accordion-panel>
<p>
Only a single panel of this accordion can be opened at time,
but this accordion also allows for the ability to collapse all panels.
</p>
</div>
</div>
</div>
</div>
<h2 class="demo-heading">
<span>Demo 3:</span>
Accordion with second panel opened by default, only one panel opened at a time, but all may be closed.
</h2>
<div data-default="2" data-aria-accordion data-transition>
<h3 data-aria-accordion-heading>
Chapter 7
</h3>
<div data-aria-accordion-panel>
<p>
Kind of like a choose your own adventure book, this panel was skipped over as Chapter 8 was opened by default.
</p>
</div>
<h3 data-aria-accordion-heading>
Chapter 8
</h3>
<div data-aria-accordion-panel>
<p>
This panel is set to be opened by default, when this particular accordion renders. This is accomplished via the <code>data-default="2"</code>, set on the parent accordion container.
</p>
</div>
</div>
<h2 class="demo-heading">
<span>Demo 4:</span>
Accordion contained within an <code><ol></code>, with no panels open by default.
</h2>
<ol data-aria-accordion data-default="none">
<li>
<h3 data-aria-accordion-heading>
Chapter 9
</h3>
<div data-aria-accordion-panel>
<p>
Using the <code>data-constant</code> attribute on the parent
accordion wrapper will require that an accordion panel
be perpetually set to open.
</p>
</div>
</li>
<li>
<h3 data-aria-accordion-heading>
Chapter 10
</h3>
<div data-aria-accordion-panel>
<p>
When panels are open, their corresponding trigger (button) will
be announced as "dimmed" or "unavailable", so it's clear that
while the trigger exists, it can't presently be activated.
</p>
</div>
</li>
<li>
<h2 data-aria-accordion-heading>
Chapter 11
</h2>
<div data-aria-accordion-panel>
<p>
Sometimes accordions are desired within accordions. Typically
this sort of nesting should be avoided, as it can create a more
complex UX than should really be necessary.
</p>
</div>
</li>
</ol>
</main> <!-- /.content-area -->
</div> <!-- /.page -->
<!-- unminified version: index.js -->
<script src="assets/js/aria.accordion.min.js"></script>
</body>
</html>