Skip to content

Commit

Permalink
Merge pull request #2 from kadirahq/style-tweaks-and-readme-update
Browse files Browse the repository at this point in the history
Style tweaks and readme update
  • Loading branch information
roonyh committed Aug 30, 2016
2 parents b1a7fbe + fa87a43 commit 1f6f3dd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# Knobs
> A Prop Editor for react storybook
![usage](usage.gif)

## API

Use function `createKnob` passed to your stories to create a *knob* for a prop.

`createKnob(name, initialValue, type)`

* `name`: Should uniquely idintify the prop. Used as the label of the knob
* `initialValue`: Value used when first rendered
* `type`: Optionally specify a type for the prop. Decides the input type of the knob. Currently the string 'object' is identified and it gives knob a textarea input that will be `eval`ed for an object. By default shows a text input.


```js
import React from 'react';
import Button from './Button';
Expand Down
5 changes: 3 additions & 2 deletions src/components/PropField.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const stylesheet = {
display: 'inline-block',
height: '26px',
outline: 'none',
border: '0px',
fontSize: '12px',
padding: '5px',
width: '70%',
Expand All @@ -24,8 +25,8 @@ const stylesheet = {
color: 'rgb(130, 130, 130)',
},
field: {
marginBottom: '3px',
verticalAlign: 'middle',
padding: '5px',
color: 'rgb(130, 130, 130)',
},
label: {
display: 'inline-block',
Expand Down
2 changes: 2 additions & 0 deletions src/components/PropForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import PropField from './PropField';

const stylesheet = {
propForm: {
padding: '2px',
backgroundColor: 'rgb(240, 240, 240)',
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ storiesOf('Button', module)
<Button
onClick={ action('button clicked') }
color={createKnob('color', '#fff')}
style={createKnob('style', { width: '50px' }, 'object')}
style={createKnob('style', { width: '70px' }, 'object')}
>
{createKnob('children', 'Hello')}
</Button>
Expand Down
Binary file added usage.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 1f6f3dd

Please sign in to comment.