Skip to content

Commit 404e2e4

Browse files
committed
Use IconButton in card examples
1 parent 69521f8 commit 404e2e4

File tree

1 file changed

+39
-100
lines changed

1 file changed

+39
-100
lines changed

spec/components/card.jsx

Lines changed: 39 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,21 @@
11
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';
94
import style from '../style';
105

116
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.';
127

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}) => (
2511
<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>
3214
</li>
3315
);
3416

35-
const basic = [
36-
{
17+
const cards = {
18+
basic: [{
3719
name: 'Basic Card',
3820
component: (
3921
<Card className={style.card}>
@@ -63,11 +45,8 @@ const basic = [
6345
</CardActions>
6446
</Card>
6547
)
66-
}
67-
];
68-
69-
const media = [
70-
{
48+
}],
49+
media: [{
7150
name: '16:9 Card Media Area',
7251
component: (
7352
<Card className={style.card}>
@@ -116,11 +95,8 @@ const media = [
11695
</CardMedia>
11796
</Card>
11897
)
119-
}
120-
];
121-
122-
const avatar = [
123-
{
98+
}],
99+
avatar: [{
124100
name: 'Avatar Card Title',
125101
component: (
126102
<Card className={style.card}>
@@ -134,8 +110,8 @@ const avatar = [
134110
image="https://placeimg.com/800/450/nature"
135111
/>
136112
<CardActions style={{ justifyContent: 'flex-end' }}>
137-
<Button toggle icon="share" />
138-
<Button toggle icon="favorite" />
113+
<IconButton icon="share" />
114+
<IconButton icon="favorite" />
139115
</CardActions>
140116
</Card>
141117
)
@@ -154,18 +130,15 @@ const avatar = [
154130
<iframe width="1280" height="720" src="https://www.youtube.com/embed/sGbxmsDFVnE?rel=0&amp;showinfo=0" frameBorder="0" allowFullScreen></iframe>
155131
</CardMedia>
156132
<CardActions style={{ justifyContent: 'flex-end' }}>
157-
<Button toggle icon="report_problem" />
133+
<IconButton icon="report_problem" />
158134
<Spacer/>
159-
<Button toggle icon="share" />
160-
<Button toggle icon="favorite" />
135+
<IconButton icon="share" />
136+
<IconButton icon="favorite" />
161137
</CardActions>
162138
</Card>
163139
)
164-
}
165-
];
166-
167-
const horizontal = [
168-
{
140+
}],
141+
horizontal: [{
169142
name: 'Alternative Layout Example',
170143
component: (
171144
<Card className={style.card}>
@@ -201,11 +174,8 @@ const horizontal = [
201174
</div>
202175
</Card>
203176
)
204-
}
205-
];
206-
207-
const small = [
208-
{
177+
}],
178+
small: [{
209179
name: 'Small Media Card',
210180
component: (
211181
<Card>
@@ -216,9 +186,9 @@ const small = [
216186
<CardTitle>Test</CardTitle>
217187
</CardMedia>
218188
<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" />
222192
</CardActions>
223193
</Card>
224194
)
@@ -232,55 +202,24 @@ const small = [
232202
image="https://placeimg.com/280/280/people"
233203
>
234204
<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" />
238208
</CardActions>
239209
</CardMedia>
240210
</Card>
241211
)
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+
};
275214

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+
);
285224

286225
export default CardTest;

0 commit comments

Comments
 (0)