Skip to content

Commit dd6d015

Browse files
committed
introduce Storybook Knobs
1 parent 2065e6c commit dd6d015

File tree

5 files changed

+109
-4
lines changed

5 files changed

+109
-4
lines changed

.storybook/addons.js

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

.storybook/config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import { configure } from '@storybook/react';
1+
import { configure, addDecorator } from '@storybook/react';
2+
import { withKnobs } from '@storybook/addon-knobs';
23

34
// pick all stories.js files within the src/ folder
45
const req = require.context('../src', true, /stories\.js$/);
56

7+
addDecorator(withKnobs);
8+
69
function loadStories() {
710
req.keys().forEach(filename => req(filename));
811
}
912

10-
configure(loadStories, module);
13+
configure(loadStories, module);

package-lock.json

Lines changed: 99 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-knobs": "^4.0.0-alpha.6",
2122
"@storybook/react": "^4.0.0-alpha.6",
2223
"babel-core": "^6.26.0",
2324
"babel-loader": "^7.1.4",

src/Checkbox/stories.js

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

56
class CheckboxStateful extends React.Component {
@@ -28,7 +29,7 @@ class CheckboxStateful extends React.Component {
2829
storiesOf('Checkbox', module)
2930
.add('with checked', () => {
3031
const value = true;
31-
const children = 'My Checkbox Label';
32+
const children = text('label', 'My Checkbox Label');
3233
const onCheckboxChange = () => {};
3334

3435
return (
@@ -39,7 +40,7 @@ storiesOf('Checkbox', module)
3940
})
4041
.add('with unchecked', () => {
4142
const value = false;
42-
const children = 'My Checkbox Label';
43+
const children = text('label', 'My Checkbox Label');
4344
const onCheckboxChange = () => {};
4445

4546
return (

0 commit comments

Comments
 (0)