Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | 8x 8x 8x 8x 8x | import Link from 'next/link' import { useState } from 'react' import { GoTriangleDown } from 'react-icons/go' import { GiHamburgerMenu } from 'react-icons/gi' function Navbar({ t }) { // states for opening/closing nav dropdowns const [about, setAbout] = useState(false) const [assessment, setAssessment] = useState(false) const [engagement, setEngagement] = useState(false) const [open, setOpen] = useState(false) // ensure dropdowns are closed before opening a new one // todo: better approach needed? function handleClick(state, toggle) { ;[setAbout, setAssessment, setEngagement].forEach((fn) => fn(false)) toggle(!state) } return ( <nav> <button aria-label="toggle navigation menu" onClick={() => setOpen((prev) => !prev)} className="md:hidden hover:text-periwinkle text-2xl ml-1 p-1" > <GiHamburgerMenu /> </button> <div className={`${ !open ? 'hidden md:flex' : '' } flex flex-col gap-2 items-start md:flex-row md:justify-around md:items-center md:h-12 bg-periwinkle text-white px-2`} > <Link href="/home"> <a className="hover:underline">{t.home}</a> </Link> <div tabIndex={0} className="relative" onClick={() => handleClick(about, setAbout)} onKeyDown={(e) => e.key === 'Enter' ? handleClick(about, setAbout) : null } > <div className="flex md:justify-center items-center gap-2 hover:underline"> {t.aboutUs} <GoTriangleDown className="text-xs" /> </div> <div className={`${ about ? 'flex flex-col items-start' : 'hidden' } bg-periwinkle md:absolute top-9 left-0'`} > <Link href="/about/coaches"> <a className="w-full p-1 text-left hover:text-periwinkle hover:bg-white duration-200"> {t.ourCoaches} </a> </Link> <Link href=""> <a className="p-1 text-left hover:text-periwinkle hover:bg-white duration-200"> {t.serviceCatalogue} </a> </Link> </div> </div> <div tabIndex={0} className="relative" onClick={() => handleClick(assessment, setAssessment)} onKeyDown={(e) => e.key === 'Enter' ? handleClick(assessment, setAssessment) : null } > <div className="flex md:justify-center items-center gap-2 hover:underline"> {t.dojoAssessment} <GoTriangleDown className="text-xs" /> </div> <div className={`${ assessment ? 'flex flex-col items-start' : 'hidden' } bg-periwinkle w-full md:absolute top-9 left-0'`} > <Link href="/belt-assessment/belt-system"> <a className="w-full p-1 text-left hover:text-periwinkle hover:bg-white duration-200"> {t.beltSystem} </a> </Link> </div> </div> <div tabIndex={0} className="relative" onClick={() => handleClick(engagement, setEngagement)} onKeyDown={(e) => e.key === 'Enter' ? handleClick(engagement, setEngagement) : null } > <div className="flex md:justify-center items-center gap-2 hover:underline"> {t.dojoEngagement} <GoTriangleDown className="text-xs" /> </div> <div className={`${ engagement ? 'flex flex-col items-start' : 'hidden' } bg-periwinkle w-full md:absolute top-9 left-0'`} > <Link href=""> <a className="w-full p-1 text-left hover:text-periwinkle hover:bg-white duration-200"> {t.startTeam} </a> </Link> </div> </div> <Link href=""> <a className="hover:underline">{t.events}</a> </Link> <Link href=""> <a className="hover:underline">{t.tools}</a> </Link> <Link href=""> <a className="hover:underline">{t.faq}</a> </Link> <Link href=""> <a className="hover:underline">{t.contactUs}</a> </Link> </div> </nav> ) } export default Navbar |