import React from 'react'; import { storiesOf } from '@storybook/react'; import moment from 'moment'; import { withKnobs, number, object, boolean, text, select, date, array, color, files, } from '../../src'; const stories = storiesOf('Example of Knobs', module); stories.addDecorator(withKnobs); stories.add('simple example', () => ); stories.add('with all knobs', () => { const name = text('Name', 'Tom Cary'); const dob = date('DOB', new Date('January 20 1887')); const bold = boolean('Bold', false); const selectedColor = color('Color', 'black'); const favoriteNumber = number('Favorite Number', 42); const comfortTemp = number('Comfort Temp', 72, { range: true, min: 60, max: 90, step: 1 }); const passions = array('Passions', ['Fishing', 'Skiing']); const images = files('Happy Picture', 'image/*', [ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfiARwMCyEWcOFPAAAAP0lEQVQoz8WQMQoAIAwDL/7/z3GwghSp4KDZyiUpBMCYUgd8rehtH16/l3XewgU2KAzapjXBbNFaPS6lDMlKB6OiDv3iAH1OAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTAxLTI4VDEyOjExOjMzLTA3OjAwlAHQBgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0wMS0yOFQxMjoxMTozMy0wNzowMOVcaLoAAAAASUVORK5CYII=', ]); const customStyle = object('Style', { fontFamily: 'Arial', padding: 20, }); const style = { ...customStyle, fontWeight: bold ? 800 : 400, favoriteNumber, color: selectedColor, }; return (
I'm {name} and I was born on "{moment(dob).format('DD MMM YYYY')}" I like:{' '}

My favorite number is {favoriteNumber}.

My most comfortable room temperature is {comfortTemp} degrees Fahrenheit.

When I am happy I look like this: happy

); }); stories.add('dates Knob', () => { const today = date('today'); const dob = date('DOB', null); const myDob = date('My DOB', new Date('July 07 1993')); return ( ); }); stories.add('dynamic knobs', () => { const showOptional = select('Show optional', ['yes', 'no'], 'yes'); return (
{text('compulsary', 'I must be here')}
{showOptional === 'yes' ?
{text('optional', 'I can disapear')}
: null}
); }); stories.add('without any knob', () => );