Skip to content

Commit 6c08eac

Browse files
committed
feat: 공통화 button 컴포넌트 haptic 이벤트 적용
1 parent 2459a32 commit 6c08eac

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/components/ui/button.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { Slot } from '@radix-ui/react-slot';
44
import { type VariantProps, cva } from 'class-variance-authority';
55
import type * as React from 'react';
6+
import { HapticStyles } from '@/types/haptic';
67

78
import { cn } from '@/lib/utils';
89

@@ -35,20 +36,23 @@ const buttonVariants = cva(
3536
export interface ButtonProps
3637
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
3738
VariantProps<typeof buttonVariants> {
39+
haptic?: keyof typeof HapticStyles;
3840
asChild?: boolean;
3941
}
4042

4143
const Button = ({
4244
className,
4345
variant,
4446
size,
47+
haptic = 'impactLight', // 기본 진동 설정
4548
asChild = false,
4649
...props
4750
}: ButtonProps) => {
4851
const Comp = asChild ? Slot : 'button';
4952
return (
5053
<Comp
5154
className={cn(buttonVariants({ variant, size, className }))}
55+
data-haptic={haptic}
5256
{...props}
5357
/>
5458
);

src/types/haptic.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* 지원 가능한 스타일 목록
3+
*/
4+
export const HapticStyles = {
5+
impactLight: 'impactLight',
6+
impactMedium: 'impactMedium',
7+
impactHeavy: 'impactHeavy',
8+
selection: 'selection',
9+
notificationSuccess: 'notificationSuccess',
10+
notificationWarning: 'notificationWarning',
11+
notificationError: 'notificationError',
12+
} as const;

0 commit comments

Comments
 (0)