Skip to content

Instantly share code, notes, and snippets.

@alexdisdier
Last active March 6, 2020 05:55
Show Gist options
  • Save alexdisdier/f5e48c6d834d8c5a21a95d45d776de03 to your computer and use it in GitHub Desktop.
Save alexdisdier/f5e48c6d834d8c5a21a95d45d776de03 to your computer and use it in GitHub Desktop.
A react button sample story
import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, text, boolean, color } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';
import README from './README.md';
import Button from '.';
const stories = storiesOf('Button', module);
stories.addDecorator(withKnobs);
stories.addParameters({
readme: {
content: README
}
});
stories.add('default', () => {
const hasOnClick = boolean('Has onClick', true);
return (
<Button
onClick={hasOnClick ? action('clicked') : undefined}
color={color('Custom color', '')}
disabled={boolean('Disabled', false)}
>
{text('Label', 'I am a button')}
</Button>
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment