2022-10-04 18:55:51 +02:00
|
|
|
import React from 'react';
|
|
|
|
import {
|
2023-02-02 21:15:26 +01:00
|
|
|
AlignItems,
|
2023-03-22 03:19:49 +01:00
|
|
|
Color,
|
2022-10-04 18:55:51 +02:00
|
|
|
DISPLAY,
|
|
|
|
FLEX_DIRECTION,
|
2023-02-02 21:15:26 +01:00
|
|
|
Size,
|
2022-10-04 18:55:51 +02:00
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import Box from '../../ui/box/box';
|
2023-04-05 18:11:10 +02:00
|
|
|
import { TextDirection, IconName } from '..';
|
|
|
|
|
2022-11-03 19:41:16 +01:00
|
|
|
import { BUTTON_BASE_SIZES } from './button-base.constants';
|
2022-10-04 18:55:51 +02:00
|
|
|
import { ButtonBase } from './button-base';
|
|
|
|
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/ButtonBase',
|
2023-01-20 20:27:46 +01:00
|
|
|
|
2022-10-04 18:55:51 +02:00
|
|
|
component: ButtonBase,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
page: README,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
as: {
|
|
|
|
control: 'select',
|
|
|
|
options: ['button', 'a'],
|
|
|
|
},
|
|
|
|
block: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
children: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
startIconName: {
|
|
|
|
control: 'select',
|
2023-04-05 18:11:10 +02:00
|
|
|
options: Object.values(IconName),
|
2023-02-22 18:42:06 +01:00
|
|
|
},
|
|
|
|
endIconName: {
|
2022-10-04 18:55:51 +02:00
|
|
|
control: 'select',
|
2023-04-05 18:11:10 +02:00
|
|
|
options: Object.values(IconName),
|
2022-10-04 18:55:51 +02:00
|
|
|
},
|
|
|
|
loading: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
control: 'select',
|
2022-11-03 19:41:16 +01:00
|
|
|
options: Object.values(BUTTON_BASE_SIZES),
|
2022-10-04 18:55:51 +02:00
|
|
|
},
|
|
|
|
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 Base',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const DefaultStory = (args) => <ButtonBase {...args} />;
|
|
|
|
|
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
export const SizeStory = (args) => (
|
2022-10-04 18:55:51 +02:00
|
|
|
<>
|
|
|
|
<Box
|
|
|
|
display={DISPLAY.FLEX}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.baseline}
|
2022-10-04 18:55:51 +02:00
|
|
|
gap={1}
|
|
|
|
marginBottom={2}
|
|
|
|
>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonBase {...args} size={Size.SM}>
|
2022-10-04 18:55:51 +02:00
|
|
|
Button SM
|
|
|
|
</ButtonBase>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonBase {...args} size={Size.MD}>
|
2022-10-04 18:55:51 +02:00
|
|
|
Button MD
|
|
|
|
</ButtonBase>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonBase {...args} size={Size.LG}>
|
2022-10-04 18:55:51 +02:00
|
|
|
Button LG
|
|
|
|
</ButtonBase>
|
|
|
|
</Box>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
SizeStory.storyName = 'Size';
|
|
|
|
|
2022-10-04 18:55:51 +02:00
|
|
|
export const Block = (args) => (
|
|
|
|
<>
|
|
|
|
<ButtonBase {...args} marginBottom={2}>
|
|
|
|
Default Button
|
|
|
|
</ButtonBase>
|
|
|
|
<ButtonBase {...args} block marginBottom={2}>
|
|
|
|
Block Button
|
|
|
|
</ButtonBase>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const As = (args) => (
|
|
|
|
<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.ROW} gap={2}>
|
|
|
|
<ButtonBase {...args}>Button Element</ButtonBase>
|
|
|
|
<ButtonBase as="a" href="#" {...args}>
|
|
|
|
Anchor Element
|
|
|
|
</ButtonBase>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
2022-11-03 19:41:16 +01:00
|
|
|
export const Href = (args) => <ButtonBase {...args}>Anchor Element</ButtonBase>;
|
|
|
|
|
|
|
|
Href.args = {
|
|
|
|
href: '/metamask',
|
|
|
|
};
|
|
|
|
|
2023-03-10 18:47:01 +01:00
|
|
|
export const ExternalLink = (args) => (
|
|
|
|
<ButtonBase {...args}>Anchor element with external link</ButtonBase>
|
|
|
|
);
|
|
|
|
|
|
|
|
ExternalLink.args = {
|
|
|
|
href: 'https://metamask.io',
|
|
|
|
externalLink: true,
|
|
|
|
};
|
|
|
|
|
2022-10-04 18:55:51 +02:00
|
|
|
export const Disabled = (args) => (
|
|
|
|
<ButtonBase {...args}>Disabled Button</ButtonBase>
|
|
|
|
);
|
|
|
|
|
|
|
|
Disabled.args = {
|
|
|
|
disabled: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
export const Loading = (args) => (
|
|
|
|
<ButtonBase {...args}>Loading Button</ButtonBase>
|
|
|
|
);
|
|
|
|
|
|
|
|
Loading.args = {
|
|
|
|
loading: true,
|
|
|
|
};
|
|
|
|
|
2023-02-22 18:42:06 +01:00
|
|
|
export const StartIconName = (args) => (
|
2023-04-05 18:11:10 +02:00
|
|
|
<ButtonBase {...args} startIconName={IconName.AddSquare}>
|
2023-02-22 18:42:06 +01:00
|
|
|
Button
|
|
|
|
</ButtonBase>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const EndIconName = (args) => (
|
2023-04-05 18:11:10 +02:00
|
|
|
<ButtonBase {...args} endIconName={IconName.Arrow2Right}>
|
2022-10-04 18:55:51 +02:00
|
|
|
Button
|
|
|
|
</ButtonBase>
|
|
|
|
);
|
2023-02-22 18:42:06 +01:00
|
|
|
|
|
|
|
export const Rtl = (args) => (
|
|
|
|
<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.COLUMN} gap={2}>
|
|
|
|
<ButtonBase
|
|
|
|
{...args}
|
2023-04-05 18:11:10 +02:00
|
|
|
startIconName={IconName.AddSquare}
|
|
|
|
endIconName={IconName.Arrow2Right}
|
2023-02-22 18:42:06 +01:00
|
|
|
>
|
|
|
|
Button Demo
|
|
|
|
</ButtonBase>
|
|
|
|
<ButtonBase
|
|
|
|
{...args}
|
2023-04-05 18:11:10 +02:00
|
|
|
startIconName={IconName.AddSquare}
|
|
|
|
endIconName={IconName.Arrow2Right}
|
2023-04-03 19:42:37 +02:00
|
|
|
textDirection={TextDirection.RightToLeft}
|
2023-02-22 18:42:06 +01:00
|
|
|
>
|
|
|
|
Button Demo
|
|
|
|
</ButtonBase>
|
|
|
|
</Box>
|
|
|
|
);
|
2023-03-22 03:19:49 +01:00
|
|
|
|
|
|
|
export const Ellipsis = (args) => (
|
|
|
|
<Box backgroundColor={Color.iconMuted} style={{ width: 150 }}>
|
|
|
|
<ButtonBase {...args}>Example without ellipsis</ButtonBase>
|
|
|
|
<ButtonBase {...args} ellipsis>
|
|
|
|
Example with ellipsis
|
|
|
|
</ButtonBase>
|
|
|
|
</Box>
|
|
|
|
);
|