Skip to content

Commit

Permalink
Merge be9ab06 into 5490ba1
Browse files Browse the repository at this point in the history
  • Loading branch information
eszthoff committed Apr 19, 2019
2 parents 5490ba1 + be9ab06 commit 7fbe987
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/List/ListItem/ListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import styles from './ListItem.scss';
const { block, elem } = bem({
name: 'ListItem',
classnames: styles,
propsToMods: ['isSelected', 'onClick']
propsToMods: ['isSelected', 'onClick', 'disabled']
});

const ListItem = props => {
const { children, isSelected, onClick, ...rest } = props;
const { children, isSelected, onClick, disabled, ...rest } = props;
const customBlockMod = { clickable: typeof onClick === 'function' };

return (
Expand All @@ -31,16 +31,19 @@ ListItem.displayName = 'ListItem';
ListItem.propTypes = {
/** List Items */
children: PropTypes.node,
/** A function to be called if the item is clicked */
onClick: PropTypes.func,
/** Formats this item as selected */
isSelected: PropTypes.bool,
/** A function to be called if the item is clicked */
onClick: PropTypes.func
/** Format this item as disabled */
disabled: PropTypes.bool
};

ListItem.defaultProps = {
children: null,
isSelected: false,
onClick: null
onClick: null,
disabled: false
};

export default ListItem;
4 changes: 4 additions & 0 deletions src/components/List/ListItem/ListItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,8 @@
&--clickable {
cursor: pointer;
}

&--disabled:hover {
background-color: var(--color-background);
}
}
2 changes: 2 additions & 0 deletions src/components/List/__tests__/__snapshots__/List.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`List component should render List correctly 1`] = `
>
<ListItem
className="List__item"
disabled={false}
isSelected={false}
key=".0"
onClick={null}
Expand Down Expand Up @@ -38,6 +39,7 @@ exports[`List component should render List correctly 1`] = `
</ListItem>
<ListItem
className="List__item"
disabled={false}
isSelected={false}
key=".1"
onClick={null}
Expand Down
3 changes: 3 additions & 0 deletions stories/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ storiesOf('List', module)
<ListItem isSelected={boolean('Select item', true)}>
<Text inline>Item selectable via props</Text>
</ListItem>
<ListItem disabled={boolean('Disable item', true)}>
<Text inline>Disabled item</Text>
</ListItem>
<ListItem
onClick={e => {
e.preventDefault();
Expand Down

0 comments on commit 7fbe987

Please sign in to comment.