Skip to content

Commit 3344cbf

Browse files
committed
refactored out the basic drawer and added a new DrawerItemsList componen
1 parent d4f9e35 commit 3344cbf

File tree

5 files changed

+44
-16
lines changed

5 files changed

+44
-16
lines changed

src/templates/Drawer/BasicDrawer/BasicDrawer.jsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import _ from 'lodash';
21
import React from 'react';
32
import PropTypes from 'prop-types';
43
import { withStyles } from 'material-ui/styles';
5-
import List, { ListItem, ListItemIcon, ListItemText } from 'material-ui/List';
6-
import Icon from 'material-ui/Icon';
4+
5+
import DrawerItemsList from '../DrawerItemsList';
76

87
import styles from './styles';
98

@@ -16,16 +15,8 @@ class BasicDrawer extends React.PureComponent {
1615
const { links, classes } = this.props;
1716
return (
1817
<div className={classes.wrapper}>
19-
<List className={classes.list}>
20-
{_.map(links, link => (
21-
<ListItem button onClick={link.onClick} key={`link-${link.label}`}>
22-
<ListItemIcon>
23-
{link.icon ? <Icon>{link.icon}</Icon> : <Icon>arrow_right</Icon>}
24-
</ListItemIcon>
25-
<ListItemText primary={link.label} />
26-
</ListItem>
27-
))}
28-
</List>
18+
hello
19+
<DrawerItemsList items={links} />
2920
</div>
3021
);
3122
}

src/templates/Drawer/BasicDrawer/styles.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@ export default {
22
wrapper: {
33
width: '100%',
44
},
5-
list: {
6-
flex: 'initial',
7-
},
85
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import map from 'lodash/map';
2+
import React from 'react';
3+
import PropTypes from 'prop-types';
4+
import { withStyles } from 'material-ui/styles';
5+
import List, { ListItem, ListItemIcon, ListItemText } from 'material-ui/List';
6+
import Icon from 'material-ui/Icon';
7+
8+
import styles from './styles';
9+
10+
class DrawerItemsList extends React.PureComponent {
11+
static propTypes = {
12+
items: PropTypes.arrayOf(PropTypes.shape({})),
13+
classes: PropTypes.shape({}),
14+
};
15+
render() {
16+
const { items, classes } = this.props;
17+
return (
18+
<List className={classes.list}>
19+
{map(items, item => (
20+
<ListItem button onClick={item.onClick} key={`item-${item.label}`}>
21+
<ListItemIcon>
22+
{item.icon ? <Icon>{item.icon}</Icon> : <Icon>arrow_right</Icon>}
23+
</ListItemIcon>
24+
<ListItemText primary={item.label} />
25+
</ListItem>
26+
))}
27+
</List>
28+
);
29+
}
30+
}
31+
32+
export default withStyles(styles)(DrawerItemsList);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import DrawerItemsList from './DrawerItemsList';
2+
3+
export default DrawerItemsList;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export default {
2+
list: {
3+
flex: 'initial',
4+
},
5+
};

0 commit comments

Comments
 (0)