Skip to content

Commit ef37855

Browse files
committed
introduce Storybook Actions
1 parent dd6d015 commit ef37855

File tree

4 files changed

+56
-4
lines changed

4 files changed

+56
-4
lines changed

.storybook/addons.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
import '@storybook/addon-knobs/register';
2+
import '@storybook/addon-actions/register';

package-lock.json

Lines changed: 49 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"author": "",
1919
"license": "ISC",
2020
"devDependencies": {
21+
"@storybook/addon-actions": "^4.0.0-alpha.6",
2122
"@storybook/addon-knobs": "^4.0.0-alpha.6",
2223
"@storybook/react": "^4.0.0-alpha.6",
2324
"babel-core": "^6.26.0",

src/Checkbox/stories.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import { storiesOf } from '@storybook/react';
3-
import { text, boolean } from '@storybook/addon-knobs';
3+
import { text } from '@storybook/addon-knobs';
4+
import { action } from '@storybook/addon-actions';
45
import Checkbox from './';
56

67
class CheckboxStateful extends React.Component {
@@ -11,7 +12,7 @@ class CheckboxStateful extends React.Component {
1112
onCheckboxChange = value => {
1213
this.setState({ value });
1314

14-
this.props.onCheckboxChange();
15+
this.props.onCheckboxChange(value);
1516
};
1617

1718
render() {
@@ -30,7 +31,7 @@ storiesOf('Checkbox', module)
3031
.add('with checked', () => {
3132
const value = true;
3233
const children = text('label', 'My Checkbox Label');
33-
const onCheckboxChange = () => {};
34+
const onCheckboxChange = action('toggle');
3435

3536
return (
3637
<CheckboxStateful value={value} onCheckboxChange={onCheckboxChange}>
@@ -41,7 +42,7 @@ storiesOf('Checkbox', module)
4142
.add('with unchecked', () => {
4243
const value = false;
4344
const children = text('label', 'My Checkbox Label');
44-
const onCheckboxChange = () => {};
45+
const onCheckboxChange = action('toggle');
4546

4647
return (
4748
<CheckboxStateful value={value} onCheckboxChange={onCheckboxChange}>

0 commit comments

Comments
 (0)