Created
September 11, 2020 14:04
-
-
Save rafaelrozon/1e177d13b87d541a9df56182979914b1 to your computer and use it in GitHub Desktop.
Example of how to setup a playground story in Storybook using Args.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import Button from "."; | |
// Args Setup | |
const Template = (args) => <Button {...args} />; | |
export const Playground = Template.bind({}); | |
const buttonTypes = { | |
SUBMIT: 'submit', | |
INPUT: 'input' | |
} | |
Playground.args = { | |
type: buttonTypes.INPUT, | |
text: "Primary", | |
}; | |
Playground.argTypes = { | |
type: { | |
control: { | |
type: "select", | |
options: [buttonTypes.INPUT, buttonTypes.SUBMIT] | |
} | |
}, | |
text: { | |
control: "text" | |
} | |
} | |
export const DefaultStory = () => <Button type="button" text="Click me" />; | |
DefaultStory.storyName = "Default"; | |
export default { | |
title: "Components/Button", | |
component: DefaultStory, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment