2022-10-07 17:50:28 +02:00
|
|
|
import React from 'react';
|
2022-11-15 21:48:24 +01:00
|
|
|
import {
|
2023-02-02 21:15:26 +01:00
|
|
|
AlignItems,
|
2022-11-15 21:48:24 +01:00
|
|
|
DISPLAY,
|
2023-02-02 21:15:26 +01:00
|
|
|
Size,
|
2022-11-15 21:48:24 +01:00
|
|
|
} from '../../../helpers/constants/design-system';
|
2022-10-07 17:50:28 +02:00
|
|
|
import Box from '../../ui/box/box';
|
2023-04-05 18:11:10 +02:00
|
|
|
import { IconName } from '..';
|
2022-10-07 17:50:28 +02:00
|
|
|
import { ButtonSecondary } from './button-secondary';
|
|
|
|
import { BUTTON_SECONDARY_SIZES } from './button-secondary.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/ButtonSecondary',
|
2023-01-20 20:27:46 +01:00
|
|
|
|
2022-10-07 17:50:28 +02:00
|
|
|
component: ButtonSecondary,
|
|
|
|
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' },
|
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
startIconName: {
|
2022-10-07 17:50:28 +02:00
|
|
|
control: 'select',
|
2023-04-05 18:11:10 +02:00
|
|
|
options: Object.values(IconName),
|
2022-10-07 17:50:28 +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-07 17:50:28 +02:00
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
2023-02-22 18:42:06 +01:00
|
|
|
endIconProps: {
|
2022-10-07 17:50:28 +02:00
|
|
|
control: 'object',
|
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
loading: {
|
|
|
|
control: 'boolean',
|
|
|
|
table: { category: 'button base props' },
|
|
|
|
},
|
|
|
|
size: {
|
|
|
|
control: 'select',
|
|
|
|
options: Object.values(BUTTON_SECONDARY_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 Secondary',
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
export const DefaultStory = (args) => <ButtonSecondary {...args} />;
|
|
|
|
|
|
|
|
DefaultStory.storyName = 'Default';
|
|
|
|
|
2023-02-02 21:15:26 +01:00
|
|
|
export const SizeStory = (args) => (
|
|
|
|
<Box display={DISPLAY.FLEX} alignItems={AlignItems.baseline} gap={1}>
|
|
|
|
<ButtonSecondary {...args} size={Size.SM}>
|
2022-10-07 17:50:28 +02:00
|
|
|
Small Button
|
|
|
|
</ButtonSecondary>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonSecondary {...args} size={Size.MD}>
|
2022-10-07 17:50:28 +02:00
|
|
|
Medium (Default) Button
|
|
|
|
</ButtonSecondary>
|
2023-02-02 21:15:26 +01:00
|
|
|
<ButtonSecondary {...args} size={Size.LG}>
|
2022-10-07 17:50:28 +02:00
|
|
|
Large Button
|
|
|
|
</ButtonSecondary>
|
|
|
|
</Box>
|
|
|
|
);
|
2023-02-02 21:15:26 +01:00
|
|
|
SizeStory.storyName = 'Size';
|
2022-10-07 17:50:28 +02:00
|
|
|
|
2022-11-09 22:55:13 +01:00
|
|
|
export const Danger = (args) => (
|
2022-10-07 17:50:28 +02:00
|
|
|
<Box display={DISPLAY.FLEX} gap={1}>
|
|
|
|
<ButtonSecondary {...args}>Normal</ButtonSecondary>
|
|
|
|
{/* Test Anchor tag to match exactly as button */}
|
|
|
|
<ButtonSecondary as="a" {...args} href="#" danger>
|
|
|
|
Danger
|
|
|
|
</ButtonSecondary>
|
|
|
|
</Box>
|
|
|
|
);
|