/** * className 병합 유틸 — tailwind-merge로 충돌 자동 해결. * * cva()의 base class와 컴포넌트 className prop을 합칠 때 사용. * 같은 그룹(text color, padding, bg 등) 클래스가 여러 개면 마지막 것만 적용. * * 사용 예: * cn(badgeVariants({ intent }), className) * → className에서 들어오는 text-red-400이 base의 text-on-bright을 override (마지막 우선) * * 시맨틱 토큰 (text-on-vivid, text-on-bright, text-heading 등)을 tailwind-merge가 * text-color 그룹으로 인식하도록 extendTailwindMerge로 확장. */ import { extendTailwindMerge } from 'tailwind-merge'; import { clsx, type ClassValue } from 'clsx'; const twMerge = extendTailwindMerge({ extend: { classGroups: { // 프로젝트 시맨틱 텍스트 색상 (theme.css 정의) — text-* 그룹 충돌 해결 'text-color': [ 'text-heading', 'text-label', 'text-hint', 'text-on-vivid', 'text-on-bright', ], }, }, }); export function cn(...inputs: ClassValue[]): string { return twMerge(clsx(inputs)); }