forked from yuristrelets/react-toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathList.js
More file actions
43 lines (38 loc) · 991 Bytes
/
List.js
File metadata and controls
43 lines (38 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import React from 'react';
import ListItem from './ListItem';
import style from './style';
class List extends React.Component {
static propTypes = {
children: React.PropTypes.node,
className: React.PropTypes.string,
ripple: React.PropTypes.bool,
selectable: React.PropTypes.bool
};
static defaultProps = {
className: '',
ripple: false,
selectable: false
};
renderItems () {
return React.Children.map(this.props.children, (item) => {
if (item.type === ListItem) {
return React.cloneElement(item, {
ripple: this.props.ripple,
selectable: this.props.selectable
});
} else {
return React.cloneElement(item);
}
});
}
render () {
let className = style.list;
if (this.props.className) className += ` ${this.props.className}`;
return (
<ul data-react-toolbox='list' className={className}>
{this.renderItems()}
</ul>
);
}
}
export default List;