-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
432 additions
and
85 deletions.
There are no files selected for viewing
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
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
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,11 +1,11 @@ | ||
import { createContext } from 'react' | ||
|
||
export type DrawerContextType = { | ||
export type LayoutDrawerContextType = { | ||
isCollapsed: boolean | undefined | ||
isTouched: boolean | ||
} | ||
|
||
export const LayoutDrawerContext = createContext<DrawerContextType>({ | ||
export const LayoutDrawerContext = createContext<LayoutDrawerContextType>({ | ||
isCollapsed: undefined, | ||
isTouched: false, | ||
}) |
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
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 |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { useEffect, useState } from 'react' | ||
import { Link as ChakraLink } from '@chakra-ui/react' | ||
import cx from 'classnames' | ||
|
||
export type NavBarProps = { | ||
items: NavItem[] | ||
pathnameFn: () => string | ||
navigateFn: (href: string) => void | ||
} | ||
|
||
export type NavItem = { | ||
title: string | ||
href: string | ||
isActive?: boolean | ||
} | ||
|
||
export const NavBar = ({ items, pathnameFn, navigateFn }: NavBarProps) => { | ||
return ( | ||
<div className={cx('flex', 'flex-row', 'gap-1.5')}> | ||
{items | ||
? items.map((item, index) => ( | ||
<Item | ||
key={index} | ||
title={item.title} | ||
href={item.href} | ||
pathnameFn={pathnameFn} | ||
navigateFn={navigateFn} | ||
/> | ||
)) | ||
: null} | ||
</div> | ||
) | ||
} | ||
|
||
type ItemProps = { | ||
title: string | ||
href: string | ||
pathnameFn: () => string | ||
navigateFn: (href: string) => void | ||
} | ||
|
||
const Item = ({ title, href, pathnameFn, navigateFn }: ItemProps) => { | ||
const pathname = pathnameFn() | ||
const [isActive, setIsActive] = useState(false) | ||
|
||
useEffect(() => { | ||
if ( | ||
(href === '/' && pathname === '/') || | ||
(href !== '/' && pathname.startsWith(href)) | ||
) { | ||
setIsActive(true) | ||
} else { | ||
setIsActive(false) | ||
} | ||
}, [pathname, href]) | ||
|
||
return ( | ||
<ChakraLink | ||
variant="no-underline" | ||
className={cx( | ||
'flex', | ||
'items-center', | ||
'opacity-100', | ||
'hover:opacity-80', | ||
'h-[40px]', | ||
'rounded-xl', | ||
'pt-0', | ||
'pr-[20px]', | ||
'pb-0', | ||
'pl-[20px]', | ||
'font-semibold', | ||
{ | ||
'text-white': isActive, | ||
'dark:text-gray-600': isActive, | ||
'bg-black': isActive, | ||
'dark:bg-white': isActive, | ||
'bg-transparent': !isActive, | ||
}, | ||
)} | ||
onClick={() => navigateFn(href)} | ||
> | ||
{title} | ||
</ChakraLink> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.