diff --git a/src/shared/ui/Button/Button.stories.tsx b/src/shared/ui/Button/Button.stories.tsx index 53a37d7..129eec1 100644 --- a/src/shared/ui/Button/Button.stories.tsx +++ b/src/shared/ui/Button/Button.stories.tsx @@ -9,6 +9,51 @@ const meta: Meta = { export default meta; type Story = StoryObj; +export const Default: Story = { + render: () => { + const variantList = ['filled', 'outline', 'ghost'] as const; + const colorList = ['primary', 'neutral'] as const; + const widthType = ['fill', 'hug'] as const; + const size = ['fit', 'S', 'M'] as const; + return ( +
+
+

variant

+ {variantList.map((v) => ( + + ))} +
+
+

color

+ {colorList.map((v) => ( + + ))} +
+
+

widthType

+ {widthType.map((v) => ( + + ))} +
+
+

size

+ {size.map((v) => ( + + ))} +
+
+ ); + }, +}; + export const PrimaryButton: Story = { args: { variant: 'filled', diff --git a/src/shared/ui/Button/Button.tsx b/src/shared/ui/Button/Button.tsx index f154f6f..ce5bfad 100644 --- a/src/shared/ui/Button/Button.tsx +++ b/src/shared/ui/Button/Button.tsx @@ -1,20 +1,9 @@ import { ButtonHTMLAttributes, DetailedHTMLProps, ReactNode } from 'react'; import styles from './Button.module.css'; -import { cva } from 'cva'; - -type ButtonProps = DetailedHTMLProps, HTMLButtonElement> & { - variant: 'filled' | 'outline' | 'ghost'; - color: 'primary' | 'neutral'; - widthType: 'fill' | 'hug'; - suffixSlot?: ReactNode; - prefixSlot?: ReactNode; - textAlign?: 'left' | 'center' | 'right'; - size?: 'fit' | 'S' | 'M'; -}; +import { cva, VariantProps } from 'cva'; const buttonStyle = cva(styles.Button, { variants: { - disabled: { enabled: '', disabled: '' }, widthType: { fill: styles.WidthType_Fill, hug: styles.WidthType_Hug }, textAlign: { left: styles.TextAlign_Left, center: styles.TextAlign_Center, right: styles.TextAlign_Right }, size: { M: styles.Size_M, S: styles.Size_S, fit: styles.Size_Fit }, @@ -28,26 +17,33 @@ const buttonStyle = cva(styles.Button, { { variant: 'outline', color: 'neutral', className: styles.Variant_Outline_Neutral }, { variant: 'ghost', color: 'primary', className: styles.Variant_Ghost_Primary }, { variant: 'ghost', color: 'neutral', className: styles.Variant_Ghost_Neutral }, - { variant: 'ghost', disabled: 'disabled', className: styles.Disabled_Ghost }, ], + defaultVariants: { + variant: 'filled', + color: 'primary', + size: 'M', + textAlign: 'center', + }, }); +type ButtonProps = DetailedHTMLProps, HTMLButtonElement> & { + suffixSlot?: ReactNode; + prefixSlot?: ReactNode; +} & VariantProps; + export const Button = ({ className = '', variant, color, - size = 'M', - widthType = 'fill', - textAlign = 'center', + size, + widthType, + textAlign, suffixSlot, prefixSlot, children, ...props }: ButtonProps) => ( -