2022-10-14 00:39:22 +02:00
|
|
|
import React from 'react';
|
|
|
|
import {
|
2023-02-02 21:15:26 +01:00
|
|
|
AlignItems,
|
|
|
|
BorderColor,
|
|
|
|
BorderStyle,
|
2022-10-14 00:39:22 +02:00
|
|
|
DISPLAY,
|
2023-02-02 21:15:26 +01:00
|
|
|
Size,
|
|
|
|
TextVariant,
|
|
|
|
TextColor,
|
2022-10-14 00:39:22 +02:00
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import Box from '../../ui/box/box';
|
2023-04-05 18:11:10 +02:00
|
|
|
import { IconName } from '..';
|
2022-10-14 00:39:22 +02:00
|
|
|
import { Text } from '../text';
|
|
|
|
import { ButtonLink } from './button-link';
|
|
|
|
import { BUTTON_LINK_SIZES } from './button-link.constants';
|
|
|
|
import README from './README.mdx';
|
|
|
|
|
|
|
|
const marginSizeControlOptions = [
|
|
|
|
undefined,
|
|
|
|
0,
|
|
|
|
1,
|
|
|
|
2,
|
|
|
|
3,
|
|
|
|
4,
|
|
|
|
5,
|
|
|
|
6,
|
|
|
|
7,
|
|
|
|
8,
|
|
|
|
9,
|
|
|
|
10,
|
|
|
|
11,
|
|
|
|
12,
|
|
|
|
'auto',
|
|
|
|
];
|
|
|
|
|
|
|
|
export default {
|
|
|
|
title: 'Components/ComponentLibrary/ButtonLink',
|
2023-01-20 20:27:46 +01:00
|
|
|
|
2022-10-14 00:39:22 +02:00
|
|
|
component: ButtonLink,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
page: README,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
as: {
|
|
|
|
control: 'select',
|
|
|
|
options: ['button', 'a'],
|
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
block: {
|
|
|
|
control: 'boolean',
|
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
children: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
danger: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
control: 'boolean',
|
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
href: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
2023-03-10 18:47:01 +01:00
|
|
|
externalLink: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
startIconName: {
|
2022-10-14 00:39:22 +02:00
|
|
|
control: 'select',
|
2023-04-05 18:11:10 +02:00
|
|
|
options: Object.values(IconName),
|
2022-10-14 00:39:22 +02:00
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
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
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
startIconProps: {
|
|
|
|
control: 'object',
|
2022-10-14 00:39:22 +02:00
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
endIconProps: {
|
2022-10-14 00:39:22 +02:00
|
|
|
control: 'object',
|
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
loading: {
|
|
|
|
control: 'boolean',
|
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
control: 'select',
|
|
|
|
options: Object.values(BUTTON_LINK_SIZES),
|
|
|
|
},
|
|
|
|
marginTop: {
|
|
|
|
options: marginSizeControlOptions,
|
|
|
|
control: 'select',
|
|
|
|
table: { category: 'box props' },
|
|
|
|
},
|
|
|
|
marginRight: {
|
|
|
|
options: marginSizeControlOptions,
|
|
|
|
control: 'select',
|
|
|
|
table: { category: 'box props' },
|
|
|
|
},
|
|
|
|
marginBottom: {
|
|
|
|
options: marginSizeControlOptions,
|
|
|
|
control: 'select',
|
|
|
|
table: { category: 'box props' },
|
|
|
|
},
|
|
|
|
marginLeft: {
|
|
|
|
options: marginSizeControlOptions,
|
|
|
|
control: 'select',
|
|
|
|
table: { category: 'box props' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
args: {
|
|
|
|
children: 'Button Link',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const DefaultStory = (args) => <ButtonLink {...args} />;
|
|
|
|
|
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
export const SizeStory = (args) => (
|
2022-10-14 00:39:22 +02:00
|
|
|
<>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Box display={DISPLAY.FLEX} alignItems={AlignItems.flexStart} gap={4}>
|
|
|
|
<ButtonLink {...args} size={Size.auto}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Auto (default)
|
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.SM}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Small
|
2022-10-14 00:39:22 +02:00
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.MD}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Medium
|
2022-10-14 00:39:22 +02:00
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.LG}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Large
|
2022-10-14 00:39:22 +02:00
|
|
|
</ButtonLink>
|
|
|
|
</Box>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Text variant={TextVariant.bodyLgMedium}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Inherits the font-size of the parent element.{' '}
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.inherit}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Learn more
|
|
|
|
</ButtonLink>
|
|
|
|
</Text>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Text variant={TextVariant.bodyMd}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Inherits the font-size of the parent element.{' '}
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.inherit}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Learn more
|
|
|
|
</ButtonLink>
|
|
|
|
</Text>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Text variant={TextVariant.bodySm}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Inherits the font-size of the parent element.{' '}
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.inherit}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Learn more
|
|
|
|
</ButtonLink>
|
|
|
|
</Text>
|
2023-02-02 21:15:26 +01:00
|
|
|
<Text variant={TextVariant.bodyXs}>
|
2023-03-22 03:19:49 +01:00
|
|
|
Inherits the font-size of the parent element and example with override for
|
|
|
|
a success color.{' '}
|
2023-02-01 08:55:46 +01:00
|
|
|
<ButtonLink
|
|
|
|
{...args}
|
2023-02-02 21:15:26 +01:00
|
|
|
size={Size.inherit}
|
2023-03-22 03:19:49 +01:00
|
|
|
color={TextColor.successDefault}
|
2023-02-01 08:55:46 +01:00
|
|
|
>
|
2023-01-26 19:32:11 +01:00
|
|
|
Learn more
|
|
|
|
</ButtonLink>
|
2022-10-14 00:39:22 +02:00
|
|
|
</Text>
|
|
|
|
</>
|
|
|
|
);
|
2023-02-02 21:15:26 +01:00
|
|
|
SizeStory.storyName = 'Size';
|
2022-10-14 00:39:22 +02:00
|
|
|
|
2022-11-09 22:55:13 +01:00
|
|
|
export const Danger = (args) => (
|
2023-01-26 19:32:11 +01:00
|
|
|
<Box display={DISPLAY.FLEX} gap={4}>
|
2022-10-14 00:39:22 +02:00
|
|
|
<ButtonLink {...args}>Normal</ButtonLink>
|
|
|
|
{/* Test Anchor tag to match exactly as button */}
|
|
|
|
<ButtonLink as="a" {...args} href="#" danger>
|
|
|
|
Danger
|
|
|
|
</ButtonLink>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
2023-01-26 19:32:11 +01:00
|
|
|
export const Href = (args) => <ButtonLink {...args}>Href example</ButtonLink>;
|
2022-10-14 00:39:22 +02:00
|
|
|
|
|
|
|
Href.args = {
|
|
|
|
href: '/metamask',
|
|
|
|
};
|
2023-01-26 19:32:11 +01:00
|
|
|
|
2023-03-10 18:47:01 +01:00
|
|
|
export const ExternalLink = (args) => (
|
|
|
|
<ButtonLink {...args}>Anchor element with external link</ButtonLink>
|
|
|
|
);
|
|
|
|
|
|
|
|
ExternalLink.args = {
|
|
|
|
href: 'https://metamask.io/',
|
|
|
|
externalLink: true,
|
|
|
|
};
|
|
|
|
|
2023-01-26 19:32:11 +01:00
|
|
|
export const HitArea = (args) => (
|
|
|
|
<>
|
|
|
|
<Text marginBottom={4}>Default</Text>
|
|
|
|
<Box
|
|
|
|
display={DISPLAY.FLEX}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.flexStart}
|
2023-01-26 19:32:11 +01:00
|
|
|
gap={4}
|
|
|
|
marginBottom={4}
|
|
|
|
>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.auto}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Auto (default)
|
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.SM}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Small
|
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.MD}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Medium
|
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.LG}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Large
|
|
|
|
</ButtonLink>
|
|
|
|
</Box>
|
|
|
|
<Text marginBottom={4}>Add paddingLeft and paddingRight props</Text>
|
|
|
|
<Box
|
|
|
|
display={DISPLAY.FLEX}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.flexStart}
|
2023-01-26 19:32:11 +01:00
|
|
|
gap={4}
|
|
|
|
marginBottom={4}
|
|
|
|
>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} paddingLeft={4} paddingRight={4} size={Size.auto}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Auto (default)
|
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} paddingLeft={4} paddingRight={4} size={Size.SM}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Small
|
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} paddingLeft={4} paddingRight={4} size={Size.MD}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Medium
|
|
|
|
</ButtonLink>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} paddingLeft={4} paddingRight={4} size={Size.LG}>
|
2023-01-26 19:32:11 +01:00
|
|
|
Large
|
|
|
|
</ButtonLink>
|
|
|
|
</Box>
|
|
|
|
<Text marginBottom={4}>Add block prop</Text>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonLink {...args} size={Size.LG} block>
|
2023-01-26 19:32:11 +01:00
|
|
|
Large block
|
|
|
|
</ButtonLink>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
HitArea.args = {
|
2023-02-02 21:15:26 +01:00
|
|
|
borderColor: BorderColor.errorDefault,
|
|
|
|
borderStyle: BorderStyle.dashed,
|
2023-01-26 19:32:11 +01:00
|
|
|
};
|