diff --git a/src/app/components/Navbar.tsx b/src/app/components/Navbar.tsx index 707c19d..091cbe2 100644 --- a/src/app/components/Navbar.tsx +++ b/src/app/components/Navbar.tsx @@ -3,6 +3,7 @@ import { getTitleFont } from '../fonts' import Logo from './Logo' import { faBars } from '@fortawesome/free-solid-svg-icons' import Link from 'next/link' +import SideMenu from './navbar/SideMenu' export default function Navbar() { return ( @@ -16,8 +17,9 @@ export default function Navbar() { + ) } diff --git a/src/app/components/navbar/SideMenu.tsx b/src/app/components/navbar/SideMenu.tsx new file mode 100644 index 0000000..4bb862a --- /dev/null +++ b/src/app/components/navbar/SideMenu.tsx @@ -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 ( + +
setIsOpen(prev => !prev)} + > + + Menu + +
+ + {menuItems.map((item, i) => ( + + setIsOpen(false)} + className={`flex justify-between ${ + currentPath === item.href && 'bold text-primary-300' + }`} + > + {item.label} + {currentPath !== item.href && ( + + )} + + + ))} + +
+ ) +} diff --git a/src/app/types/SideMenuItem.ts b/src/app/types/SideMenuItem.ts new file mode 100644 index 0000000..17ac9ec --- /dev/null +++ b/src/app/types/SideMenuItem.ts @@ -0,0 +1,5 @@ +export default interface SideMenuItem { + label: string + href: string + subItems: SideMenuItem[] +}