Skip to content

Commit 8d1e3b2

Browse files
committed
refactor(Header): tv() 의존성 제거 및 인라인 스타일 적용
1 parent cac93ee commit 8d1e3b2

2 files changed

Lines changed: 28 additions & 34 deletions

File tree

src/shared/ui/Header/Header.tsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import { Logo } from '@shared/assets/logo';
22
import { Button } from '@shared/ui/Button/Button';
3-
import { headerVariants } from '@shared/ui/Header/Header.variants';
43
import { UserMenu } from '@shared/ui/Header/UserMenu';
4+
import { cn } from '@shared/utils/cn';
55
import type { ComponentPropsWithoutRef } from 'react';
6-
import type { VariantProps } from 'tailwind-variants';
7-
8-
const { base, rightSection, innerSection, navItem } = headerVariants();
96

107
const NAV_ITEMS = [
118
{ id: 'buy', label: '구매하기' },
@@ -15,14 +12,13 @@ const NAV_ITEMS = [
1512
{ id: 'mypage', label: '마이페이지' },
1613
] as const;
1714

18-
export type HeaderProps = Omit<ComponentPropsWithoutRef<'header'>, 'children'> &
19-
VariantProps<typeof headerVariants> & {
20-
isLoggedIn?: boolean;
21-
user?: { profileImage?: string; nickname?: string };
22-
onLoginClick?: () => void;
23-
onMyPageClick?: () => void;
24-
onLogoutClick?: () => void;
25-
};
15+
export type HeaderProps = Omit<ComponentPropsWithoutRef<'header'>, 'children'> & {
16+
isLoggedIn?: boolean;
17+
user?: { profileImage?: string; nickname?: string };
18+
onLoginClick?: () => void;
19+
onMyPageClick?: () => void;
20+
onLogoutClick?: () => void;
21+
};
2622

2723
export const Header = ({
2824
className,
@@ -34,12 +30,18 @@ export const Header = ({
3430
...props
3531
}: HeaderProps) => {
3632
return (
37-
<header {...props} className={base({ className })}>
33+
<header
34+
{...props}
35+
className={cn(
36+
'mx-auto flex w-full max-w-[1440px] items-center justify-between bg-white px-[120px] py-(--margin-l)',
37+
className
38+
)}
39+
>
3840
<Logo />
39-
<div className={rightSection()}>
40-
<nav className={innerSection()}>
41+
<div className="flex items-center gap-[93px]">
42+
<nav className="flex items-center gap-[56px]">
4143
{NAV_ITEMS.map((item) => (
42-
<span key={item.id} className={navItem()}>
44+
<span key={item.id} className="typo-body-1 cursor-pointer text-center text-gray-900">
4345
{item.label}
4446
</span>
4547
))}

src/shared/ui/Header/UserMenu.tsx

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
import { CaretDownMdIcon } from '@shared/assets/icons';
22
import { Button } from '@shared/ui/Button/Button';
3-
import { headerVariants } from '@shared/ui/Header/Header.variants';
43
import { Profile } from '@shared/ui/Profile/Profile';
4+
import { cn } from '@shared/utils/cn';
55
import { useEffect, useRef, useState } from 'react';
66

7-
const {
8-
userMenuButton,
9-
userMenuIcon,
10-
userMenuDropdown,
11-
userMenuDropdownInner,
12-
userMenuDropdownInfo,
13-
userMenuDropdownName,
14-
userMenuDropdownLink,
15-
} = headerVariants();
16-
177
export type UserMenuProps = {
188
profileImage?: string;
199
nickname?: string;
@@ -59,29 +49,31 @@ export const UserMenu = ({
5949
<div ref={containerRef} className="relative">
6050
<button
6151
type="button"
62-
className={userMenuButton()}
52+
className="flex cursor-pointer items-center gap-[6px]"
6353
onClick={() => setIsOpen((prev) => !prev)}
6454
aria-expanded={isOpen}
6555
aria-haspopup="menu"
6656
>
6757
<Profile size="sm" image={profileImage} />
68-
<CaretDownMdIcon className={userMenuIcon({ className: isOpen ? 'rotate-180' : '' })} />
58+
<CaretDownMdIcon
59+
className={cn('text-gray-400 transition-transform duration-200', isOpen && 'rotate-180')}
60+
/>
6961
</button>
7062

7163
{isOpen && (
7264
<div
7365
role="menu"
7466
aria-label="사용자 메뉴"
75-
className={userMenuDropdown({ className: 'absolute top-full right-0 mt-2' })}
67+
className="rounded-m absolute top-full right-0 mt-2 inline-flex h-[235px] items-center gap-[10px] bg-white p-[17px_32px] shadow-[0_4px_4px_0_rgba(0,0,0,0.25)]"
7668
>
77-
<div className={userMenuDropdownInner()}>
78-
<div className={userMenuDropdownInfo()}>
79-
<span className={userMenuDropdownName()}>{nickname}</span>
69+
<div className="flex w-[163px] flex-col items-start gap-[45px]">
70+
<div className="flex flex-col items-start gap-[17px] self-stretch">
71+
<span className="typo-body-2 self-stretch text-gray-900">{nickname}</span>
8072
</div>
8173
<button
8274
type="button"
8375
role="menuitem"
84-
className={userMenuDropdownLink()}
76+
className="typo-caption-1 cursor-pointer self-stretch border-none bg-transparent p-0 text-left text-gray-500"
8577
onClick={onMyPageClick}
8678
>
8779
마이페이지

0 commit comments

Comments
 (0)