diff --git a/src/components/MobileMenu.tsx b/src/components/MobileMenu.tsx new file mode 100644 index 0000000..147a511 --- /dev/null +++ b/src/components/MobileMenu.tsx @@ -0,0 +1,97 @@ +import { AnimatePresence } from "framer-motion"; +import { Menu, MessageSquare, X } from "lucide-react"; +import { useState, useEffect, useRef } from "react"; +import { motion } from "framer-motion"; +import { createPortal } from "react-dom"; + +export default function MobileMenu() { + const [open, setOpen] = useState(false); + const [mounted, setMounted] = useState(false); + const buttonRef = useRef(null); + const [buttonPosition, setButtonPosition] = useState({ top: 0, right: 0 }); + + useEffect(() => { + setMounted(true); + }, []); + + useEffect(() => { + if (open && buttonRef.current) { + const rect = buttonRef.current.getBoundingClientRect(); + setButtonPosition({ + top: rect.bottom + 8, + right: window.innerWidth - rect.right + }); + } + }, [open]); + + const menuContent = ( + + {open && ( + <> + {/* Backdrop */} + setOpen(false)} + /> + + {/* Menu */} + + {["Blog", "Projects", "About"].map((item) => ( + setOpen(false)} + > + {item} + + ))} + + setOpen(false)} + > + + Join Discord + + + + )} + + ); + + return ( + <> +
+ +
+ + {mounted && createPortal(menuContent, document.body)} + + ); +} \ No newline at end of file diff --git a/src/components/NavMenu.tsx b/src/components/NavMenu.tsx new file mode 100644 index 0000000..333b0a4 --- /dev/null +++ b/src/components/NavMenu.tsx @@ -0,0 +1,59 @@ +import { motion } from "framer-motion"; +import MobileMenu from "./MobileMenu"; +import { MessageSquare } from "lucide-react"; + +export default function NavMenu() { + return ( + + {["Blog", "Projects", "About"].map((item) => ( + + {item} + + ))} + + + + Join Discord + + + + + ); +} diff --git a/src/components/Web.tsx b/src/components/Web.tsx index 97a54a4..96d5377 100644 --- a/src/components/Web.tsx +++ b/src/components/Web.tsx @@ -1,5 +1,7 @@ import { motion } from "framer-motion"; import { Github, MessageSquare } from "lucide-react"; +import MobileMenu from "./MobileMenu"; +import NavMenu from "./NavMenu"; export default function WebStuff({ children, @@ -71,56 +73,7 @@ export default function WebStuff({ Logo - {/* Menu */} - - {["Blog", "Projects", "About"].map((item) => ( - - {item} - - ))} - - - - Join Discord - - + {children}