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
2 changes: 1 addition & 1 deletion src/app/schedule/(components)/empty-state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const EmptyState = ({ type, onButtonClick }: EmptyStateProps) => {

<Button
className={cn('text-text-sm-bold mt-[18px]', config.buttonWidth)}
size='xs'
size='sm'
variant='primary'
onClick={onButtonClick}
>
Expand Down
8 changes: 4 additions & 4 deletions src/components/shared/card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ const Card = ({
{shouldShowButtons && (
<Button
className='mt-3'
size='xs'
variant='leave'
size='sm'
variant='tertiary'
onClick={(e) => {
e.stopPropagation();
leaveAndChatActions.onLeave();
Expand Down Expand Up @@ -115,8 +115,8 @@ const Card = ({
{shouldShowButtons && (
<Button
className='mt-3'
size='xs'
variant='chat'
size='sm'
variant='primary'
onClick={(e) => {
e.stopPropagation();
leaveAndChatActions.onChat();
Expand Down
6 changes: 2 additions & 4 deletions src/components/ui/button/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ describe('버튼 컴포넌트 테스트', () => {

const button = screen.getByRole('button');

expect(button).toHaveClass('text-text-sm-semibold');
expect(button).toHaveClass('h-11');
expect(button).toHaveClass('max-w-[112px]');
expect(button).toHaveClass('h-10');
});

test('disabled 테스트', () => {
Expand All @@ -65,7 +63,7 @@ describe('버튼 컴포넌트 테스트', () => {
);
const button = screen.getByRole('button');

expect(button).toHaveClass('disabled:bg-gray-400');
expect(button).toHaveClass('!cursor-not-allowed');
});

test('onClick event 테스트', () => {
Expand Down
66 changes: 44 additions & 22 deletions src/components/ui/button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,68 @@ import { cva } from 'class-variance-authority';

import { cn } from '@/lib/utils';

const buttonVariants = cva(
'bg-mono-white w-full border transition hover:cursor-pointer hover:opacity-80 disabled:cursor-not-allowed',
{
variants: {
variant: {
primary: 'bg-mint-400 text-mono-white disabled:bg-gray-400',
secondary: 'border-mint-500 text-mint-500 disabled:border-gray-400 disabled:text-gray-400',
tertiary: 'border-gray-400 text-gray-600 disabled:text-gray-400',
leave: 'border-gray-200 bg-mono-white text-gray-600 text-text-sm-semibold',
chat: 'border-mint-500 bg-mint-500 text-mono-white text-text-sm-bold',
},
size: {
md: 'text-text-md-bold h-14 rounded-[16px]',
sm: 'text-text-sm-semibold h-11 max-w-[112px] rounded-[16px]',
xs: 'h-10 rounded-xl',
},
const buttonVariants = cva('bg-mono-white w-full border transition', {
variants: {
variant: {
primary: 'bg-mint-400 text-text-md-bold text-mono-white',
secondary: 'border-mint-500 text-text-sm-semibold text-mint-500',
tertiary: 'border-gray-400 text-text-sm-semibold text-gray-600',
},
defaultVariants: {
size: {
md: 'h-13 rounded-2xl',
sm: 'h-10 rounded-xl',
},
disabled: {
true: '!cursor-not-allowed',
false: 'hover:opacity-80',
},
},
compoundVariants: [
{
variant: 'primary',
size: 'md',
disabled: true,
class: 'bg-gray-400',
},
{
variant: 'secondary',
disabled: true,
class: 'border-gray-400 text-gray-400',
},
{
variant: 'tertiary',
disabled: true,
class: 'text-gray-400',
},
],
defaultVariants: {
variant: 'primary',
size: 'md',
disabled: false,
},
);
});

interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: 'primary' | 'secondary' | 'tertiary' | 'leave' | 'chat';
size?: 'md' | 'sm' | 'xs';
variant?: 'primary' | 'secondary' | 'tertiary';
size?: 'md' | 'sm';
type?: 'button' | 'submit' | 'reset';
}

export const Button = ({
className,
variant,
size,
disabled = false,
children,
type = 'button',
...props
}: ButtonProps) => {
return (
<button className={cn(buttonVariants({ variant, size }), className)} type={type} {...props}>
<button
className={cn(buttonVariants({ variant, size, disabled: !!disabled }), className)}
disabled={disabled}
type={type}
{...props}
>
{children}
</button>
);
Expand Down