Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/components/ui/button/button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const meta: Meta<typeof Button> = {
title: 'UI/Button',
component: Button,
tags: ['autodocs'],
parameters: { layout: 'centered' },
};
export default meta;

Expand Down Expand Up @@ -50,3 +51,18 @@ export const AsLink: Story = {
children: '๋‚ด ํ”„๋กœํ•„ ๋“ฑ๋กํ•˜๊ธฐ',
},
};

/** ์ƒˆ ํ”„๋ฆฌ์…‹: xs38 (๋ชจ๋ฐ”์ผ 38 โ†’ PC 48) */
export const Size_XS38: Story = {
args: { children: '38โ†’48 ๋ฒ„ํŠผ', variant: 'primary', size: 'xs38' },
};

/** 48โ†’48 ์œ ์ง€ ํ”„๋ฆฌ์…‹ */
export const Size_LGFixed: Story = {
args: { children: '48โ†’48 ๊ณ ์ •', variant: 'primary', size: 'lgFixed' },
};

/** Bold ์˜ค๋ฒ„๋ผ์ด๋“œ ํ™•์ธ (className ๋ณ‘ํ•ฉ) */
export const BoldOverride: Story = {
args: { children: 'Bold ๋ฒ„ํŠผ', variant: 'secondary', size: 'md', className: 'font-bold' },
};
8 changes: 6 additions & 2 deletions src/components/ui/button/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { ButtonHTMLAttributes, ElementType } from 'react';

type ButtonProps = {
variant?: 'primary' | 'secondary' | 'disabled' | 'approve' | 'reject';
size?: 'lg' | 'md' | 'sm';
size?: 'lg' | 'md' | 'sm' | 'xs38' | 'lgFixed';
full?: boolean;
className?: string;
as?: ElementType;
} & ButtonHTMLAttributes<HTMLButtonElement> & { [key: string]: unknown };

Expand All @@ -15,6 +16,8 @@ const SIZE_CLASS = {
lg: 'h-12 px-4 text-base sm:h-14 sm:px-6 sm:text-lg',
md: 'h-10 px-4 text-sm sm:h-11 sm:px-5 sm:text-base',
sm: 'h-8 px-3 text-sm sm:h-9 sm:px-4 sm:text-base',
xs38: 'h-[38px] px-3.5 text-sm sm:h-12 sm:px-5 sm:text-base',
lgFixed: 'h-12 px-5 text-base sm:h-12 sm:px-5 sm:text-base',
} as const;

/* 3) variant์— ๋”ฐ๋ฅธ ์ƒ‰์ƒ/ํ…Œ๋‘๋ฆฌ */
Expand All @@ -33,6 +36,7 @@ export default function Button({
full = false,
as: Component = 'button',
children,
className,
...props
}: ButtonProps) {
// props์—์„œ type/disabled๋งŒ ๋ถ„๋ฆฌ(์ค‘๋ณต, ์ถฉ๋Œ ๋ฐฉ์ง€), ๋‚˜๋จธ์ง€๋Š” ๊ทธ๋Œ€๋กœ ์ „๋‹ฌ
Expand All @@ -41,7 +45,7 @@ export default function Button({
const variantClass = VARIANT_CLASS[variant];
return (
<Component
className={`${BASE_CLASS} ${variantClass} ${sizeClass} ${full ? 'w-full' : ''}`}
className={`${BASE_CLASS} ${variantClass} ${sizeClass} ${full ? 'w-full' : ''} ${className ?? ''}`}
{...(Component === 'button'
? {
disabled: variant === 'disabled' || disabled,
Expand Down
Loading