1
1
import React from 'react' ;
2
- import Button from '../../components/button' ;
3
- import Card , {
4
- CardActions ,
5
- CardMedia ,
6
- CardText ,
7
- CardTitle
8
- } from '../../components/card' ;
2
+ import Button , { IconButton } from '../../components/button' ;
3
+ import Card , { CardActions , CardMedia , CardText , CardTitle } from '../../components/card' ;
9
4
import style from '../style' ;
10
5
11
6
const dummyText = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.' ;
12
7
13
- const Spacer = ( ) => {
14
- return (
15
- < div style = { {
16
- display : 'flex' ,
17
- flex : '1 1 auto'
18
- } } />
19
- ) ;
20
- } ;
21
-
22
- const DemoList = ( props ) => < ul className = { style . demoList } > { props . children } </ ul > ;
23
-
24
- const DemoListItem = ( props ) => (
8
+ const Spacer = ( ) => < div style = { { display : 'flex' , flex : '1 1 auto' } } /> ;
9
+ const DemoList = ( { children} ) => < ul className = { style . demoList } > { children } </ ul > ;
10
+ const DemoListItem = ( { component, name} ) => (
25
11
< li className = { style . demoListItem } >
26
- < div className = { style . demo } >
27
- { props . component }
28
- </ div >
29
- < div className = { style . demoName } >
30
- { props . name }
31
- </ div >
12
+ < div className = { style . demo } > { component } </ div >
13
+ < div className = { style . demoName } > { name } </ div >
32
14
</ li >
33
15
) ;
34
16
35
- const basic = [
36
- {
17
+ const cards = {
18
+ basic : [ {
37
19
name : 'Basic Card' ,
38
20
component : (
39
21
< Card className = { style . card } >
@@ -63,11 +45,8 @@ const basic = [
63
45
</ CardActions >
64
46
</ Card >
65
47
)
66
- }
67
- ] ;
68
-
69
- const media = [
70
- {
48
+ } ] ,
49
+ media : [ {
71
50
name : '16:9 Card Media Area' ,
72
51
component : (
73
52
< Card className = { style . card } >
@@ -116,11 +95,8 @@ const media = [
116
95
</ CardMedia >
117
96
</ Card >
118
97
)
119
- }
120
- ] ;
121
-
122
- const avatar = [
123
- {
98
+ } ] ,
99
+ avatar : [ {
124
100
name : 'Avatar Card Title' ,
125
101
component : (
126
102
< Card className = { style . card } >
@@ -134,8 +110,8 @@ const avatar = [
134
110
image = "https://placeimg.com/800/450/nature"
135
111
/>
136
112
< CardActions style = { { justifyContent : 'flex-end' } } >
137
- < Button toggle icon = "share" />
138
- < Button toggle icon = "favorite" />
113
+ < IconButton icon = "share" />
114
+ < IconButton icon = "favorite" />
139
115
</ CardActions >
140
116
</ Card >
141
117
)
@@ -154,18 +130,15 @@ const avatar = [
154
130
< iframe width = "1280" height = "720" src = "https://www.youtube.com/embed/sGbxmsDFVnE?rel=0&showinfo=0" frameBorder = "0" allowFullScreen > </ iframe >
155
131
</ CardMedia >
156
132
< CardActions style = { { justifyContent : 'flex-end' } } >
157
- < Button toggle icon = "report_problem" />
133
+ < IconButton icon = "report_problem" />
158
134
< Spacer />
159
- < Button toggle icon = "share" />
160
- < Button toggle icon = "favorite" />
135
+ < IconButton icon = "share" />
136
+ < IconButton icon = "favorite" />
161
137
</ CardActions >
162
138
</ Card >
163
139
)
164
- }
165
- ] ;
166
-
167
- const horizontal = [
168
- {
140
+ } ] ,
141
+ horizontal : [ {
169
142
name : 'Alternative Layout Example' ,
170
143
component : (
171
144
< Card className = { style . card } >
@@ -201,11 +174,8 @@ const horizontal = [
201
174
</ div >
202
175
</ Card >
203
176
)
204
- }
205
- ] ;
206
-
207
- const small = [
208
- {
177
+ } ] ,
178
+ small : [ {
209
179
name : 'Small Media Card' ,
210
180
component : (
211
181
< Card >
@@ -216,9 +186,9 @@ const small = [
216
186
< CardTitle > Test</ CardTitle >
217
187
</ CardMedia >
218
188
< CardActions style = { { justifyContent : 'center' } } >
219
- < Button toggle icon = "thumb_down" />
220
- < Button toggle icon = "thumb_up" />
221
- < Button toggle icon = "turned_in_not" />
189
+ < IconButton icon = "thumb_down" />
190
+ < IconButton icon = "thumb_up" />
191
+ < IconButton icon = "turned_in_not" />
222
192
</ CardActions >
223
193
</ Card >
224
194
)
@@ -232,55 +202,24 @@ const small = [
232
202
image = "https://placeimg.com/280/280/people"
233
203
>
234
204
< CardActions style = { { justifyContent : 'center' } } >
235
- < Button inverse toggle icon = "fast_rewind" />
236
- < Button inverse toggle icon = "play_arrow" />
237
- < Button inverse toggle icon = "fast_forward" />
205
+ < IconButton inverse icon = "fast_rewind" />
206
+ < IconButton inverse icon = "play_arrow" />
207
+ < IconButton inverse icon = "fast_forward" />
238
208
</ CardActions >
239
209
</ CardMedia >
240
210
</ Card >
241
211
)
242
- }
243
- ] ;
244
-
245
- class CardTest extends React . Component {
246
-
247
- render ( ) {
248
- return (
249
- < div >
250
- < h2 > Cards</ h2 >
251
-
252
- < DemoList >
253
- { basic . map ( ( demo , i ) => (
254
- < DemoListItem key = { i } { ...demo } />
255
- ) ) }
256
- </ DemoList >
257
-
258
- < DemoList >
259
- { media . map ( ( demo , i ) => (
260
- < DemoListItem key = { i } { ...demo } />
261
- ) ) }
262
- </ DemoList >
263
-
264
- < DemoList >
265
- { avatar . map ( ( demo , i ) => (
266
- < DemoListItem key = { i } { ...demo } />
267
- ) ) }
268
- </ DemoList >
269
-
270
- < DemoList >
271
- { horizontal . map ( ( demo , i ) => (
272
- < DemoListItem key = { i } { ...demo } />
273
- ) ) }
274
- </ DemoList >
212
+ } ]
213
+ } ;
275
214
276
- < DemoList >
277
- { small . map ( ( demo , i ) => (
278
- < DemoListItem key = { i } { ... demo } />
279
- ) ) }
280
- </ DemoList >
281
- </ div >
282
- ) ;
283
- }
284
- }
215
+ const CardTest = ( ) => (
216
+ < div >
217
+ { Object . keys ( cards ) . map ( ( key ) => (
218
+ < DemoList key = { key } >
219
+ { cards [ key ] . map ( ( demo , i ) => < DemoListItem key = { key + i } { ... demo } /> ) }
220
+ </ DemoList >
221
+ ) ) }
222
+ </ div >
223
+ ) ;
285
224
286
225
export default CardTest ;
0 commit comments