Skip to content

Commit

Permalink
Added tappable version of ListItems
Browse files Browse the repository at this point in the history
Also added a clickHandler example story
  • Loading branch information
devgeeks committed Jul 30, 2016
1 parent 73a3d35 commit 3b9a934
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 19 deletions.
26 changes: 13 additions & 13 deletions gh-pages/static/preview.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gh-pages/static/preview.bundle.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 14 additions & 4 deletions src/components/List/ListItem.js
@@ -1,15 +1,25 @@
import React from 'react';
import classNames from 'classnames';
import Tappable from 'react-tappable';

const ListItem = (props) => {
const { clickHandler = false, ...rest } = props;
const cx = classNames({
'topcoat-list__item': true,
});
return (
<li className={ cx } { ...props }>
const item = clickHandler
? (<Tappable
component="li"
onTap={ clickHandler }
className={ cx }
{ ...rest }
>
{ props.children }
</li>
);
</Tappable>)
: (<li className={ cx } { ...rest }>
{ props.children }
</li>);
return item;
};

ListItem.displayName = 'ListItem';
Expand Down
18 changes: 17 additions & 1 deletion src/components/List/stories/index.js
@@ -1,5 +1,5 @@
import React from 'react';
import { storiesOf } from '@kadira/storybook';
import { action, storiesOf } from '@kadira/storybook';

import { List, ListContainer, ListHeader, ListItem } from '../';

Expand All @@ -14,6 +14,22 @@ storiesOf('List', module)
</ListContainer>
</List>
))
.addWithInfo('clickHandler', () => (
<List>
<ListHeader>Header</ListHeader>
<ListContainer>
<ListItem clickHandler={ action('tapped one') }>
List Item One
</ListItem>
<ListItem clickHandler={ action('tapped two') }>
List Item Two
</ListItem>
<ListItem clickHandler={ action('tapped three') }>
List Item Three
</ListItem>
</ListContainer>
</List>
))
.addWithInfo('no header', () => (
<List>
<ListContainer>
Expand Down

0 comments on commit 3b9a934

Please sign in to comment.