2022-11-09 22:55:13 +01:00
|
|
|
import React from 'react';
|
2023-08-28 23:42:00 +02:00
|
|
|
import { StoryFn, Meta } from '@storybook/react';
|
2022-11-09 22:55:13 +01:00
|
|
|
import {
|
2023-02-02 21:15:26 +01:00
|
|
|
AlignItems,
|
2023-08-28 23:42:00 +02:00
|
|
|
Display,
|
|
|
|
FlexDirection,
|
2023-02-02 21:15:26 +01:00
|
|
|
TextVariant,
|
2022-11-09 22:55:13 +01:00
|
|
|
} from '../../../helpers/constants/design-system';
|
2023-08-28 23:42:00 +02:00
|
|
|
import { Box, IconName } from '..';
|
2022-11-09 22:55:13 +01:00
|
|
|
import { Text } from '../text';
|
|
|
|
import README from './README.mdx';
|
2023-08-28 23:42:00 +02:00
|
|
|
import { Button, ButtonSize, ButtonVariant } from '.';
|
2022-11-09 22:55:13 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Components/ComponentLibrary/Button',
|
|
|
|
component: Button,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
page: README,
|
|
|
|
},
|
|
|
|
controls: { sort: 'alpha' },
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
as: {
|
|
|
|
control: 'select',
|
|
|
|
options: ['button', 'a'],
|
|
|
|
},
|
|
|
|
block: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
children: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
danger: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
href: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
startIconName: {
|
2022-11-09 22:55:13 +01:00
|
|
|
control: 'select',
|
2023-04-05 18:11:10 +02:00
|
|
|
options: Object.values(IconName),
|
2022-11-09 22:55:13 +01:00
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
endIconName: {
|
|
|
|
control: 'select',
|
2023-04-05 18:11:10 +02:00
|
|
|
options: Object.values(IconName),
|
2023-02-22 18:42:06 +01:00
|
|
|
},
|
|
|
|
startIconProps: {
|
|
|
|
control: 'object',
|
2022-11-09 22:55:13 +01:00
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
endIconProps: {
|
2022-11-09 22:55:13 +01:00
|
|
|
control: 'object',
|
|
|
|
},
|
|
|
|
loading: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
control: 'select',
|
2023-08-28 23:42:00 +02:00
|
|
|
options: Object.values(ButtonSize),
|
2022-11-09 22:55:13 +01:00
|
|
|
},
|
2023-04-26 18:17:25 +02:00
|
|
|
variant: {
|
2023-08-28 23:42:00 +02:00
|
|
|
options: Object.values(ButtonVariant),
|
2022-11-09 22:55:13 +01:00
|
|
|
control: 'select',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
args: {
|
|
|
|
children: 'Button',
|
|
|
|
},
|
2023-08-28 23:42:00 +02:00
|
|
|
} as Meta<typeof Button>;
|
2022-11-09 22:55:13 +01:00
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
const Template: StoryFn<typeof Button> = (args) => <Button {...args} />;
|
2022-11-09 22:55:13 +01:00
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const DefaultStory = Template.bind({});
|
2022-11-09 22:55:13 +01:00
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const Variant: StoryFn<typeof Button> = () => (
|
|
|
|
<Box display={Display.Flex} gap={1}>
|
|
|
|
<Button variant={ButtonVariant.Primary}>Button Primary</Button>
|
|
|
|
<Button variant={ButtonVariant.Secondary}>Button Secondary</Button>
|
|
|
|
<Button variant={ButtonVariant.Link}>Button Link</Button>
|
2022-11-09 22:55:13 +01:00
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const SizeStory: StoryFn<typeof Button> = (args) => (
|
2022-11-09 22:55:13 +01:00
|
|
|
<>
|
|
|
|
<Box
|
2023-08-28 23:42:00 +02:00
|
|
|
display={Display.Flex}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.baseline}
|
2022-11-09 22:55:13 +01:00
|
|
|
gap={1}
|
|
|
|
marginBottom={3}
|
|
|
|
>
|
2023-08-28 23:42:00 +02:00
|
|
|
<Button {...args} variant={ButtonVariant.Primary} size={ButtonSize.Sm}>
|
2022-11-09 22:55:13 +01:00
|
|
|
Small Button
|
|
|
|
</Button>
|
2023-08-28 23:42:00 +02:00
|
|
|
<Button {...args} size={ButtonSize.Md}>
|
2022-11-09 22:55:13 +01:00
|
|
|
Medium (Default) Button
|
|
|
|
</Button>
|
2023-08-28 23:42:00 +02:00
|
|
|
<Button {...args} size={ButtonSize.Lg}>
|
2022-11-09 22:55:13 +01:00
|
|
|
Large Button
|
|
|
|
</Button>
|
2023-08-28 23:42:00 +02:00
|
|
|
<Button {...args} variant={ButtonVariant.Link}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Auto ButtonLink
|
|
|
|
</Button>
|
2022-11-09 22:55:13 +01:00
|
|
|
</Box>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Text variant={TextVariant.bodySm}>
|
2023-08-28 23:42:00 +02:00
|
|
|
<Button {...args} variant={ButtonVariant.Link} size={ButtonSize.Inherit}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Button Inherit
|
2022-11-09 22:55:13 +01:00
|
|
|
</Button>{' '}
|
2023-01-26 19:32:11 +01:00
|
|
|
inherits the font-size of the parent element. Inherit size only used for
|
2022-11-09 22:55:13 +01:00
|
|
|
ButtonLink.
|
|
|
|
</Text>
|
|
|
|
</>
|
|
|
|
);
|
2023-02-02 21:15:26 +01:00
|
|
|
SizeStory.storyName = 'Size';
|
2022-11-09 22:55:13 +01:00
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const Danger: StoryFn<typeof Button> = (args) => (
|
|
|
|
<Box display={Display.Flex} gap={1}>
|
2022-11-09 22:55:13 +01:00
|
|
|
<Button {...args}>Normal</Button>
|
|
|
|
{/* Test Anchor tag to match exactly as button */}
|
|
|
|
<Button as="a" {...args} href="#" danger>
|
|
|
|
Danger
|
|
|
|
</Button>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const Href: StoryFn<typeof Button> = (args) => (
|
|
|
|
<Button {...args}>Anchor Element</Button>
|
|
|
|
);
|
2022-11-09 22:55:13 +01:00
|
|
|
|
|
|
|
Href.args = {
|
|
|
|
href: '/metamask',
|
|
|
|
};
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const Block: StoryFn<typeof Button> = (args) => (
|
2022-11-09 22:55:13 +01:00
|
|
|
<>
|
|
|
|
<Button {...args} marginBottom={2}>
|
|
|
|
Default Button
|
|
|
|
</Button>
|
|
|
|
<Button {...args} block marginBottom={2}>
|
|
|
|
Block Button
|
|
|
|
</Button>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const As: StoryFn<typeof Button> = (args) => (
|
|
|
|
<Box display={Display.Flex} flexDirection={FlexDirection.Row} gap={2}>
|
2022-11-09 22:55:13 +01:00
|
|
|
<Button {...args}>Button Element</Button>
|
|
|
|
<Button as="a" href="#" {...args}>
|
|
|
|
Anchor Element
|
|
|
|
</Button>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const Disabled = Template.bind({});
|
2022-11-09 22:55:13 +01:00
|
|
|
Disabled.args = {
|
|
|
|
disabled: true,
|
|
|
|
};
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const Loading = Template.bind({});
|
2022-11-09 22:55:13 +01:00
|
|
|
Loading.args = {
|
|
|
|
loading: true,
|
|
|
|
};
|
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const StartIconName = Template.bind({});
|
|
|
|
StartIconName.args = {
|
|
|
|
startIconName: IconName.AddSquare,
|
|
|
|
};
|
2023-02-22 18:42:06 +01:00
|
|
|
|
2023-08-28 23:42:00 +02:00
|
|
|
export const EndIconName = Template.bind({});
|
|
|
|
EndIconName.args = {
|
|
|
|
endIconName: IconName.AddSquare,
|
|
|
|
};
|