o2o-negosium-original/front/src/components/Button.tsx
민헌 245c287a9d [refactor] front: 공통 UI를 components 디렉터리로 정리 + Logo 컴포넌트/로고 에셋 추가
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-16 14:33:23 +09:00

55 lines
1.6 KiB
TypeScript

import { type ComponentProps } from 'react'
import { cn } from './cn'
export type ButtonVariant =
| 'primary'
| 'secondary'
| 'outline'
| 'ghost'
| 'destructive'
export type ButtonSize = 'sm' | 'md' | 'lg'
const base =
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium ' +
'transition-[color,background-color,transform] cursor-pointer select-none ' +
'active:scale-[0.98] ' +
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ' +
'disabled:pointer-events-none disabled:opacity-50'
// hover 는 한 단계 톤다운(brand-700) — 디자인 선호
const variantClass: Record<ButtonVariant, string> = {
primary: 'bg-primary text-primary-foreground hover:bg-brand-700',
secondary: 'bg-secondary text-secondary-foreground hover:bg-accent',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
ghost: 'hover:bg-accent hover:text-accent-foreground',
destructive: 'bg-destructive text-white hover:opacity-90',
}
const sizeClass: Record<ButtonSize, string> = {
sm: 'h-8 px-3 text-sm',
md: 'h-10 px-4 text-sm',
lg: 'h-11 px-6 text-base',
}
export interface ButtonProps extends ComponentProps<'button'> {
variant?: ButtonVariant
size?: ButtonSize
}
export function Button({
variant = 'primary',
size = 'md',
type = 'button',
className,
...props
}: ButtonProps) {
return (
<button
type={type}
className={cn(base, variantClass[variant], sizeClass[size], className)}
{...props}
/>
)
}