|
| 1 | +import type { Meta, StoryObj } from '@storybook/react'; |
| 2 | + |
| 3 | +import { Button, ButtonLikeShapeEnum, ButtonLikeSizeEnum } from '@proton/atoms'; |
| 4 | +import type { ButtonLikeOwnProps } from '@proton/atoms'; |
| 5 | +import { ThemeColor } from '@proton/colors'; |
| 6 | + |
| 7 | +const meta: Meta<typeof Button> = { |
| 8 | + args: { |
| 9 | + color: ThemeColor.Norm, |
| 10 | + children: 'I am a button', |
| 11 | + 'data-testid': '', |
| 12 | + disabled: false, |
| 13 | + fullWidth: false, |
| 14 | + group: false, |
| 15 | + icon: false, |
| 16 | + loading: false, |
| 17 | + noDisabledStyles: false, |
| 18 | + pill: false, |
| 19 | + selected: false, |
| 20 | + shape: ButtonLikeShapeEnum.Solid, |
| 21 | + size: ButtonLikeSizeEnum.Medium, |
| 22 | + }, |
| 23 | + component: Button, |
| 24 | + parameters: { |
| 25 | + docs: { |
| 26 | + description: { |
| 27 | + component: 'Button component.', |
| 28 | + }, |
| 29 | + }, |
| 30 | + }, |
| 31 | + tags: ['autodocs'], |
| 32 | +}; |
| 33 | + |
| 34 | +export default meta; |
| 35 | + |
| 36 | +type Story = StoryObj<typeof Button>; |
| 37 | + |
| 38 | +export const Default: Story = {}; |
| 39 | + |
| 40 | +// Colors |
| 41 | +const AllColorsSorted = Object.values(ThemeColor).sort(); |
| 42 | +const AllColorsWithProps = (props: ButtonLikeOwnProps = {}) => ( |
| 43 | + <> |
| 44 | + {AllColorsSorted.map((color: ThemeColor) => ( |
| 45 | + <Button key={color} {...props} children={color} color={color} /> |
| 46 | + ))} |
| 47 | + </> |
| 48 | +); |
| 49 | + |
| 50 | +export const AllColors: Story = { |
| 51 | + render: () => AllColorsWithProps(), |
| 52 | +}; |
| 53 | +export const AllColorsDisabled: Story = { |
| 54 | + render: () => AllColorsWithProps({ disabled: true }), |
| 55 | +}; |
| 56 | +export const AllColorsFullWidth: Story = { |
| 57 | + render: () => AllColorsWithProps({ fullWidth: true }), |
| 58 | +}; |
| 59 | +export const AllColorsAsIcon: Story = { |
| 60 | + render: () => AllColorsWithProps({ icon: true }), |
| 61 | +}; |
| 62 | +export const AllColorsLoading: Story = { |
| 63 | + render: () => AllColorsWithProps({ loading: true }), |
| 64 | +}; |
| 65 | +export const AllColorsPill: Story = { |
| 66 | + render: () => AllColorsWithProps({ pill: true }), |
| 67 | +}; |
| 68 | + |
| 69 | +// Shapes |
| 70 | +const AllShapesSorted = Object.values(ButtonLikeShapeEnum).sort(); |
| 71 | +const AllShapesWithProps = (props: ButtonLikeOwnProps = {}) => ( |
| 72 | + <> |
| 73 | + {AllShapesSorted.map((shape: ButtonLikeShapeEnum) => ( |
| 74 | + <Button key={shape} {...props} children={shape} color={ThemeColor.Norm} shape={shape} /> |
| 75 | + ))} |
| 76 | + </> |
| 77 | +); |
| 78 | + |
| 79 | +export const AllShapes: Story = { |
| 80 | + render: () => AllShapesWithProps(), |
| 81 | +}; |
| 82 | +export const AllShapesDisabled: Story = { |
| 83 | + render: () => AllShapesWithProps({ disabled: true }), |
| 84 | +}; |
| 85 | +export const AllShapesFullWidth: Story = { |
| 86 | + render: () => AllShapesWithProps({ fullWidth: true }), |
| 87 | +}; |
| 88 | +export const AllShapesAsIcon: Story = { |
| 89 | + render: () => AllShapesWithProps({ icon: true }), |
| 90 | +}; |
| 91 | +export const AllShapesLoading: Story = { |
| 92 | + render: () => AllShapesWithProps({ loading: true }), |
| 93 | +}; |
| 94 | +export const AllShapesPill: Story = { |
| 95 | + render: () => AllShapesWithProps({ pill: true }), |
| 96 | +}; |
| 97 | + |
| 98 | +// Sizes |
| 99 | +const AllSizesSorted = Object.values(ButtonLikeSizeEnum).sort(); |
| 100 | +const AllSizesWithProps = (props: ButtonLikeOwnProps = {}) => ( |
| 101 | + <> |
| 102 | + {AllSizesSorted.map((size: ButtonLikeSizeEnum) => ( |
| 103 | + <Button key={size} {...props} children={size} color={ThemeColor.Norm} size={size} /> |
| 104 | + ))} |
| 105 | + </> |
| 106 | +); |
| 107 | + |
| 108 | +export const AllSizes: Story = { |
| 109 | + render: () => AllSizesWithProps(), |
| 110 | +}; |
| 111 | +export const AllSizesDisabled: Story = { |
| 112 | + render: () => AllSizesWithProps({ disabled: true }), |
| 113 | +}; |
| 114 | +export const AllSizesFullWidth: Story = { |
| 115 | + render: () => AllSizesWithProps({ fullWidth: true }), |
| 116 | +}; |
| 117 | +export const AllSizesAsIcon: Story = { |
| 118 | + render: () => AllSizesWithProps({ icon: true }), |
| 119 | +}; |
| 120 | +export const AllSizesLoading: Story = { |
| 121 | + render: () => AllSizesWithProps({ loading: true }), |
| 122 | +}; |
| 123 | +export const AllSizesPill: Story = { |
| 124 | + render: () => AllSizesWithProps({ pill: true }), |
| 125 | +}; |
0 commit comments