@fluentui/react-accordion 9.0.8 → 9.0.9
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.
- package/CHANGELOG.json +70 -1
- package/CHANGELOG.md +20 -2
- package/lib/Accordion.js.map +1 -1
- package/lib/AccordionHeader.js.map +1 -1
- package/lib/AccordionItem.js.map +1 -1
- package/lib/AccordionPanel.js.map +1 -1
- package/lib/components/Accordion/Accordion.js.map +1 -1
- package/lib/components/Accordion/Accordion.types.js.map +1 -1
- package/lib/components/Accordion/AccordionContext.js.map +1 -1
- package/lib/components/Accordion/index.js.map +1 -1
- package/lib/components/Accordion/renderAccordion.js.map +1 -1
- package/lib/components/Accordion/useAccordion.js.map +1 -1
- package/lib/components/Accordion/useAccordionContextValues.js.map +1 -1
- package/lib/components/Accordion/useAccordionStyles.js.map +1 -1
- package/lib/components/AccordionHeader/AccordionHeader.js.map +1 -1
- package/lib/components/AccordionHeader/AccordionHeader.types.js.map +1 -1
- package/lib/components/AccordionHeader/AccordionHeaderContext.js.map +1 -1
- package/lib/components/AccordionHeader/index.js.map +1 -1
- package/lib/components/AccordionHeader/renderAccordionHeader.js.map +1 -1
- package/lib/components/AccordionHeader/useAccordionHeader.js.map +1 -1
- package/lib/components/AccordionHeader/useAccordionHeaderContextValues.js.map +1 -1
- package/lib/components/AccordionHeader/useAccordionHeaderStyles.js.map +1 -1
- package/lib/components/AccordionItem/AccordionItem.js.map +1 -1
- package/lib/components/AccordionItem/AccordionItem.types.js.map +1 -1
- package/lib/components/AccordionItem/AccordionItemContext.js.map +1 -1
- package/lib/components/AccordionItem/index.js.map +1 -1
- package/lib/components/AccordionItem/renderAccordionItem.js.map +1 -1
- package/lib/components/AccordionItem/useAccordionItem.js.map +1 -1
- package/lib/components/AccordionItem/useAccordionItemContextValues.js.map +1 -1
- package/lib/components/AccordionItem/useAccordionItemStyles.js.map +1 -1
- package/lib/components/AccordionPanel/AccordionPanel.js.map +1 -1
- package/lib/components/AccordionPanel/AccordionPanel.types.js.map +1 -1
- package/lib/components/AccordionPanel/index.js.map +1 -1
- package/lib/components/AccordionPanel/renderAccordionPanel.js.map +1 -1
- package/lib/components/AccordionPanel/useAccordionPanel.js.map +1 -1
- package/lib/components/AccordionPanel/useAccordionPanelStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Accordion.js.map +1 -1
- package/lib-commonjs/AccordionHeader.js.map +1 -1
- package/lib-commonjs/AccordionItem.js.map +1 -1
- package/lib-commonjs/AccordionPanel.js.map +1 -1
- package/lib-commonjs/components/Accordion/Accordion.js.map +1 -1
- package/lib-commonjs/components/Accordion/AccordionContext.js.map +1 -1
- package/lib-commonjs/components/Accordion/index.js.map +1 -1
- package/lib-commonjs/components/Accordion/renderAccordion.js.map +1 -1
- package/lib-commonjs/components/Accordion/useAccordion.js.map +1 -1
- package/lib-commonjs/components/Accordion/useAccordionContextValues.js.map +1 -1
- package/lib-commonjs/components/Accordion/useAccordionStyles.js.map +1 -1
- package/lib-commonjs/components/AccordionHeader/AccordionHeader.js.map +1 -1
- package/lib-commonjs/components/AccordionHeader/AccordionHeaderContext.js.map +1 -1
- package/lib-commonjs/components/AccordionHeader/index.js.map +1 -1
- package/lib-commonjs/components/AccordionHeader/renderAccordionHeader.js.map +1 -1
- package/lib-commonjs/components/AccordionHeader/useAccordionHeader.js.map +1 -1
- package/lib-commonjs/components/AccordionHeader/useAccordionHeaderContextValues.js.map +1 -1
- package/lib-commonjs/components/AccordionHeader/useAccordionHeaderStyles.js.map +1 -1
- package/lib-commonjs/components/AccordionItem/AccordionItem.js.map +1 -1
- package/lib-commonjs/components/AccordionItem/AccordionItemContext.js.map +1 -1
- package/lib-commonjs/components/AccordionItem/index.js.map +1 -1
- package/lib-commonjs/components/AccordionItem/renderAccordionItem.js.map +1 -1
- package/lib-commonjs/components/AccordionItem/useAccordionItem.js.map +1 -1
- package/lib-commonjs/components/AccordionItem/useAccordionItemContextValues.js.map +1 -1
- package/lib-commonjs/components/AccordionItem/useAccordionItemStyles.js.map +1 -1
- package/lib-commonjs/components/AccordionPanel/AccordionPanel.js.map +1 -1
- package/lib-commonjs/components/AccordionPanel/index.js.map +1 -1
- package/lib-commonjs/components/AccordionPanel/renderAccordionPanel.js.map +1 -1
- package/lib-commonjs/components/AccordionPanel/useAccordionPanel.js.map +1 -1
- package/lib-commonjs/components/AccordionPanel/useAccordionPanelStyles.js.map +1 -1
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +19 -19
- package/Spec.md +0 -447
package/Spec.md
DELETED
|
@@ -1,447 +0,0 @@
|
|
|
1
|
-
# Accordion
|
|
2
|
-
|
|
3
|
-
## Background
|
|
4
|
-
|
|
5
|
-
### Definition
|
|
6
|
-
|
|
7
|
-
This spec defines the default function of an `Accordion` as a vertically stacked set of interactive panels that each contain a title and content snippet.
|
|
8
|
-
|
|
9
|
-
An accordion is a vertically stacked group of collapsible sections. An accordion is composed of grouped buttons and panels. When a user selects an accordion button, its corresponding panel should switch between 'open' and 'collapsed' states.
|
|
10
|
-
|
|
11
|
-
Accordions follow many consistent patterns but do allow for some variability in behavior. For example, some accordions only allow one panel to be open at a time, where others may allow multiple or all panels to be open simultaneously. Similarly, many accordions will allow all panels to be simultaneously collapsed, while others may require one panel to be open at all times.
|
|
12
|
-
|
|
13
|
-
If you are familiar with the disclosure pattern, an accordion will feel very similar. The key distinction is that a disclosure is a standalone component that consists of a single button-panel-group. Because of this, you cannot navigate between different disclosures with a keyboard the same way you can with an accordion.
|
|
14
|
-
|
|
15
|
-
## Prior art
|
|
16
|
-
|
|
17
|
-
As a part of the spec definitions in Fluent UI, a research effort has been made through [Open UI](https://open-ui.org/). The current research proposal is available as an open source contribution undergoing review ([research proposal](https://github.com/WICG/open-ui/pull/263))
|
|
18
|
-
|
|
19
|
-
## Comparison of `@fluentui/react` and `@fluentui/react-northstar`
|
|
20
|
-
|
|
21
|
-
- All mentions of v7 or v8 == `@fluentui/react` ([docsite](https://developer.microsoft.com/en-us/fluentui#/))
|
|
22
|
-
- All mentions of v0 == `@fluentui/react-northstar` ([docsite](https://fluentsite.z22.web.core.windows.net/))
|
|
23
|
-
|
|
24
|
-
There's no comparison to be done between the two libraries, since v8 hasn't implemented this component.
|
|
25
|
-
|
|
26
|
-
## API
|
|
27
|
-
|
|
28
|
-
The `Accordion` should implement a `children` based API as is the standard across all the surveyed alternatives as a part of Open UI research in [Prior Art](#prior-art). The component will leverage the use of React's Context API in the interaction and data flows of child components.
|
|
29
|
-
|
|
30
|
-
Sample usages will be given in the following section of this document [Sample code](#sample-code)
|
|
31
|
-
|
|
32
|
-
### Accordion
|
|
33
|
-
|
|
34
|
-
The root level component serves context and common API between all children.
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
export type AccordionProps = ComponentProps &
|
|
38
|
-
React.HTMLAttributes<HTMLElement> & {
|
|
39
|
-
/**
|
|
40
|
-
* Indicates if keyboard navigation is available and gives two options,
|
|
41
|
-
* linear or circular navigation
|
|
42
|
-
*/
|
|
43
|
-
navigation?: 'linear' | 'circular';
|
|
44
|
-
/**
|
|
45
|
-
* Indicates if Accordion support multiple Panels opened at the same time
|
|
46
|
-
*/
|
|
47
|
-
multiple?: boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Indicates if Accordion support multiple Panels closed at the same time
|
|
50
|
-
*/
|
|
51
|
-
collapsible?: boolean;
|
|
52
|
-
/**
|
|
53
|
-
* value indicating the items that are opened
|
|
54
|
-
* If used, the component will be in controlled mode
|
|
55
|
-
*/
|
|
56
|
-
openItems?: AccordionItemValue | AccordionItemValue[];
|
|
57
|
-
/**
|
|
58
|
-
* Index indicating the panels that are opened
|
|
59
|
-
*/
|
|
60
|
-
defaultOpenItems?: AccordionItemValue | AccordionItemValue[];
|
|
61
|
-
/**
|
|
62
|
-
* Size of spacing in the heading
|
|
63
|
-
*/
|
|
64
|
-
size?: 'small' | 'medium' | 'large' | 'extra-large';
|
|
65
|
-
/**
|
|
66
|
-
* The component to be used as button in the heading
|
|
67
|
-
*/
|
|
68
|
-
button?: ShorthandProps<React.HTMLAttributes<HTMLElement>>;
|
|
69
|
-
/**
|
|
70
|
-
* Expand icon slot rendered before (or after) children content in heading
|
|
71
|
-
*/
|
|
72
|
-
expandIcon?: ShorthandProps<AccordionHeaderExpandIconProps>;
|
|
73
|
-
/**
|
|
74
|
-
* The position of the expand icon slot in heading
|
|
75
|
-
*/
|
|
76
|
-
expandIconPosition?: 'start' | 'end';
|
|
77
|
-
/**
|
|
78
|
-
* Extra icon slot rendered before children content in heading
|
|
79
|
-
*/
|
|
80
|
-
icon?: ShorthandProps<AccordionHeaderIconProps>;
|
|
81
|
-
/**
|
|
82
|
-
* Indicates if the AccordionHeader should be inline-block
|
|
83
|
-
*/
|
|
84
|
-
inline?: boolean;
|
|
85
|
-
onToggle?(event: AccordionToggleEvent, data: AccordionToggleData): void;
|
|
86
|
-
};
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
### AccordionItem
|
|
90
|
-
|
|
91
|
-
Each Combination of `AccordionHeader` and `AccordionPanel` should be inside an `AccordionItem`, and The `Accordion` component should contain one or more `AccordionItem`.
|
|
92
|
-
|
|
93
|
-
```ts
|
|
94
|
-
export type AccordionItemProps = ComponentProps &
|
|
95
|
-
React.HTMLAttributes<HTMLElement> & {
|
|
96
|
-
/**
|
|
97
|
-
* Disables opening/closing of panel inside the item
|
|
98
|
-
*/
|
|
99
|
-
disabled?: boolean;
|
|
100
|
-
/**
|
|
101
|
-
* required value that identifies this item inside an Accordion component
|
|
102
|
-
*/
|
|
103
|
-
value: AccordionItemValue;
|
|
104
|
-
};
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### AccordionHeader
|
|
108
|
-
|
|
109
|
-
Label for or thumbnail representing a section of content that also serves as a control for showing, and in some implementations, hiding the section of content
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
export type AccordionHeaderProps = ComponentProps &
|
|
113
|
-
React.HTMLAttributes<HTMLElement> & {
|
|
114
|
-
/**
|
|
115
|
-
* Size of spacing in the heading
|
|
116
|
-
*/
|
|
117
|
-
size?: 'small' | 'medium' | 'large' | 'extra-large';
|
|
118
|
-
/**
|
|
119
|
-
* The component to be used as button in heading
|
|
120
|
-
*/
|
|
121
|
-
button?: ShorthandProps<React.HTMLAttributes<HTMLElement>>;
|
|
122
|
-
/**
|
|
123
|
-
* Expand icon slot rendered before (or after) children content in heading
|
|
124
|
-
*/
|
|
125
|
-
expandIcon?: ShorthandProps<AccordionHeaderExpandIconProps>;
|
|
126
|
-
/**
|
|
127
|
-
* The position of the expand icon slot in heading
|
|
128
|
-
*/
|
|
129
|
-
expandIconPosition?: 'start' | 'end';
|
|
130
|
-
/**
|
|
131
|
-
* Extra icon slot rendered before children content in heading
|
|
132
|
-
*/
|
|
133
|
-
icon?: ShorthandProps<AccordionHeaderIconProps>;
|
|
134
|
-
/**
|
|
135
|
-
* Indicates if the AccordionHeader should be inline-block
|
|
136
|
-
*/
|
|
137
|
-
inline?: boolean;
|
|
138
|
-
};
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
### AccordionPanel
|
|
142
|
-
|
|
143
|
-
Section of content associated with an accordion header.
|
|
144
|
-
|
|
145
|
-
## Sample code
|
|
146
|
-
|
|
147
|
-
The below samples do not represent the definitive props of the final implemented component, but represent the ideal final implementations. Can be subject to change during the implementation phase.
|
|
148
|
-
|
|
149
|
-
### Basic Accordion
|
|
150
|
-
|
|
151
|
-
```tsx
|
|
152
|
-
const accordion = (
|
|
153
|
-
<Accordion>
|
|
154
|
-
<AccordionItem>
|
|
155
|
-
<AccordionHeader>
|
|
156
|
-
First Panel
|
|
157
|
-
</AccordionHeader>
|
|
158
|
-
<AccordionPanel>
|
|
159
|
-
This is the content of the first Panel
|
|
160
|
-
</AccordionPanel>
|
|
161
|
-
</AccordionItem>
|
|
162
|
-
<AccordionItem>
|
|
163
|
-
<AccordionHeader>
|
|
164
|
-
Second Panel
|
|
165
|
-
</AccordionHeader>
|
|
166
|
-
<AccordionPanel>
|
|
167
|
-
This is the content of the second Panel
|
|
168
|
-
</AccordionPanel>
|
|
169
|
-
</AccordionItem>
|
|
170
|
-
<Accordion>
|
|
171
|
-
)
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
Expected DOM output
|
|
175
|
-
|
|
176
|
-
```html
|
|
177
|
-
<div>
|
|
178
|
-
<div role="heading">
|
|
179
|
-
<div role="button" aria-expanded="false" aria-controls="sect1" id="accordion1">
|
|
180
|
-
<svg>Chevron Icon</svg>
|
|
181
|
-
First Panel
|
|
182
|
-
</div>
|
|
183
|
-
</div>
|
|
184
|
-
<div id="sect1" role="region" aria-labelledby="accordion1">This is the content of the first Panel</div>
|
|
185
|
-
<div role="heading">
|
|
186
|
-
<div role="button" aria-expanded="false" aria-controls="sect2" id="accordion2">
|
|
187
|
-
<svg>Chevron Icon</svg>
|
|
188
|
-
Second Panel
|
|
189
|
-
</div>
|
|
190
|
-
</div>
|
|
191
|
-
<div id="sect2" role="region" aria-labelledby="accordion2">This is the content of the second Panel</div>
|
|
192
|
-
</div>
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### One panel opened Accordion
|
|
196
|
-
|
|
197
|
-
```tsx
|
|
198
|
-
const accordion = (
|
|
199
|
-
<Accordion open={0}>
|
|
200
|
-
<AccordionItem>
|
|
201
|
-
<AccordionHeader>
|
|
202
|
-
First Panel
|
|
203
|
-
</AccordionHeader>
|
|
204
|
-
<AccordionPanel>
|
|
205
|
-
This is the content of the first Panel
|
|
206
|
-
</AccordionPanel>
|
|
207
|
-
</AccordionItem>
|
|
208
|
-
<AccordionItem>
|
|
209
|
-
<AccordionHeader>
|
|
210
|
-
Second Panel
|
|
211
|
-
</AccordionHeader>
|
|
212
|
-
<AccordionPanel>
|
|
213
|
-
This is the content of the second Panel
|
|
214
|
-
</AccordionPanel>
|
|
215
|
-
</AccordionItem>
|
|
216
|
-
<Accordion>
|
|
217
|
-
)
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
Expected DOM output
|
|
221
|
-
|
|
222
|
-
```html
|
|
223
|
-
<div>
|
|
224
|
-
<div role="heading">
|
|
225
|
-
<div role="button" aria-expanded="true" aria-controls="sect1" id="accordion1">
|
|
226
|
-
<svg>Chevron Icon</svg>
|
|
227
|
-
First Panel
|
|
228
|
-
</div>
|
|
229
|
-
</div>
|
|
230
|
-
<div id="sect1" role="region" aria-labelledby="accordion1">This is the content of the first Panel</div>
|
|
231
|
-
<div role="heading">
|
|
232
|
-
<div role="button" aria-expanded="false" aria-controls="sect2" id="accordion2">
|
|
233
|
-
<svg>Chevron Icon</svg>
|
|
234
|
-
Second Panel
|
|
235
|
-
</div>
|
|
236
|
-
</div>
|
|
237
|
-
<div id="sect2" role="region" aria-labelledby="accordion2">This is the content of the second Panel</div>
|
|
238
|
-
</div>
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Opened Accordion
|
|
242
|
-
|
|
243
|
-
To have multiple panels opened at the same time an Accordion must use the `multiple` property.
|
|
244
|
-
|
|
245
|
-
```tsx
|
|
246
|
-
const accordion = (
|
|
247
|
-
<Accordion open={[0, 1]} multiple>
|
|
248
|
-
<AccordionItem>
|
|
249
|
-
<AccordionHeader>
|
|
250
|
-
First Panel
|
|
251
|
-
</AccordionHeader>
|
|
252
|
-
<AccordionPanel>
|
|
253
|
-
This is the content of the first Panel
|
|
254
|
-
</AccordionPanel>
|
|
255
|
-
</AccordionItem>
|
|
256
|
-
<AccordionItem>
|
|
257
|
-
<AccordionHeader>
|
|
258
|
-
Second Panel
|
|
259
|
-
</AccordionHeader>
|
|
260
|
-
<AccordionPanel>
|
|
261
|
-
This is the content of the second Panel
|
|
262
|
-
</AccordionPanel>
|
|
263
|
-
</AccordionItem>
|
|
264
|
-
<Accordion>
|
|
265
|
-
)
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
Expected DOM output
|
|
269
|
-
|
|
270
|
-
```html
|
|
271
|
-
<div>
|
|
272
|
-
<div role="heading">
|
|
273
|
-
<div role="button" aria-expanded="true" aria-controls="sect1" id="accordion1">
|
|
274
|
-
<svg>Chevron Icon</svg>
|
|
275
|
-
First Panel
|
|
276
|
-
</div>
|
|
277
|
-
</div>
|
|
278
|
-
<div id="sect1" role="region" aria-labelledby="accordion1">This is the content of the first Panel</div>
|
|
279
|
-
<div role="heading">
|
|
280
|
-
<div role="button" aria-expanded="true" aria-controls="sect2" id="accordion2">
|
|
281
|
-
<svg>Chevron Icon</svg>
|
|
282
|
-
Second Panel
|
|
283
|
-
</div>
|
|
284
|
-
</div>
|
|
285
|
-
<div id="sect2" role="region" aria-labelledby="accordion2">This is the content of the second Panel</div>
|
|
286
|
-
</div>
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### Custom icon Accordion panel
|
|
290
|
-
|
|
291
|
-
```tsx
|
|
292
|
-
const accordion = (
|
|
293
|
-
<Accordion expandIconPositon="end">
|
|
294
|
-
<AccordionItem>
|
|
295
|
-
<AccordionHeader expandIcon={<CustomIcon/>}>
|
|
296
|
-
First Panel
|
|
297
|
-
</AccordionHeader>
|
|
298
|
-
<AccordionPanel>
|
|
299
|
-
This is the content of the first Panel
|
|
300
|
-
</AccordionPanel>
|
|
301
|
-
</AccordionItem>
|
|
302
|
-
<AccordionItem>
|
|
303
|
-
<AccordionHeader expandIcon={<AnotherCustomIcon/>}>
|
|
304
|
-
Second Panel
|
|
305
|
-
</AccordionHeader>
|
|
306
|
-
<AccordionPanel>
|
|
307
|
-
This is the content of the second Panel
|
|
308
|
-
</AccordionPanel>
|
|
309
|
-
</AccordionItem>
|
|
310
|
-
<Accordion>
|
|
311
|
-
)
|
|
312
|
-
```
|
|
313
|
-
|
|
314
|
-
Expected DOM output
|
|
315
|
-
|
|
316
|
-
```html
|
|
317
|
-
<div>
|
|
318
|
-
<div role="heading">
|
|
319
|
-
<div role="button" aria-expanded="false" aria-controls="sect1" id="accordion1">
|
|
320
|
-
First Panel
|
|
321
|
-
<svg>CustomIcon</svg>
|
|
322
|
-
</div>
|
|
323
|
-
</div>
|
|
324
|
-
<div id="sect1" role="region" aria-labelledby="accordion1">This is the content of the first Panel</div>
|
|
325
|
-
<div role="heading">
|
|
326
|
-
<div role="button" aria-expanded="false" aria-controls="sect2" id="accordion2">
|
|
327
|
-
Second Panel
|
|
328
|
-
<svg>AnotherCustomIcon</svg>
|
|
329
|
-
</div>
|
|
330
|
-
</div>
|
|
331
|
-
<div id="sect2" role="region" aria-labelledby="accordion2">This is the content of the second Panel</div>
|
|
332
|
-
</div>
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
### Custom heading Accordion panel
|
|
336
|
-
|
|
337
|
-
```tsx
|
|
338
|
-
const accordion = (
|
|
339
|
-
<Accordion>
|
|
340
|
-
<AccordionItem>
|
|
341
|
-
<AccordionHeader as="h1">
|
|
342
|
-
First Panel
|
|
343
|
-
</AccordionHeader>
|
|
344
|
-
<AccordionPanel>
|
|
345
|
-
This is the content of the first Panel
|
|
346
|
-
</AccordionPanel>
|
|
347
|
-
</AccordionItem>
|
|
348
|
-
<AccordionItem>
|
|
349
|
-
<AccordionHeader as="h1">
|
|
350
|
-
Second Panel
|
|
351
|
-
</AccordionHeader>
|
|
352
|
-
<AccordionPanel>
|
|
353
|
-
This is the content of the second Panel
|
|
354
|
-
</AccordionPanel>
|
|
355
|
-
</AccordionItem>
|
|
356
|
-
<Accordion>
|
|
357
|
-
)
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
Expected DOM output
|
|
361
|
-
|
|
362
|
-
```html
|
|
363
|
-
<div>
|
|
364
|
-
<h1>
|
|
365
|
-
<div role="button" aria-expanded="false" aria-controls="sect1" id="accordion1">
|
|
366
|
-
<svg>Chevron Icon</svg>
|
|
367
|
-
First Panel
|
|
368
|
-
</div>
|
|
369
|
-
</h1>
|
|
370
|
-
<div id="sect1" role="region" aria-labelledby="accordion1">This is the content of the first Panel</div>
|
|
371
|
-
<h1>
|
|
372
|
-
<div role="button" aria-expanded="false" aria-controls="sect2" id="accordion2">
|
|
373
|
-
<svg>Chevron Icon</svg>
|
|
374
|
-
Second Panel
|
|
375
|
-
</div>
|
|
376
|
-
</h1>
|
|
377
|
-
<div id="sect2" role="region" aria-labelledby="accordion2">This is the content of the second Panel</div>
|
|
378
|
-
</div>
|
|
379
|
-
```
|
|
380
|
-
|
|
381
|
-
## Behaviors
|
|
382
|
-
|
|
383
|
-
- Keyboard navigation should be optional and native tabbing used by default.
|
|
384
|
-
- Circular Navigation should be optional and disabled by default.
|
|
385
|
-
|
|
386
|
-
### Useful references
|
|
387
|
-
|
|
388
|
-
The below references were used to decide an appropriate keyboard interactions from an a11y perspective.
|
|
389
|
-
|
|
390
|
-
- https://www.w3.org/TR/wai-aria-practices/#accordion
|
|
391
|
-
- https://www.w3.org/TR/wai-aria-practices/#example
|
|
392
|
-
- https://www.w3.org/TR/wai-aria-practices/#keyboard-interaction
|
|
393
|
-
|
|
394
|
-
### Accordion panel open/close
|
|
395
|
-
|
|
396
|
-
An accordion panel can be open/close by the following user interactions on the heading. Not all interactions should be supported at the same time, but the component must be able to support combinations of the below interactions.
|
|
397
|
-
|
|
398
|
-
As a general rule, once the accordion is closed the focus should return to the heading element once the accordion is closed unless the interaction would involve another focusable element.
|
|
399
|
-
|
|
400
|
-
| Type | Action | Result | Details |
|
|
401
|
-
| -------- | ---------- | ----------- | ----------------------------------------------------------- |
|
|
402
|
-
| Mouse | Click | Open | Click on a closed heading |
|
|
403
|
-
| Mouse | Click | Close | Click on an opened heading |
|
|
404
|
-
| Keyboard | Enter | Open | Pressed with focus on a closed heading |
|
|
405
|
-
| Keyboard | Enter | Close | Pressed with focus on an opened heading |
|
|
406
|
-
| Keyboard | Space | Open | Pressed with focus on a closed heading |
|
|
407
|
-
| Keyboard | Space | Close | Pressed with focus on an opened heading |
|
|
408
|
-
| Type | Action | Result | Details |
|
|
409
|
-
| Keyboard | Down Arrow | Moves Focus | Moves focus to the next panel heading (may be circular) |
|
|
410
|
-
| Keyboard | Up Arrow | Moves Focus | Moves focus to the previous panel heading (may be circular) |
|
|
411
|
-
| Keyboard | Home | Moves Focus | Moves focus to the first panel heading |
|
|
412
|
-
| Keyboard | End | Moves Focus | Moves focus to the last panel heading |
|
|
413
|
-
|
|
414
|
-
## Accessibility
|
|
415
|
-
|
|
416
|
-
Accessibility behavior is built into the spec as much as possible. This section addresses specific issues that don't fit well with the standard definition of the component.
|
|
417
|
-
|
|
418
|
-
### No heading level on `AccordionHeader` by default
|
|
419
|
-
|
|
420
|
-
As described on [WAI-ARIA Roles, States, and Properties](https://www.w3.org/TR/wai-aria-practices/#wai-aria-roles-states-and-properties) documentation for accordion:
|
|
421
|
-
|
|
422
|
-
> Each accordion header button is wrapped in an element with role heading that has a value set for aria-level that is appropriate for the information architecture of the page.
|
|
423
|
-
|
|
424
|
-
Every `AccordionHeader` should have as its root a semantic heading element: `h1`, `h2`, `h3`, `h4`, `h5` or `h6`. Alternatively `role="heading"` and a proper `aria-level` attribute. This behavior is not implemented by default on `AccordionHeader` as it's impossible to predict which heading level will be required by the user. Requiring manual addition of such ARIA requirement.
|
|
425
|
-
|
|
426
|
-
```tsx
|
|
427
|
-
{/* No heading level by default */}
|
|
428
|
-
<AccordionHeader>This is a header</AccordionHeader>
|
|
429
|
-
{/* Generated html */}
|
|
430
|
-
<div>
|
|
431
|
-
<button>This is a header</button>
|
|
432
|
-
</div>
|
|
433
|
-
|
|
434
|
-
{/* as semantic heading */}
|
|
435
|
-
<AccordionHeader as="h4">This is a header</AccordionHeader>
|
|
436
|
-
{/* Generated html */}
|
|
437
|
-
<h4>
|
|
438
|
-
<button>This is a header</button>
|
|
439
|
-
</h4>
|
|
440
|
-
|
|
441
|
-
{/* if no semantic heading can be used */}
|
|
442
|
-
<AccordionHeader role="heading" aria-level="4">This is a header</AccordionHeader>
|
|
443
|
-
{/* Generated html */}
|
|
444
|
-
<div role="heading" aria-level="4">
|
|
445
|
-
<button>This is a header</button>
|
|
446
|
-
</h4>
|
|
447
|
-
```
|