1
1
import React , { Component } from 'react' ;
2
- import { Button , Card , CardBody , CardFooter , CardHeader , Collapse , Fade } from 'reactstrap' ;
2
+ import { Button , Card , CardBody , CardFooter , CardHeader , Col , Collapse , Fade , Row } from 'reactstrap' ;
3
3
4
4
class Collapses extends Component {
5
5
@@ -10,9 +10,13 @@ class Collapses extends Component {
10
10
this . onExiting = this . onExiting . bind ( this ) ;
11
11
this . onExited = this . onExited . bind ( this ) ;
12
12
this . toggle = this . toggle . bind ( this ) ;
13
+ this . toggleAccordion = this . toggleAccordion . bind ( this ) ;
14
+ this . toggleCustom = this . toggleCustom . bind ( this ) ;
13
15
this . toggleFade = this . toggleFade . bind ( this ) ;
14
16
this . state = {
15
17
collapse : false ,
18
+ accordion : [ true , false , false ] ,
19
+ custom : [ true , false ] ,
16
20
status : 'Closed' ,
17
21
fadeIn : true ,
18
22
timeout : 300 ,
@@ -39,75 +43,184 @@ class Collapses extends Component {
39
43
this . setState ( { collapse : ! this . state . collapse } ) ;
40
44
}
41
45
46
+ toggleAccordion ( tab ) {
47
+
48
+ const prevState = this . state . accordion ;
49
+ const state = prevState . map ( ( x , index ) => tab === index ? ! x : false ) ;
50
+
51
+ this . setState ( {
52
+ accordion : state ,
53
+ } ) ;
54
+ }
55
+
56
+ toggleCustom ( tab ) {
57
+
58
+ const prevState = this . state . custom ;
59
+ const state = prevState . map ( ( x , index ) => tab === index ? ! x : false ) ;
60
+
61
+ this . setState ( {
62
+ custom : state ,
63
+ } ) ;
64
+ }
65
+
42
66
toggleFade ( ) {
43
67
this . setState ( { fadeIn : ! this . state . fadeIn } ) ;
44
68
}
45
69
46
70
render ( ) {
47
71
return (
48
72
< div className = "animated fadeIn" >
49
- < Card >
50
- < CardHeader >
51
- < i className = "fa fa-align-justify" > </ i > < strong > Collapse</ strong >
52
- < div className = "card-header-actions" >
53
- < a href = "https://reactstrap.github.io/components/collapse/" rel = "noreferrer noopener" target = "_blank" className = "card-header-action" >
54
- < small className = "text-muted" > docs</ small >
55
- </ a >
56
- </ div >
57
- </ CardHeader >
58
- < Collapse
59
- isOpen = { this . state . collapse }
60
- onEntering = { this . onEntering }
61
- onEntered = { this . onEntered }
62
- onExiting = { this . onExiting }
63
- onExited = { this . onExited }
64
- >
65
- < CardBody >
66
- < p >
67
- Anim pariatur cliche reprehenderit,
68
- enim eiusmod high life accusamus terry richardson ad squid. Nihil
69
- anim keffiyeh helvetica, craft beer labore wes anderson cred
70
- nesciunt sapiente ea proident.
71
- </ p >
72
- < p >
73
- Donec molestie odio id nisi malesuada, mattis tincidunt velit egestas. Sed non pulvinar risus. Aenean
74
- elementum eleifend nunc, pellentesque dapibus arcu hendrerit fringilla. Aliquam in nibh massa. Cras
75
- ultricies lorem non enim volutpat, a eleifend urna placerat. Fusce id luctus urna. In sed leo tellus.
76
- Mauris tristique leo a nisl feugiat, eget vehicula leo venenatis. Quisque magna metus, luctus quis
77
- sollicitudin vel, vehicula nec ipsum. Donec rutrum commodo lacus ut condimentum. Integer vel turpis
78
- purus. Etiam vehicula, nulla non fringilla blandit, massa purus faucibus tellus, a luctus enim orci non
79
- augue. Aenean ullamcorper nisl urna, non feugiat tortor volutpat in. Vivamus lobortis massa dolor, eget
80
- faucibus ipsum varius eget. Pellentesque imperdiet, turpis sed sagittis lobortis, leo elit laoreet arcu,
81
- vehicula sagittis elit leo id nisi.
82
- </ p >
83
- </ CardBody >
84
- </ Collapse >
85
- < CardFooter >
86
- < Button color = "primary" onClick = { this . toggle } style = { { marginBottom : '1rem' } } > Toggle</ Button >
87
- < h5 > Current state: { this . state . status } </ h5 >
88
- </ CardFooter >
89
- </ Card >
90
- < Card >
91
- < CardHeader >
92
- < i className = "fa fa-align-justify" > </ i > < strong > Fade</ strong >
93
- < div className = "card-header-actions" >
94
- < a href = "https://reactstrap.github.io/components/fade/" rel = "noreferrer noopener" target = "_blank" className = "card-header-action" >
95
- < small className = "text-muted" > docs</ small >
96
- </ a >
97
- </ div >
98
- </ CardHeader >
99
- < CardBody >
100
- < Fade timeout = { this . state . timeout } in = { this . state . fadeIn } tag = "h5" className = "mt-3" >
101
- This content will fade in and out as the button is pressed...
102
- </ Fade >
103
- </ CardBody >
104
- < CardFooter >
105
- < Button color = "primary" onClick = { this . toggleFade } > Toggle Fade</ Button >
106
- </ CardFooter >
107
- </ Card >
73
+ < Row >
74
+ < Col xl = "6" >
75
+ < Card >
76
+ < CardHeader >
77
+ < i className = "fa fa-align-justify" > </ i > < strong > Collapse</ strong >
78
+ < div className = "card-header-actions" >
79
+ < a href = "https://reactstrap.github.io/components/collapse/" rel = "noreferrer noopener" target = "_blank" className = "card-header-action" >
80
+ < small className = "text-muted" > docs</ small >
81
+ </ a >
82
+ </ div >
83
+ </ CardHeader >
84
+ < Collapse isOpen = { this . state . collapse } onEntering = { this . onEntering } onEntered = { this . onEntered } onExiting = { this . onExiting } onExited = { this . onExited } >
85
+ < CardBody >
86
+ < p >
87
+ Anim pariatur cliche reprehenderit,
88
+ enim eiusmod high life accusamus terry richardson ad squid. Nihil
89
+ anim keffiyeh helvetica, craft beer labore wes anderson cred
90
+ nesciunt sapiente ea proident.
91
+ </ p >
92
+ < p >
93
+ Donec molestie odio id nisi malesuada, mattis tincidunt velit egestas. Sed non pulvinar risus. Aenean
94
+ elementum eleifend nunc, pellentesque dapibus arcu hendrerit fringilla. Aliquam in nibh massa. Cras
95
+ ultricies lorem non enim volutpat, a eleifend urna placerat. Fusce id luctus urna. In sed leo tellus.
96
+ Mauris tristique leo a nisl feugiat, eget vehicula leo venenatis. Quisque magna metus, luctus quis
97
+ sollicitudin vel, vehicula nec ipsum. Donec rutrum commodo lacus ut condimentum. Integer vel turpis
98
+ purus. Etiam vehicula, nulla non fringilla blandit, massa purus faucibus tellus, a luctus enim orci non
99
+ augue. Aenean ullamcorper nisl urna, non feugiat tortor volutpat in. Vivamus lobortis massa dolor, eget
100
+ faucibus ipsum varius eget. Pellentesque imperdiet, turpis sed sagittis lobortis, leo elit laoreet arcu,
101
+ vehicula sagittis elit leo id nisi.
102
+ </ p >
103
+ </ CardBody >
104
+ </ Collapse >
105
+ < CardFooter >
106
+ < Button color = "primary" onClick = { this . toggle } style = { { marginBottom : '1rem' } } > Toggle</ Button >
107
+ < h5 > Current state: { this . state . status } </ h5 >
108
+ </ CardFooter >
109
+ </ Card >
110
+ < Card >
111
+ < CardHeader >
112
+ < i className = "fa fa-align-justify" > </ i > < strong > Fade</ strong >
113
+ < div className = "card-header-actions" >
114
+ < a href = "https://reactstrap.github.io/components/fade/" rel = "noreferrer noopener" target = "_blank" className = "card-header-action" >
115
+ < small className = "text-muted" > docs</ small >
116
+ </ a >
117
+ </ div >
118
+ </ CardHeader >
119
+ < CardBody >
120
+ < Fade timeout = { this . state . timeout } in = { this . state . fadeIn } tag = "h5" className = "mt-3" >
121
+ This content will fade in and out as the button is pressed...
122
+ </ Fade >
123
+ </ CardBody >
124
+ < CardFooter >
125
+ < Button color = "primary" onClick = { this . toggleFade } > Toggle Fade</ Button >
126
+ </ CardFooter >
127
+ </ Card >
128
+ </ Col >
129
+ < Col xl = "6" >
130
+ < Card >
131
+ < CardHeader >
132
+ < i className = "fa fa-align-justify" > </ i > Collapse < small > accordion</ small >
133
+ </ CardHeader >
134
+ < CardBody >
135
+ < div id = "accordion" >
136
+ < Card >
137
+ < CardHeader id = "headingOne" >
138
+ < Button block color = "link" className = "text-left m-0 p-0" onClick = { ( ) => this . toggleAccordion ( 0 ) } aria-expanded = { this . state . accordion [ 0 ] } aria-controls = "collapseOne" >
139
+ < h5 className = "m-0 p-0" > Collapsible Group Item #1</ h5 >
140
+ </ Button >
141
+ </ CardHeader >
142
+ < Collapse isOpen = { this . state . accordion [ 0 ] } data-parent = "#accordion" id = "collapseOne" aria-labelledby = "headingOne" >
143
+ < CardBody >
144
+ 1. Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non
145
+ cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
146
+ on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred
147
+ nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft
148
+ beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
149
+ </ CardBody >
150
+ </ Collapse >
151
+ </ Card >
152
+ < Card >
153
+ < CardHeader id = "headingTwo" >
154
+ < Button block color = "link" className = "text-left m-0 p-0" onClick = { ( ) => this . toggleAccordion ( 1 ) } aria-expanded = { this . state . accordion [ 1 ] } aria-controls = "collapseTwo" >
155
+ < h5 className = "m-0 p-0" > Collapsible Group Item #2</ h5 >
156
+ </ Button >
157
+ </ CardHeader >
158
+ < Collapse isOpen = { this . state . accordion [ 1 ] } data-parent = "#accordion" id = "collapseTwo" >
159
+ < CardBody >
160
+ 2. Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non
161
+ cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
162
+ on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred
163
+ nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft
164
+ beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
165
+ </ CardBody >
166
+ </ Collapse >
167
+ </ Card >
168
+ < Card >
169
+ < CardHeader id = "headingThree" >
170
+ < Button block color = "link" className = "text-left m-0 p-0" onClick = { ( ) => this . toggleAccordion ( 2 ) } aria-expanded = { this . state . accordion [ 2 ] } aria-controls = "collapseThree" >
171
+ < h5 className = "m-0 p-0" > Collapsible Group Item #3</ h5 >
172
+ </ Button >
173
+ </ CardHeader >
174
+ < Collapse isOpen = { this . state . accordion [ 2 ] } data-parent = "#accordion" id = "collapseThree" >
175
+ < CardBody >
176
+ 3. Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non
177
+ cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt aliqua put a bird
178
+ on it squid single-origin coffee nulla assumenda shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred
179
+ nesciunt sapiente ea proident. Ad vegan excepteur butcher vice lomo. Leggings occaecat craft
180
+ beer farm-to-table, raw denim aesthetic synth nesciunt you probably haven't heard of them accusamus labore sustainable VHS.
181
+ </ CardBody >
182
+ </ Collapse >
183
+ </ Card >
184
+ </ div >
185
+ </ CardBody >
186
+ </ Card >
187
+ < Card >
188
+ < CardHeader >
189
+ < i className = "fa fa-align-justify" > </ i > Collapse < small > custom accordion</ small >
190
+ </ CardHeader >
191
+ < CardBody >
192
+ < div id = "exampleAccordion" data-children = ".item" >
193
+ < div className = "item" >
194
+ < Button className = "m-0 p-0" color = "link" onClick = { ( ) => this . toggleCustom ( 0 ) } aria-expanded = { this . state . custom [ 0 ] } aria-controls = "exampleAccordion1" >
195
+ Toggle item
196
+ </ Button >
197
+ < Collapse isOpen = { this . state . custom [ 0 ] } data-parent = "#exampleAccordion" id = "exampleAccordion1" >
198
+ < p className = "mb-3" >
199
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed pretium lorem non vestibulum scelerisque. Proin a vestibulum sem, eget
200
+ tristique massa. Aliquam lacinia rhoncus nibh quis ornare.
201
+ </ p >
202
+ </ Collapse >
203
+ </ div >
204
+ < div className = "item" >
205
+ < Button className = "m-0 p-0" color = "link" onClick = { ( ) => this . toggleCustom ( 1 ) } aria-expanded = { this . state . custom [ 1 ] } aria-controls = "exampleAccordion2" >
206
+ Toggle item 2
207
+ </ Button >
208
+ < Collapse isOpen = { this . state . custom [ 1 ] } data-parent = "#exampleAccordion" id = "exampleAccordion2" >
209
+ < p className = "mb-3" >
210
+ Donec at ipsum dignissim, rutrum turpis scelerisque, tristique lectus. Pellentesque habitant morbi tristique senectus et netus et
211
+ malesuada fames ac turpis egestas. Vivamus nec dui turpis. Orci varius natoque penatibus et magnis dis parturient montes,
212
+ nascetur ridiculus mus.
213
+ </ p >
214
+ </ Collapse >
215
+ </ div >
216
+ </ div >
217
+ </ CardBody >
218
+ </ Card >
219
+ </ Col >
220
+ </ Row >
108
221
</ div >
109
222
) ;
110
223
}
111
224
}
112
225
113
- export default Collapses ;
226
+ export default Collapses ;
0 commit comments