diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 1f35400..5976bc7 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,3 +1,4 @@ +import { ControlBar, Header } from '@/shared/components'; import { Icon } from '@/shared/icons'; export default function Home() { @@ -5,14 +6,14 @@ export default function Home() { <>
+
{}} className='' title={'글다'} /> + {}} userName={''} /> + {}} />

초기 세팅 완료

- - - - +

Next.js(Page Router) + TS + Tailwind + Axios

diff --git a/src/shared/components/header/ControlBar.tsx b/src/shared/components/header/ControlBar.tsx new file mode 100644 index 0000000..df6f630 --- /dev/null +++ b/src/shared/components/header/ControlBar.tsx @@ -0,0 +1,71 @@ +import { Icon } from '@/shared/icons'; +import { cn } from '@/shared/lib'; +import { cva } from 'class-variance-authority'; + +interface ControlBarProps { + isLoggedIn: boolean; + onLogin: () => void; + userName: string; + className?: string; +} + +const rightStyle = cva('flex items-center gap-[0.6rem] transition w-[7.8rem]', { + variants: { + state: { + loggedIn: 'text-mint-600', + guest: 'text-gray-400 hover:text-gray-600', + }, + }, + defaultVariants: { state: 'guest' }, +}); + +const ControlBar = ({ + onLogin, + isLoggedIn, + userName = '글다', + className, +}: ControlBarProps) => { + const rightState = isLoggedIn ? 'loggedIn' : ('guest' as const); + const iconColor = isLoggedIn ? 'mint-600' : ('gray-400' as const); + + return ( +
+
+
+ +

+ 글다 +

+ {isLoggedIn ? ( +
+ + + {userName}님 + +
+ ) : ( + + )} +
+
+ ); +}; + +export default ControlBar; diff --git a/src/shared/components/header/Header.tsx b/src/shared/components/header/Header.tsx new file mode 100644 index 0000000..a75306e --- /dev/null +++ b/src/shared/components/header/Header.tsx @@ -0,0 +1,55 @@ +import { Icon } from '@/shared/icons'; +import { cn } from '@/shared/lib'; +import { cva, type VariantProps } from 'class-variance-authority'; + +interface HeaderProps { + title: string; + onClick: () => void; + className?: string; + color?: VariantProps['color']; +} + +const headerStyle = cva( + 'w-full h-[11.8rem] px-[1.6rem] pb-[1.8rem] pt-[7.6rem] fixed top-0 left-0 right-0 z-[100]', + { + variants: { + color: { + mint300: 'bg-mint-300', + mint50: 'bg-mint-50', + }, + }, + defaultVariants: { + color: 'mint300', + }, + }, +); + +const Header = ({ title, onClick, color, className }: HeaderProps) => { + return ( +
+
+ + +

+ {title} +

+ +
+
+
+ ); +}; + +export default Header; diff --git a/src/shared/components/index.ts b/src/shared/components/index.ts new file mode 100644 index 0000000..bfac3a9 --- /dev/null +++ b/src/shared/components/index.ts @@ -0,0 +1,2 @@ +export { default as Header } from './header/Header'; +export { default as ControlBar } from './header/ControlBar';