@@ -18,9 +18,8 @@ import Code from './components/Code';
18
18
// tslint:disable-next-line no-import-side-effect ordered-imports
19
19
import {
20
20
ExampleDefault ,
21
- ExampleAllowMultipleExpanded ,
22
21
ExampleAllowMultipleExpandedFalse ,
23
- ExampleAllowZeroExpanded ,
22
+ ExampleAllowZeroExpandedFalse ,
24
23
ExamplePreExpanded ,
25
24
ExampleOnChange ,
26
25
ExampleAccordionItemState ,
@@ -54,8 +53,7 @@ const App = (): JSX.Element => (
54
53
< h2 className = "u-margin-top" > Default behaviour</ h2 >
55
54
56
55
< p >
57
- By default, only one item may be expanded and it can only be
58
- collapsed again by expanding another.
56
+ By default, any number of items may be expanded at any given time.
59
57
</ p >
60
58
61
59
< Accordion >
@@ -73,32 +71,15 @@ const App = (): JSX.Element => (
73
71
74
72
< Code code = { ExampleDefault } />
75
73
76
- < h2 className = "u-margin-top" > Expanding multiple items at once</ h2 >
77
-
78
- < p >
79
- If you set < strong > allowMultipleExpanded</ strong > to{ ' ' }
80
- < strong > true</ strong > then the accordion will permit multiple items
81
- to be expanded at once.
82
- </ p >
83
-
84
- < Accordion allowMultipleExpanded = { true } >
85
- { placeholders . map ( ( placeholder : Placeholder ) => (
86
- < AccordionItem key = { placeholder . heading } >
87
- < AccordionItemHeading >
88
- < AccordionItemButton >
89
- { placeholder . heading }
90
- </ AccordionItemButton >
91
- </ AccordionItemHeading >
92
- < AccordionItemPanel > { placeholder . panel } </ AccordionItemPanel >
93
- </ AccordionItem >
94
- ) ) }
95
- </ Accordion >
96
-
97
- < Code code = { ExampleAllowMultipleExpanded } />
98
-
99
74
< h2 className = "u-margin-top" >
100
- Same as above except with allowMultipleExpanded=false
75
+ Prevent multiple items being expanded at a time
101
76
</ h2 >
77
+ < p >
78
+ < strong > Note:</ strong > we do not recommend this behavior. Users may
79
+ wish to view the content of more than one panel at once. Also,
80
+ collapsing a panel when opening another can cause unexpected scroll
81
+ position changes.
82
+ </ p >
102
83
103
84
< Accordion allowMultipleExpanded = { false } >
104
85
{ placeholders . map ( ( placeholder : Placeholder ) => (
@@ -115,17 +96,25 @@ const App = (): JSX.Element => (
115
96
116
97
< Code code = { ExampleAllowMultipleExpandedFalse } />
117
98
118
- < h2 className = "u-margin-top" > Collapsing the last expanded item </ h2 >
99
+ < h2 className = "u-margin-top" > Pre- expanded items </ h2 >
119
100
120
101
< p >
121
- If you set < strong > allowZeroExpanded</ strong > to{ ' ' }
122
- < strong > true</ strong > then a solitary expanded item may be collapsed
123
- again.
102
+ If you set < strong > preExpanded</ strong > , then you can choose which
103
+ items are expanded on mount.
104
+ </ p >
105
+
106
+ < p >
107
+ The strings passed to < strong > preExpanded</ strong > are directly
108
+ related to the < strong > uuid</ strong > props of{ ' ' }
109
+ < strong > AccordionItem</ strong > .
124
110
</ p >
125
111
126
- < Accordion allowZeroExpanded = { true } >
112
+ < Accordion preExpanded = { [ placeholders [ 0 ] . uuid ] } >
127
113
{ placeholders . map ( ( placeholder : Placeholder ) => (
128
- < AccordionItem key = { placeholder . heading } >
114
+ < AccordionItem
115
+ key = { placeholder . heading }
116
+ uuid = { placeholder . uuid }
117
+ >
129
118
< AccordionItemHeading >
130
119
< AccordionItemButton >
131
120
{ placeholder . heading }
@@ -136,22 +125,27 @@ const App = (): JSX.Element => (
136
125
) ) }
137
126
</ Accordion >
138
127
139
- < Code code = { ExampleAllowZeroExpanded } />
128
+ < Code code = { ExamplePreExpanded } />
140
129
141
- < h2 className = "u-margin-top" > Pre-expanded items</ h2 >
130
+ < h2 className = "u-margin-top" > Preventing the collapsing of all items</ h2 >
142
131
143
132
< p >
144
- If you set < strong > preExpanded</ strong > , then you can choose which
145
- items are expanded on mount.
133
+ If you set < strong > allowZeroExpanded</ strong > to{ ' ' }
134
+ < strong > false</ strong > then the user must have at least one panel
135
+ open at a time.
146
136
</ p >
147
-
148
137
< p >
149
- The strings passed to < strong > preExpanded</ strong > are directly
150
- related to the < strong > uuid</ strong > props of{ ' ' }
151
- < strong > AccordionItem</ strong > .
138
+ < strong > Note:</ strong > we do not recommend this behavior. Users
139
+ would be able to expand items but not necessarily collapse them,
140
+ which might not match their expectations. If you do choose to use
141
+ this setting, we recommend you pair it with having{ ' ' }
142
+ < strong > preExpanded</ strong > item(s).
152
143
</ p >
153
144
154
- < Accordion preExpanded = { [ placeholders [ 0 ] . uuid ] } >
145
+ < Accordion
146
+ allowZeroExpanded = { false }
147
+ preExpanded = { [ placeholders [ 0 ] . uuid ] }
148
+ >
155
149
{ placeholders . map ( ( placeholder : Placeholder ) => (
156
150
< AccordionItem
157
151
key = { placeholder . heading }
@@ -167,7 +161,7 @@ const App = (): JSX.Element => (
167
161
) ) }
168
162
</ Accordion >
169
163
170
- < Code code = { ExamplePreExpanded } />
164
+ < Code code = { ExampleAllowZeroExpandedFalse } />
171
165
172
166
< h2 className = "u-margin-top" > Informative onChange</ h2 >
173
167
0 commit comments