-
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.
Merge pull request #129 from mineTomek/add-side-menu-functionality
Add side menu functionality
- Loading branch information
Showing
3 changed files
with
111 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
'use client' | ||
|
||
import SideMenuItem from '@/app/types/SideMenuItem' | ||
import { faArrowUpRightFromSquare } from '@fortawesome/free-solid-svg-icons' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import { Variants, motion } from 'framer-motion' | ||
import Link from 'next/link' | ||
import { usePathname } from 'next/navigation' | ||
import { useState } from 'react' | ||
|
||
const sidebar: Variants = { | ||
open: { | ||
transform: 'translateX(0)', | ||
|
||
transition: { | ||
delayChildren: 0.2, | ||
staggerChildren: 0.1, | ||
}, | ||
}, | ||
closed: { | ||
transform: 'translateX(100%)', | ||
|
||
transition: {}, | ||
}, | ||
} | ||
|
||
const menuItem: Variants = { | ||
open: { | ||
transform: 'translateY(0) scale(1)', | ||
opacity: 1, | ||
}, | ||
closed: { | ||
transform: 'translateY(1rem) scale(.7)', | ||
opacity: 0, | ||
}, | ||
} | ||
|
||
const menuItems: SideMenuItem[] = [ | ||
{ | ||
label: 'Main Page', | ||
href: '/', | ||
subItems: [], | ||
}, | ||
{ | ||
label: 'Blog', | ||
href: '/blog', | ||
subItems: [], | ||
}, | ||
{ | ||
label: 'Project Timeline', | ||
href: '/timeline', | ||
subItems: [], | ||
}, | ||
] | ||
|
||
export default function SideMenu() { | ||
const [isOpen, setIsOpen] = useState(false) | ||
|
||
const currentPath = usePathname() | ||
|
||
return ( | ||
<motion.div | ||
className='fixed bottom-0 right-0 top-0 z-10 w-80 gap-2' | ||
initial={false} | ||
animate={isOpen ? 'open' : 'closed'} | ||
> | ||
<div | ||
className={`ml-auto flex h-16 cursor-pointer flex-col justify-center bg-zinc-100 transition-[background-color,width] ${ | ||
isOpen ? 'w-ful pl-4 dark:bg-zinc-900' : 'w-16 pl-16 dark:bg-zinc-800' | ||
}`} | ||
onClick={_e => setIsOpen(prev => !prev)} | ||
> | ||
<motion.p variants={{ open: { opacity: 1 }, closed: { opacity: 0.3 } }}> | ||
Menu | ||
</motion.p> | ||
</div> | ||
<motion.div | ||
className='z-20 flex flex-col gap-2 rounded-bl-lg bg-zinc-100 p-4 dark:bg-zinc-700' | ||
variants={sidebar} | ||
> | ||
{menuItems.map((item, i) => ( | ||
<motion.div | ||
key={`menu_item_${i}`} | ||
variants={menuItem} | ||
> | ||
<Link | ||
href={item.href} | ||
onClick={_e => setIsOpen(false)} | ||
className={`flex justify-between ${ | ||
currentPath === item.href && 'bold text-primary-300' | ||
}`} | ||
> | ||
{item.label} | ||
{currentPath !== item.href && ( | ||
<FontAwesomeIcon icon={faArrowUpRightFromSquare} /> | ||
)} | ||
</Link> | ||
</motion.div> | ||
))} | ||
</motion.div> | ||
</motion.div> | ||
) | ||
} |
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,5 @@ | ||
export default interface SideMenuItem { | ||
label: string | ||
href: string | ||
subItems: SideMenuItem[] | ||
} |
02d6240
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
mine-tomek-website – ./
mine-tomek-website-minetomek.vercel.app
mine-tomek-website.vercel.app
exp.tomeklukomski.pl
mine-tomek-website-git-main-minetomek.vercel.app