refactor: update box sizing and support multiple storybook icons for Badge

This commit is contained in:
jinhojang6 2023-04-12 04:02:06 +09:00
parent 724ac50229
commit fd9c4d268d
No known key found for this signature in database
GPG Key ID: 0E7AA62CB0D9E6F3
2 changed files with 23 additions and 9 deletions

View File

@ -1,6 +1,6 @@
import { Meta, Story } from '@storybook/react' import { Meta, Story } from '@storybook/react'
import { FolderIcon } from '../Icons'
import { Badge, BadgeProps } from './Badge' import { Badge, BadgeProps } from './Badge'
import { useStorybookIconComponent } from '../../utils/storybook.utils'
export default { export default {
title: 'Badge', title: 'Badge',
@ -31,18 +31,32 @@ export default {
value: [true, false], value: [true, false],
}, },
}, },
icon: {
type: {
name: 'enum',
value: useStorybookIconComponent.options,
},
defaultValue: 'FolderIcon',
},
}, },
} as Meta } as Meta
export const Root: Story<BadgeProps> = (args) => ( export const Root: Story<BadgeProps & { icon: string }> = ({
<Badge {...args} icon={<FolderIcon color="primary" />}> icon,
...args
}) => {
const Icon = useStorybookIconComponent(icon)
return (
<Badge {...args} icon={Icon && <Icon color="primary" />}>
Badge Badge
</Badge> </Badge>
) )
}
Root.args = { Root.args = {
variant: 'outlined', variant: 'outlined',
iconDirection: 'left', iconDirection: 'left',
disabled: false, disabled: false,
size: 'large', size: 'large',
icon: 'FolderIcon',
} }

View File

@ -4,7 +4,7 @@ import { badgeClasses } from './Badge.classes'
export const BadgeStyles = css` export const BadgeStyles = css`
.${badgeClasses.root} { .${badgeClasses.root} {
width: fit-content; width: fit-content;
box-sizing: border-box;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
@ -21,13 +21,13 @@ export const BadgeStyles = css`
} }
.${badgeClasses.large} { .${badgeClasses.large} {
padding: 4px 12px; padding: 3px 11px;
gap: 12px; gap: 12px;
height: 28px; height: 28px;
} }
.${badgeClasses.small} { .${badgeClasses.small} {
padding: 4px 8px; padding: 3px 7px;
gap: 8px; gap: 8px;
height: 24px; height: 24px;
} }