Skip to content

Latest commit

 

History

History
43 lines (31 loc) · 1.08 KB

storybook.md

File metadata and controls

43 lines (31 loc) · 1.08 KB

Storybook

The project describes use cases for each component. Requests to the server are simulated using storybook-addon-mock.

The file with the scripts is created next to the component with the extension .stories.tsx

You can run Storybook using the command:

  • npm run storybook.

Read more about Storybook

Example:

import React from 'react';
import { ComponentStory, ComponentMeta } from '@storybook/react';

import { ThemeDecorator } from '@/shared/config/storybook/ThemeDecorator/ThemeDecorator';
import { Button, ButtonSize, ButtonTheme } from './Button';
import { Theme } from '@/shared/const/theme';

export default {
  title: 'shared/Button',
  component: Button,
  argTypes: {
    backgroundColor: { control: 'color' },
  },
} as ComponentMeta<typeof Button>;

const Template: ComponentStory<typeof Button> = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
  children: 'Text',
};

export const Clear = Template.bind({});
Clear.args = {
  children: 'Text',
  theme: ButtonTheme.CLEAR,
};