Skip to content

Commit a09b925

Browse files
committed
feat: 탭메뉴 컴포넌트 분리
1 parent 040953e commit a09b925

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { cn } from '@/utils';
2+
import { twMerge } from 'tailwind-merge';
3+
import { motion } from 'framer-motion';
4+
import { useState } from 'react';
5+
6+
interface TabMenuProps {
7+
activeTab: 'profile' | 'password';
8+
onChange: (tab: 'profile' | 'password') => void;
9+
}
10+
11+
const TabMenu = ({ activeTab, onChange }: TabMenuProps) => {
12+
const [hoverTab, setHoverTab] = useState<'profile' | 'password' | null>(null);
13+
const currentTab = hoverTab || activeTab;
14+
15+
return (
16+
<div className="relative flex">
17+
<button
18+
className={cn('p-3 flex-1 cursor-pointer', activeTab === 'profile' && 'font-bold')}
19+
onClick={() => onChange('profile')}
20+
onMouseEnter={() => setHoverTab('profile')}
21+
onMouseLeave={() => setHoverTab(null)}
22+
>
23+
프로필 수정
24+
</button>
25+
<button
26+
className={cn('p-3 flex-1 cursor-pointer', activeTab === 'password' && 'font-bold')}
27+
onClick={() => onChange('password')}
28+
onMouseEnter={() => setHoverTab('password')}
29+
onMouseLeave={() => setHoverTab(null)}
30+
>
31+
비밀번호 변경
32+
</button>
33+
<motion.div
34+
layout
35+
className={twMerge(
36+
'absolute bottom-0 h-[2px] w-1/2 bg-primary-active transition-all duration-300',
37+
currentTab === 'profile' ? 'left-0' : 'left-1/2',
38+
)}
39+
/>
40+
</div>
41+
);
42+
};
43+
44+
export default TabMenu;

0 commit comments

Comments
 (0)