[19/n][Storybook] Tag with typed themes (#57)

This commit is contained in:
Vivian Phung 2024-05-14 19:19:31 -04:00 committed by GitHub
commit 065b12e3d9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,17 @@
import { StoryObj, Meta } from '@storybook/react'; import { StoryObj, Meta } from '@storybook/react';
import { Tag } from 'components/shared/Tag'; import { Tag, TagTheme } from 'components/shared/Tag';
import { CheckIcon, PlusIcon } from 'components/shared/CustomIcon'; import { PlusIcon } from 'components/shared/CustomIcon';
const tagTypes: TagTheme['type'][] = [
'attention',
'negative',
'positive',
'emphasized',
'neutral',
];
const tagStyles: TagTheme['style'][] = ['default', 'minimal'];
const tagSizes: TagTheme['size'][] = ['xs', 'sm'];
const meta: Meta<typeof Tag> = { const meta: Meta<typeof Tag> = {
title: 'Components/Tag', title: 'Components/Tag',
@ -12,7 +22,7 @@ const meta: Meta<typeof Tag> = {
}, },
argTypes: { argTypes: {
children: { children: {
control: 'text', control: 'object',
}, },
leftIcon: { leftIcon: {
control: 'object', control: 'object',
@ -22,15 +32,15 @@ const meta: Meta<typeof Tag> = {
}, },
type: { type: {
control: 'select', control: 'select',
options: ['attention', 'negative', 'positive', 'emphasized', 'neutral'], options: tagTypes,
}, },
style: { style: {
control: 'select', control: 'select',
options: ['default', 'outlined'], options: tagStyles,
}, },
size: { size: {
control: 'select', control: 'select',
options: ['xs', 'sm'], options: tagSizes,
}, },
}, },
}; };
@ -40,18 +50,6 @@ export default meta;
type Story = StoryObj<typeof Tag>; type Story = StoryObj<typeof Tag>;
export const Default: Story = { export const Default: Story = {
render: ({ children, leftIcon, rightIcon, type, style, size, ...arg }) => (
<Tag
leftIcon={leftIcon}
rightIcon={rightIcon}
style={style}
type={type}
size={size}
{...arg}
>
{children}
</Tag>
),
args: { args: {
children: 'Tag', children: 'Tag',
style: 'default', style: 'default',
@ -61,15 +59,13 @@ export const Default: Story = {
}; };
export const WithLeftIcon: Story = { export const WithLeftIcon: Story = {
render: ({ ...arg }) => <Tag {...arg} />,
args: { args: {
...Default.args, ...Default.args,
leftIcon: <CheckIcon />, leftIcon: <PlusIcon />,
}, },
}; };
export const WithRightIcon: Story = { export const WithRightIcon: Story = {
render: ({ ...arg }) => <Tag {...arg} />,
args: { args: {
...Default.args, ...Default.args,
rightIcon: <PlusIcon />, rightIcon: <PlusIcon />,