Skip to content

Instantly share code, notes, and snippets.

@rafaelrozon
Created September 11, 2020 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rafaelrozon/1e177d13b87d541a9df56182979914b1 to your computer and use it in GitHub Desktop.
Save rafaelrozon/1e177d13b87d541a9df56182979914b1 to your computer and use it in GitHub Desktop.
Example of how to setup a playground story in Storybook using Args.
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