Skip to content

Commit

Permalink
fix(ListItem,ListDivider): Remove unused imports, add ListItem propty…
Browse files Browse the repository at this point in the history
…pes and fix rest operator
  • Loading branch information
allyssonsantos committed Mar 13, 2019
1 parent 72e4478 commit 0da8a7b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 0 additions & 3 deletions components/List/ListDivider.jsx
@@ -1,7 +1,4 @@
import React from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
import Icon from '../Icon';

const Divider = styled.li`
background-color: #a2a5a8;
Expand Down
16 changes: 14 additions & 2 deletions components/List/ListItem.jsx
Expand Up @@ -71,18 +71,30 @@ const Item = styled.li`
`};
`;

const ListItem = ({ icon, children, onClick, rest }) => (
const ListItem = ({ icon, children, onClick, ...rest }) => (
<Item
{...rest}
onClick={onClick}
icon={icon}
hasList={React.Children.map(
children,
children => children.type === List,
children => children.type === List
).some(child => child)}
>
{icon && <Icon name={icon} />}
{children}
</Item>
);

ListItem.PropTypes = {
icon: PropTypes.string,
children: PropTypes.node.isRequired,
onClick: PropTypes.func,
};

ListItem.defaultProps = {
icon: '',
onClick: () => {},
};

export default ListItem;

0 comments on commit 0da8a7b

Please sign in to comment.