Skip to content

Commit

Permalink
fade in with framermotion
Browse files Browse the repository at this point in the history
  • Loading branch information
FlapShatner committed May 3, 2023
1 parent 468d7fb commit 60497c2
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 13 deletions.
30 changes: 17 additions & 13 deletions components/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { motion, AnimatePresence } from 'framer-motion'
import { links } from '@/lib/links'
import Link from 'next/link'
import { useRouter } from 'next/router'
Expand All @@ -12,20 +13,23 @@ const Menu = ({ show, setShow }: MenuProps) => {
const { pathname } = router

return (
<div
className={`absolute bg-black text-white top-0 left-0 h-full w-full flex justify-center items-start transition-all ${
show ? 'translate-x-0' : 'translate-x-full'
}`}>
<div className='flex flex-col gap-8 text-3xl font-semibold pt-40'>
{links.map((link) => (
<Link key={link.linkName} href={link.linkPath}>
<div className={`${pathname == link.linkPath ? 'text-red-600' : 'text-white'}`} onClick={() => setShow(!show)}>
{link.linkName}
<AnimatePresence>
{show && (
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}>
<div className='absolute bg-black text-white top-0 left-0 h-full w-full flex justify-center items-start transition-all'>
<div className='flex flex-col gap-8 text-3xl font-semibold pt-40'>
{links.map((link) => (
<Link key={link.linkName} href={link.linkPath}>
<div className={`${pathname == link.linkPath ? 'text-red-600' : 'text-white'}`} onClick={() => setShow(!show)}>
{link.linkName}
</div>
</Link>
))}
</div>
</Link>
))}
</div>
</div>
</div>
</motion.div>
)}
</AnimatePresence>
)
}

Expand Down
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"autoprefixer": "10.4.14",
"eslint": "8.39.0",
"eslint-config-next": "13.3.4",
"framer-motion": "^10.12.7",
"hamburger-react": "^2.5.0",
"next": "13.3.4",
"postcss": "8.4.23",
Expand Down

1 comment on commit 60497c2

@vercel
Copy link

@vercel vercel bot commented on 60497c2 May 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.