2022-11-09 22:57:21 +01:00
|
|
|
import React from 'react';
|
|
|
|
import {
|
2023-02-02 21:15:26 +01:00
|
|
|
AlignItems,
|
|
|
|
Color,
|
2022-11-09 22:57:21 +01:00
|
|
|
DISPLAY,
|
|
|
|
FLEX_DIRECTION,
|
2023-02-02 21:15:26 +01:00
|
|
|
Size,
|
2022-11-09 22:57:21 +01:00
|
|
|
} from '../../../helpers/constants/design-system';
|
|
|
|
import Box from '../../ui/box/box';
|
|
|
|
import { ICON_NAMES } from '../icon';
|
|
|
|
import { BUTTON_ICON_SIZES } from './button-icon.constants';
|
|
|
|
import { ButtonIcon } from './button-icon';
|
|
|
|
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/ButtonIcon',
|
2023-01-20 20:27:46 +01:00
|
|
|
|
2022-11-09 22:57:21 +01:00
|
|
|
component: ButtonIcon,
|
|
|
|
parameters: {
|
|
|
|
docs: {
|
|
|
|
page: README,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
argTypes: {
|
|
|
|
ariaLabel: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
as: {
|
|
|
|
control: 'select',
|
|
|
|
options: ['button', 'a'],
|
|
|
|
},
|
|
|
|
className: {
|
|
|
|
control: 'text',
|
|
|
|
},
|
|
|
|
color: {
|
|
|
|
control: 'select',
|
2023-02-02 21:15:26 +01:00
|
|
|
options: Object.values(Color),
|
2022-11-09 22:57:21 +01:00
|
|
|
},
|
|
|
|
disabled: {
|
|
|
|
control: 'boolean',
|
|
|
|
},
|
|
|
|
href: {
|
2022-12-01 18:26:31 +01:00
|
|
|
control: 'text',
|
2022-11-09 22:57:21 +01:00
|
|
|
},
|
2022-12-01 18:26:31 +01:00
|
|
|
iconName: {
|
2022-11-09 22:57:21 +01:00
|
|
|
control: 'select',
|
|
|
|
options: Object.values(ICON_NAMES),
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
control: 'select',
|
|
|
|
options: Object.values(BUTTON_ICON_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' },
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const DefaultStory = (args) => <ButtonIcon {...args} />;
|
|
|
|
|
|
|
|
DefaultStory.args = {
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName: ICON_NAMES.CLOSE,
|
2022-11-09 22:57:21 +01:00
|
|
|
ariaLabel: 'Close',
|
|
|
|
};
|
|
|
|
|
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
2022-12-01 18:26:31 +01:00
|
|
|
export const IconName = (args) => <ButtonIcon {...args} />;
|
|
|
|
|
|
|
|
IconName.args = {
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName: ICON_NAMES.CLOSE,
|
2022-12-01 18:26:31 +01:00
|
|
|
ariaLabel: 'Close',
|
|
|
|
};
|
2022-11-09 22:57:21 +01:00
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
export const SizeStory = (args) => (
|
2022-11-09 22:57:21 +01:00
|
|
|
<Box
|
|
|
|
display={DISPLAY.FLEX}
|
2023-02-02 21:15:26 +01:00
|
|
|
alignItems={AlignItems.baseline}
|
2022-11-09 22:57:21 +01:00
|
|
|
gap={1}
|
|
|
|
marginBottom={2}
|
|
|
|
>
|
|
|
|
<ButtonIcon
|
|
|
|
{...args}
|
2023-02-02 21:15:26 +01:00
|
|
|
size={Size.SM}
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.CLOSE}
|
2022-11-09 22:57:21 +01:00
|
|
|
ariaLabel="Close"
|
|
|
|
/>
|
|
|
|
<ButtonIcon
|
|
|
|
{...args}
|
2023-02-02 21:15:26 +01:00
|
|
|
size={Size.LG}
|
|
|
|
color={Color.primaryDefault}
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.CLOSE}
|
2022-11-09 22:57:21 +01:00
|
|
|
ariaLabel="Close"
|
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
SizeStory.storyName = 'Size';
|
|
|
|
|
2022-11-09 22:57:21 +01:00
|
|
|
export const AriaLabel = (args) => (
|
|
|
|
<>
|
|
|
|
<ButtonIcon
|
|
|
|
as="button"
|
2023-01-24 18:39:46 +01:00
|
|
|
iconName={ICON_NAMES.CLOSE}
|
2022-11-09 22:57:21 +01:00
|
|
|
ariaLabel="Close"
|
|
|
|
{...args}
|
|
|
|
/>
|
|
|
|
<ButtonIcon
|
|
|
|
as="a"
|
|
|
|
href="https://metamask.io/"
|
|
|
|
target="_blank"
|
2023-02-02 21:15:26 +01:00
|
|
|
color={Color.primaryDefault}
|
2022-12-01 18:26:31 +01:00
|
|
|
iconName={ICON_NAMES.EXPORT}
|
2022-11-09 22:57:21 +01:00
|
|
|
ariaLabel="Visit MetaMask.io"
|
|
|
|
{...args}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const As = (args) => (
|
|
|
|
<Box display={DISPLAY.FLEX} flexDirection={FLEX_DIRECTION.ROW} gap={2}>
|
2023-01-24 18:39:46 +01:00
|
|
|
<ButtonIcon {...args} iconName={ICON_NAMES.CLOSE} ariaLabel="close" />
|
2022-11-09 22:57:21 +01:00
|
|
|
<ButtonIcon
|
|
|
|
as="a"
|
|
|
|
href="#"
|
|
|
|
{...args}
|
2023-02-02 21:15:26 +01:00
|
|
|
color={Color.primaryDefault}
|
2022-12-01 18:26:31 +01:00
|
|
|
iconName={ICON_NAMES.EXPORT}
|
|
|
|
ariaLabel="demo"
|
2022-11-09 22:57:21 +01:00
|
|
|
/>
|
|
|
|
</Box>
|
|
|
|
);
|
|
|
|
|
|
|
|
export const Href = (args) => (
|
2022-12-01 18:26:31 +01:00
|
|
|
<ButtonIcon iconName={ICON_NAMES.EXPORT} {...args} target="_blank" />
|
2022-11-09 22:57:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
Href.args = {
|
2022-12-01 18:26:31 +01:00
|
|
|
ariaLabel: 'Visit Metamask.io',
|
2022-11-09 22:57:21 +01:00
|
|
|
href: 'https://metamask.io/',
|
2023-02-02 21:15:26 +01:00
|
|
|
color: Color.primaryDefault,
|
2022-11-09 22:57:21 +01:00
|
|
|
};
|
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
export const ColorStory = (args) => (
|
2023-01-24 18:39:46 +01:00
|
|
|
<ButtonIcon {...args} iconName={ICON_NAMES.CLOSE} ariaLabel="close" />
|
2022-11-09 22:57:21 +01:00
|
|
|
);
|
2023-02-02 21:15:26 +01:00
|
|
|
ColorStory.storyName = 'Color';
|
2022-11-09 22:57:21 +01:00
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
ColorStory.args = {
|
|
|
|
color: Color.primaryDefault,
|
2022-11-09 22:57:21 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
export const Disabled = (args) => (
|
2023-01-24 18:39:46 +01:00
|
|
|
<ButtonIcon {...args} iconName={ICON_NAMES.CLOSE} ariaLabel="close" />
|
2022-11-09 22:57:21 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
Disabled.args = {
|
|
|
|
disabled: true,
|
|
|
|
};
|