[refactor] front: 공통 UI를 components 디렉터리로 정리 + Logo 컴포넌트/로고 에셋 추가

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
민헌andClaude Opus 4.8 committed 2026-06-16 14:33:23 +09:00
1 parent 7d47227141
commit 245c287a9d
7 files changed
+60 -1

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
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}
/>
)
}
+18
View File
@@ -0,0 +1,18 @@
import { type ComponentProps } from 'react'
import { cn } from './cn'
export function Input({ type = 'text', className, ...props }: ComponentProps<'input'>) {
return (
<input
type={type}
className={cn(
'flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm',
'placeholder:text-muted-foreground',
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
'disabled:cursor-not-allowed disabled:opacity-50',
className,
)}
{...props}
/>
)
}
+56
View File
@@ -0,0 +1,56 @@
import { type ComponentProps } from 'react'
import { cn } from './cn'
import logoColor from '@/assets/imarketkorea-logo.png'
import logoWhite from '@/assets/imarketkorea-logo-white.png'
export type LogoVariant = 'color' | 'white'
export type LogoSize = 'sm' | 'md' | 'lg'
const sources: Record<LogoVariant, string> = {
color: logoColor, // 브랜드 블루 심볼 — 밝은 배경용
white: logoWhite, // 화이트 심볼 — 어두운 배경용
}
// 심볼 높이에 맞춰 텍스트도 함께 스케일한다.
const sizes: Record<LogoSize, { img: string; text: string; gap: string }> = {
sm: { img: 'h-6', text: 'text-base', gap: 'gap-1.5' },
md: { img: 'h-8', text: 'text-xl', gap: 'gap-2' },
lg: { img: 'h-10', text: 'text-2xl', gap: 'gap-2.5' },
}
export interface LogoProps extends Omit<ComponentProps<'div'>, 'children'> {
variant?: LogoVariant
size?: LogoSize
/** 워드마크(iMarket Korea) 텍스트 노출 여부 */
withText?: boolean
/** 심볼 이미지 alt */
alt?: string
}
export function Logo({
variant = 'color',
size = 'md',
withText = true,
alt = 'iMarket Korea',
className,
...props
}: LogoProps) {
const s = sizes[size]
return (
<div className={cn('flex items-center', s.gap, className)} {...props}>
<img
src={sources[variant]}
alt={withText ? '' : alt}
className={cn('w-auto select-none', s.img)}
/>
{withText && (
<span className={cn('font-bold tracking-[-0.4px] text-foreground', s.text)}>
iMarket Korea
</span>
)}
</div>
)
}
export default Logo
+11
View File
@@ -0,0 +1,11 @@
// 경량 className 병합 헬퍼 (외부 의존성 없음).
// falsy 값을 걸러 공백으로 join 한다. 조건부 클래스: cn('base', isActive && 'active').
//
// 주의: tailwind-merge 가 아니므로 같은 속성의 Tailwind 유틸이 충돌할 때
// (예: 'px-4' + 'px-2') 자동 정리는 하지 않는다. 전달한 className 을
// 뒤에 두어 우선하도록 의도하지만, 최종 승자는 CSS 출력 순서를 따른다.
export type ClassValue = string | number | false | null | undefined
export function cn(...classes: ClassValue[]): string {
return classes.filter(Boolean).join(' ')
}
+6
View File
@@ -0,0 +1,6 @@
export { cn } from './cn'
export { Button } from './Button'
export type { ButtonProps, ButtonVariant, ButtonSize } from './Button'
export { Input } from './Input'
export { Logo } from './Logo'
export type { LogoProps, LogoVariant } from './Logo'