From 10738880734f352886bb17d5e256ca7a28a5623f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AF=BC=ED=97=8C?= Date: Wed, 17 Jun 2026 10:47:25 +0900 Subject: [PATCH] =?UTF-8?q?refactor(front):=20=EA=B3=B5=EC=9A=A9=20?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8/=EC=9C=A0=ED=8B=B8=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EC=A0=95=EB=B9=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - cn·interactive를 components에서 lib로 분리 (컴포넌트와 순수 유틸 경계 정리) - core/provider.tsx → Provider.tsx 개명 (컴포넌트 파일 PascalCase 통일) - 불필요한 주석 정리 Co-Authored-By: Claude Opus 4.8 (1M context) --- front/src/components/Button.tsx | 20 +++++++++----------- front/src/components/Input.tsx | 2 +- front/src/components/Logo.tsx | 9 +++------ front/src/components/cn.ts | 11 ----------- front/src/components/index.ts | 1 - front/src/lib/cn.ts | 6 ++++++ front/src/lib/index.ts | 4 ++++ front/src/lib/interactive.ts | 3 +++ 8 files changed, 26 insertions(+), 30 deletions(-) delete mode 100644 front/src/components/cn.ts create mode 100644 front/src/lib/cn.ts create mode 100644 front/src/lib/index.ts create mode 100644 front/src/lib/interactive.ts diff --git a/front/src/components/Button.tsx b/front/src/components/Button.tsx index 949c786..64464a7 100644 --- a/front/src/components/Button.tsx +++ b/front/src/components/Button.tsx @@ -1,5 +1,5 @@ import { type ComponentProps } from 'react' -import { cn } from '@/components/cn' +import { cn, interactive } from '@/lib' export type ButtonVariant = | 'primary' @@ -10,20 +10,18 @@ export type ButtonVariant = 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 ' + + 'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium select-none ' + + interactive + + ' 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 = { - primary: 'bg-primary text-primary-foreground hover:bg-brand-700', - secondary: 'bg-secondary text-secondary-foreground hover:bg-border', - outline: - 'border border-input bg-background hover:bg-accent hover:text-accent-foreground', + primary: 'bg-primary text-primary-foreground', + secondary: 'bg-secondary text-secondary-foreground', + outline: 'border border-input bg-background', + // 투명 배경이라 brightness 무효 → bg 하이라이트 ghost: 'hover:bg-accent hover:text-accent-foreground', - destructive: 'bg-destructive text-white hover:opacity-90', + destructive: 'bg-destructive text-white', } const sizeClass: Record = { diff --git a/front/src/components/Input.tsx b/front/src/components/Input.tsx index 6afa4c3..cf733de 100644 --- a/front/src/components/Input.tsx +++ b/front/src/components/Input.tsx @@ -1,5 +1,5 @@ import { type ComponentProps } from 'react' -import { cn } from '@/components/cn' +import { cn } from '@/lib' export function Input({ type = 'text', className, ...props }: ComponentProps<'input'>) { return ( diff --git a/front/src/components/Logo.tsx b/front/src/components/Logo.tsx index 13bcf9d..f4efe89 100644 --- a/front/src/components/Logo.tsx +++ b/front/src/components/Logo.tsx @@ -1,5 +1,5 @@ import { type ComponentProps } from 'react' -import { cn } from '@/components/cn' +import { cn } from '@/lib' import logoColor from '@/assets/imarketkorea-logo.png' import logoWhite from '@/assets/imarketkorea-logo-white.png' @@ -7,11 +7,10 @@ export type LogoVariant = 'color' | 'white' export type LogoSize = 'sm' | 'md' | 'lg' const sources: Record = { - color: logoColor, // 브랜드 블루 심볼 — 밝은 배경용 - white: logoWhite, // 화이트 심볼 — 어두운 배경용 + color: logoColor, + white: logoWhite, } -// 심볼 높이에 맞춰 텍스트도 함께 스케일한다. const sizes: Record = { sm: { img: 'h-6', text: 'text-base', gap: 'gap-1.5' }, md: { img: 'h-8', text: 'text-xl', gap: 'gap-2' }, @@ -21,9 +20,7 @@ const sizes: Record = { export interface LogoProps extends Omit, 'children'> { variant?: LogoVariant size?: LogoSize - /** 워드마크(iMarket Korea) 텍스트 노출 여부 */ withText?: boolean - /** 심볼 이미지 alt */ alt?: string } diff --git a/front/src/components/cn.ts b/front/src/components/cn.ts deleted file mode 100644 index b86f42f..0000000 --- a/front/src/components/cn.ts +++ /dev/null @@ -1,11 +0,0 @@ -// 경량 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(' ') -} diff --git a/front/src/components/index.ts b/front/src/components/index.ts index 4a698d5..78e677c 100644 --- a/front/src/components/index.ts +++ b/front/src/components/index.ts @@ -1,4 +1,3 @@ -export { cn } from '@/components/cn' export { Button } from '@/components/Button' export type { ButtonProps, ButtonVariant, ButtonSize } from '@/components/Button' export { Input } from '@/components/Input' diff --git a/front/src/lib/cn.ts b/front/src/lib/cn.ts new file mode 100644 index 0000000..438021b --- /dev/null +++ b/front/src/lib/cn.ts @@ -0,0 +1,6 @@ +// className 병합. tailwind-merge 아님 — 같은 속성 충돌 시 CSS 출력 순서가 승자. +export type ClassValue = string | number | false | null | undefined + +export function cn(...classes: ClassValue[]): string { + return classes.filter(Boolean).join(' ') +} diff --git a/front/src/lib/index.ts b/front/src/lib/index.ts new file mode 100644 index 0000000..af3e974 --- /dev/null +++ b/front/src/lib/index.ts @@ -0,0 +1,4 @@ +// 전역 순수 유틸/스타일 +export { cn } from '@/lib/cn' +export type { ClassValue } from '@/lib/cn' +export { interactive } from '@/lib/interactive' diff --git a/front/src/lib/interactive.ts b/front/src/lib/interactive.ts new file mode 100644 index 0000000..90dfd4f --- /dev/null +++ b/front/src/lib/interactive.ts @@ -0,0 +1,3 @@ +// 공통 인터랙션: hover=brightness↓, active=scale↓. transform/filter 만 전환(잔상 방지). +export const interactive = + 'transition-[transform,filter] duration-150 ease-out cursor-pointer hover:brightness-[0.97] active:scale-[0.98]'