Skip to content

Instantly share code, notes, and snippets.

@alpavlove
Created July 28, 2022 14:33
Show Gist options
  • Save alpavlove/5888ac24d01c38bba06f3b8ee63b5dcc to your computer and use it in GitHub Desktop.
Save alpavlove/5888ac24d01c38bba06f3b8ee63b5dcc to your computer and use it in GitHub Desktop.
Create React Components library
import React from 'react'
import { Meta, Story } from '@storybook/react'
import { Button, ButtonProps } from '../src/Button/Button'
const meta: Meta = {
title: 'Welcome',
component: Button,
argTypes: {
children: {
control: {
type: 'text',
},
},
},
parameters: {
controls: { expanded: true },
},
}
export default meta
const Template: Story<ButtonProps> = args => <Button {...args} />
// By passing using the Args format for exported stories, you can control the props for a component for reuse in a test
// https://storybook.js.org/docs/react/workflows/unit-testing
export const ButtonStory = Template.bind({})
ButtonStory.args = {
onClick: () => alert('Test'),
children: 'Text'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment