|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import Link from 'next/link'; |
| 4 | +import { useState } from 'react'; |
| 5 | + |
| 6 | +import { IoLogoGithub } from 'react-icons/io'; |
| 7 | +import { BsPeopleFill } from 'react-icons/bs'; |
| 8 | +import { HiMenu, HiX } from 'react-icons/hi'; |
| 9 | + |
| 10 | +import { Button } from './button'; |
| 11 | +import { signInAction, signOutAction } from '../../actions'; |
| 12 | + |
| 13 | +interface MobileMenuProps { |
| 14 | + session: any; |
| 15 | +} |
| 16 | + |
| 17 | +export function MobileMenu({ session }: MobileMenuProps) { |
| 18 | + const [isOpen, setIsOpen] = useState(false); |
| 19 | + |
| 20 | + const toggleMenu = () => setIsOpen(!isOpen); |
| 21 | + |
| 22 | + return ( |
| 23 | + <div className="md:hidden"> |
| 24 | + {/* Hamburger Button */} |
| 25 | + <button |
| 26 | + onClick={toggleMenu} |
| 27 | + className="text-white hover:text-hacktoberfest-light transition-colors p-2 rounded-lg" |
| 28 | + aria-label="Toggle menu" |
| 29 | + > |
| 30 | + {isOpen ? <HiX size="1.5rem" /> : <HiMenu size="1.5rem" />} |
| 31 | + </button> |
| 32 | + |
| 33 | + {/* Mobile Menu Overlay */} |
| 34 | + {isOpen && ( |
| 35 | + <div className="absolute top-full left-0 right-0 mt-2 bg-hacktoberfest-light-blue border border-hacktoberfest-light-blue rounded-lg py-4 px-4 sm:px-6 container mx-auto backdrop-blur-md shadow-lg"> |
| 36 | + <div className="flex flex-col gap-4"> |
| 37 | + <form action={session ? signOutAction : signInAction}> |
| 38 | + <Button className="w-full text-center text-xs sm:text-sm"> |
| 39 | + {session && session.user ? 'Sign Out' : 'Sign In'} |
| 40 | + </Button> |
| 41 | + </form> |
| 42 | + |
| 43 | + <Link |
| 44 | + href="/contributors" |
| 45 | + className="flex items-center gap-3 text-white hover:text-hacktoberfest-light transition-colors p-3 rounded-lg" |
| 46 | + onClick={() => setIsOpen(false)} |
| 47 | + > |
| 48 | + <BsPeopleFill size="1.2rem" /> |
| 49 | + <span className="text-sm font-medium">Contributors</span> |
| 50 | + </Link> |
| 51 | + |
| 52 | + <a |
| 53 | + href="https://github.com/max-programming/hacktoberfest-projects" |
| 54 | + target="_blank" |
| 55 | + rel="noreferrer" |
| 56 | + className="flex items-center gap-3 text-white hover:text-hacktoberfest-light transition-colors p-3 rounded-lg" |
| 57 | + onClick={() => setIsOpen(false)} |
| 58 | + > |
| 59 | + <IoLogoGithub size="1.2rem" /> |
| 60 | + <span className="text-sm font-medium">GitHub</span> |
| 61 | + </a> |
| 62 | + </div> |
| 63 | + </div> |
| 64 | + )} |
| 65 | + </div> |
| 66 | + ); |
| 67 | +} |
0 commit comments