Skip to content

Commit 8569870

Browse files
committed
docs: Add typedoc comments to cn utility function
1 parent bd8b870 commit 8569870

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

client/src/hooks/useDebounce.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { useEffect, useState } from 'react';
3636
* }
3737
* ```
3838
*
39-
* @see {@link https://web.dev/articles/debounce|디바운스에 대해 자세히 알아보기}
39+
* @see {@link https://web.dev/articles/debounce 디바운스에 대해 자세히 알아보기}
4040
* @category Hooks
4141
*/
4242
export function useDebounce<T>(value: T, delay: number = 3000): T {

client/src/utils/cn.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,55 @@
11
import { clsx, type ClassValue } from 'clsx';
22
import { twMerge } from 'tailwind-merge';
33

4+
/**
5+
* Tailwind CSS 클래스들을 병합하는 유틸리티 함수입니다.
6+
*
7+
* - clsx를 사용하여 조건부 클래스를 처리합니다.
8+
* - tailwind-merge를 사용하여 Tailwind 클래스 충돌을 해결합니다.
9+
*
10+
* @param inputs - 병합할 클래스들의 배열. ClassValue 타입은 문자열, 객체, 배열 등을 포함할 수 있습니다.
11+
* @returns 병합된 클래스 문자열
12+
*
13+
* @example
14+
* ```tsx
15+
* // 버튼 컴포넌트에서의 사용 예시
16+
* const buttonVariants = cva(
17+
* 'inline-flex items-center justify-center',
18+
* {
19+
* variants: {
20+
* variant: {
21+
* primary: 'bg-violet-500 hover:bg-violet-600',
22+
* // ...
23+
* },
24+
* size: {
25+
* sm: 'h-11 text-2xl',
26+
* // ...
27+
* }
28+
* },
29+
* defaultVariants: {
30+
* variant: 'primary',
31+
* size: 'sm'
32+
* }
33+
* }
34+
* );
35+
*
36+
* const Button = ({ className, variant, size, ...props }) => {
37+
* return (
38+
* <button
39+
* className={cn(
40+
* buttonVariants({ variant, size, className }),
41+
* )}
42+
* {...props}
43+
* />
44+
* );
45+
* };
46+
* ```
47+
*
48+
* @see {@link https://github.com/lukeed/clsx clsx}
49+
* @see {@link https://github.com/dcastil/tailwind-merge tailwind-merge}
50+
* @see {@link https://github.com/shadcn/ui shadcn/ui}
51+
* @category Utils
52+
*/
453
export function cn(...inputs: ClassValue[]) {
554
return twMerge(clsx(inputs));
655
}

0 commit comments

Comments
 (0)