-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
7484e93
commit f261e1b
Showing
4 changed files
with
146 additions
and
56 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,53 @@ | ||
import { IconArrowLeft, IconHamburger } from '@public/icons'; | ||
import Link from 'next/link'; | ||
import { PropsWithChildren } from 'react'; | ||
|
||
interface Props extends PropsWithChildren { | ||
titleAlign?: 'center' | 'left'; | ||
title?: string; | ||
isOwner?: boolean; | ||
import { PropsWithChildren, ReactNode } from 'react'; | ||
|
||
interface TopNavigationProps { | ||
children?: ReactNode; | ||
} | ||
|
||
const TopNavigation = ({ | ||
children, | ||
titleAlign = 'center', | ||
title = '', | ||
isOwner = false, | ||
}: Props) => { | ||
type ItemProps = TopNavigationProps; | ||
|
||
const TopNavigation = ({ children }: TopNavigationProps) => { | ||
return ( | ||
<div className="relative flex h-[5.4rem] w-full gap-[1.5rem] bg-opacity-0 px-[2rem] py-[1.7rem]"> | ||
<Link href="."> | ||
<IconArrowLeft className="hover:cursor-pointer" /> | ||
</Link> | ||
<div | ||
className={`flex w-full pr-[3.5rem] text-md font-normal leading-[1.9rem] ${TITLE_ALIGN_CLASSES[titleAlign]}`} | ||
> | ||
{title} | ||
</div> | ||
<div className="absolute right-[2rem] flex gap-[1rem]"> | ||
{children} | ||
{isOwner && <IconHamburger className="hover:cursor-pointer" />} | ||
</div> | ||
<div className="relative flex h-[2.4rem] w-full items-center justify-center bg-opacity-0 px-[2rem] py-[1.7rem] text-md"> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default TopNavigation; | ||
const LeftItem = ({ children }: ItemProps) => { | ||
return ( | ||
<div className="absolute left-[2rem] [&_svg]:h-[2rem] [&_svg]:w-[2rem] [&_svg]:cursor-pointer"> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
type CenterItemProps = PropsWithChildren<{ textAlign?: 'left' | 'center' }>; | ||
|
||
const textAligns = { | ||
left: 'text-left', | ||
center: 'text-center', | ||
} as const; | ||
|
||
const TITLE_ALIGN_CLASSES = { | ||
center: 'justify-center', | ||
left: 'justify-start', | ||
const CenterItem = ({ children, textAlign = 'center' }: CenterItemProps) => { | ||
const alignClassName = textAligns[textAlign]; | ||
return ( | ||
<div className={`w-full px-[3.5rem] ${alignClassName}`}>{children}</div> | ||
); | ||
}; | ||
|
||
const RightItem = ({ children }: ItemProps) => { | ||
return ( | ||
<div className="absolute right-[2rem] flex gap-[1rem] [&_svg]:h-[2rem] [&_svg]:w-[2rem] [&_svg]:cursor-pointer"> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
TopNavigation.LeftItem = LeftItem; | ||
|
||
TopNavigation.CenterItem = CenterItem; | ||
|
||
TopNavigation.RightItem = RightItem; | ||
|
||
export default TopNavigation; |