Commit 023cdf3b by sarahkf Committed by GitHub

Merge pull request #18 from edx/sarahkf/add-knobs

Setting up storybook knobs
parents ffcdc93f f389b689
import '@storybook/addon-options/register'; import '@storybook/addon-options/register';
import '@storybook/addon-knobs/register';
...@@ -7,7 +7,7 @@ import CssJail from '../src/CssJail'; ...@@ -7,7 +7,7 @@ import CssJail from '../src/CssJail';
setOptions({ setOptions({
name: '💎 PARAGON', name: '💎 PARAGON',
url: 'https://github.com/edx/paragon', url: 'https://github.com/edx/paragon',
showDownPanel: false, showDownPanel: true,
}); });
const req = require.context('../src', true, /\.stories\.jsx$/); const req = require.context('../src', true, /\.stories\.jsx$/);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
"react-transition-group": "^1.1.2" "react-transition-group": "^1.1.2"
}, },
"devDependencies": { "devDependencies": {
"@storybook/addon-knobs": "^3.2.0",
"@storybook/addon-options": "^3.1.6", "@storybook/addon-options": "^3.1.6",
"@storybook/addon-storyshots": "^3.1.7", "@storybook/addon-storyshots": "^3.1.7",
"@storybook/react": "3.1.9", "@storybook/react": "3.1.9",
......
...@@ -2,10 +2,12 @@ ...@@ -2,10 +2,12 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import React from 'react'; import React from 'react';
import { storiesOf } from '@storybook/react'; import { storiesOf } from '@storybook/react';
import { withKnobs, boolean } from '@storybook/addon-knobs';
import CheckBox from './index'; import CheckBox from './index';
storiesOf('CheckBox', module) storiesOf('CheckBox', module)
.addDecorator(withKnobs)
.add('basic usage', () => ( .add('basic usage', () => (
<CheckBox <CheckBox
name="checkbox" name="checkbox"
...@@ -20,7 +22,7 @@ storiesOf('CheckBox', module) ...@@ -20,7 +22,7 @@ storiesOf('CheckBox', module)
describedBy="checkbox" describedBy="checkbox"
label="you cannot check me out" label="you cannot check me out"
checked="false" checked="false"
disabled disabled={boolean('disabled', true)}
/> />
)) ))
.add('default checked', () => ( .add('default checked', () => (
......
/* eslint-disable import/no-extraneous-dependencies */ /* eslint-disable import/no-extraneous-dependencies */
import React from 'react'; import React from 'react';
import { storiesOf } from '@storybook/react'; import { storiesOf } from '@storybook/react';
import { withKnobs, text } from '@storybook/addon-knobs';
import InputText from './index'; import InputText from './index';
storiesOf('InputText', module) storiesOf('InputText', module)
.addDecorator(withKnobs)
.add('minimal usage', () => ( .add('minimal usage', () => (
<InputText <InputText
name="name" name="name"
label="First Name" label={text('label', 'First Name')}
value="Foo Bar" value="Foo Bar"
/> />
)) ))
...@@ -16,7 +18,7 @@ storiesOf('InputText', module) ...@@ -16,7 +18,7 @@ storiesOf('InputText', module)
<InputText <InputText
name="username" name="username"
label="Username" label="Username"
description="The unique name that identifies you throughout the site." description={text('description', 'The unique name that identifies you throughout the site.')}
validator={(value) => { validator={(value) => {
let feedback = { isValid: true }; let feedback = { isValid: true };
if (value.length < 3) { if (value.length < 3) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment