Skip to content

Commit

Permalink
Add todoItem stories
Browse files Browse the repository at this point in the history
  • Loading branch information
arunoda committed Mar 24, 2016
1 parent 556e31b commit f99a034
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 20 deletions.
38 changes: 38 additions & 0 deletions components/stories/TodoItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from 'react';
import TodoItem from '../TodoItem';
import { storiesOf, action } from 'react-storybook';

storiesOf('Todo Item', module)
.add('not completed', () => {
const todo = {
id: 'the-id',
text: 'Hello Todo',
completed: false
};

return getItem(todo);
})
.add('completed', () => {
const todo = {
id: 'the-id',
text: 'Hello Todo',
completed: true
};

return getItem(todo);
});


function getItem(todo) {
return (
<div className="todoapp">
<div className="todo-list">
<TodoItem
todo={todo}
editTodo={action('editTodo')}
deleteTodo={action('deleteTodo')}
completeTodo={action('completeTodo')}/>
</div>
</div>
);
}
42 changes: 24 additions & 18 deletions components/stories/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,32 @@ import {

storiesOf('Footer', module)
.add('default view', () => (
<Footer
completedCount={10}
activeCount={4}
filter={SHOW_ALL}
onClearCompleted={action('onClearCompleted')}
onShow={action('onShow')} />
<div className="todoapp">
<Footer
completedCount={10}
activeCount={4}
filter={SHOW_ALL}
onClearCompleted={action('onClearCompleted')}
onShow={action('onShow')} />
</div>
))
.add('show completed', () => (
<Footer
completedCount={10}
activeCount={4}
filter={SHOW_COMPLETED}
onClearCompleted={action('onClearCompleted')}
onShow={action('onShow')} />
<div className="todoapp">
<Footer
completedCount={10}
activeCount={4}
filter={SHOW_COMPLETED}
onClearCompleted={action('onClearCompleted')}
onShow={action('onShow')} />
</div>
))
.add('show active', () => (
<Footer
completedCount={10}
activeCount={4}
filter={SHOW_ACTIVE}
onClearCompleted={action('onClearCompleted')}
onShow={action('onShow')} />
<div className="todoapp">
<Footer
completedCount={10}
activeCount={4}
filter={SHOW_ACTIVE}
onClearCompleted={action('onClearCompleted')}
onShow={action('onShow')} />
</div>
));
5 changes: 3 additions & 2 deletions components/stories/index.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
import './header'
import './footer'
import './Header'
import './Footer'
import './TodoItem'

0 comments on commit f99a034

Please sign in to comment.