All files / components/Button Button.stories.tsx

100% Statements 16/16
100% Branches 0/0
100% Functions 2/2
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75          1x     66x                                                 6x   1x 1x         1x 1x           1x 1x           1x 1x         1x 1x           1x 1x          
import { ComponentStory, ComponentMeta } from '@storybook/react';
 
import Button from './Button';
import * as icons from './../Icons';
 
const iconOptions = {
  none: null,
  ...Object.fromEntries(
    Object.entries(icons).map(([name, Icon]) => [name, <Icon />])
  ),
};
 
export default {
  title: 'Components/Button',
  component: Button,
  argTypes: {
    icon: {
      options: Object.keys(iconOptions),
      mapping: iconOptions,
      control: { type: 'select' },
    },
    color: {
      options: ['primary', 'secondary'],
      control: 'select',
    },
    size: {
      options: ['large', 'default', 'small'],
      control: 'select',
    },
    onClick: { action: 'clicked' },
  },
} as ComponentMeta<typeof Button>;
 
const Template: ComponentStory<typeof Button> = args => <Button {...args} />;
 
export const Primary = Template.bind({});
Primary.args = {
  color: 'primary',
  label: 'Label',
};
 
export const PrimarySmall = Template.bind({});
PrimarySmall.args = {
  color: 'primary',
  size: 'small',
  label: 'Label',
};
 
export const PrimaryLarge = Template.bind({});
PrimaryLarge.args = {
  color: 'primary',
  size: 'large',
  label: 'Label',
};
 
export const Secondary = Template.bind({});
Secondary.args = {
  color: 'secondary',
  label: 'Label',
};
 
export const SecondarySmall = Template.bind({});
SecondarySmall.args = {
  color: 'secondary',
  size: 'small',
  label: 'Label',
};
 
export const SecondaryLarge = Template.bind({});
SecondaryLarge.args = {
  color: 'secondary',
  size: 'large',
  label: 'Label',
};