|
1 | | -import Link from "next/link"; |
| 1 | +import { useState } from "react"; |
2 | 2 |
|
3 | | -function Header() { |
| 3 | +function NavLink({ to, children }: any) { |
4 | 4 | return ( |
5 | | - <header className="flex justify-between bg-gray-100 p-5"> |
6 | | - <div className="flex items-center space-x-5"> |
7 | | - <Link href="/"> |
8 | | - <img |
9 | | - className="w-44 object-contain cursor-pointer" |
10 | | - src="/chaintool--header-logo.svg" |
11 | | - alt="" |
12 | | - /> |
13 | | - </Link> |
14 | | - </div> |
| 5 | + <a href={to} className={`mx-4`}> |
| 6 | + {children} |
| 7 | + </a> |
| 8 | + ); |
| 9 | +} |
15 | 10 |
|
16 | | - <div className="hidden md:inline-flex items-center space-x-5"> |
| 11 | +function MobileNav({ open, setOpen }: any) { |
| 12 | + return ( |
| 13 | + <div |
| 14 | + className={`absolute top-0 left-0 h-screen w-screen bg-white transform ${ |
| 15 | + open ? "-translate-x-0" : "-translate-x-full" |
| 16 | + } transition-transform duration-300 ease-in-out filter drop-shadow-md `} |
| 17 | + > |
| 18 | + <div className="flex items-center justify-center filter drop-shadow-md bg-white h-20"> |
| 19 | + {" "} |
| 20 | + {/*logo container*/} |
| 21 | + <a className="text-xl font-semibold" href="/"> |
| 22 | + MENU |
| 23 | + </a> |
| 24 | + </div> |
| 25 | + <div className="flex flex-col ml-4"> |
17 | 26 | <a |
18 | | - href="networks" |
19 | | - className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200" |
| 27 | + className="text-xl font-medium my-4" |
| 28 | + href="/networks" |
| 29 | + onClick={() => |
| 30 | + setTimeout(() => { |
| 31 | + setOpen(!open); |
| 32 | + }, 100) |
| 33 | + } |
20 | 34 | > |
21 | 35 | Networks |
22 | 36 | </a> |
23 | | - |
24 | 37 | <a |
25 | | - href="services" |
26 | | - className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200" |
| 38 | + className="text-xl font-normal my-4" |
| 39 | + href="/services" |
| 40 | + onClick={() => |
| 41 | + setTimeout(() => { |
| 42 | + setOpen(!open); |
| 43 | + }, 100) |
| 44 | + } |
27 | 45 | > |
28 | 46 | Services |
29 | 47 | </a> |
30 | | - |
31 | 48 | <a |
32 | | - href="education" |
33 | | - className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200" |
| 49 | + className="text-xl font-normal my-4" |
| 50 | + href="/education" |
| 51 | + onClick={() => |
| 52 | + setTimeout(() => { |
| 53 | + setOpen(!open); |
| 54 | + }, 100) |
| 55 | + } |
34 | 56 | > |
35 | 57 | Education |
36 | 58 | </a> |
37 | | - |
38 | 59 | <a |
| 60 | + className="text-xl font-normal my-4" |
| 61 | + href="/tools" |
| 62 | + onClick={() => |
| 63 | + setTimeout(() => { |
| 64 | + setOpen(!open); |
| 65 | + }, 100) |
| 66 | + } |
| 67 | + > |
| 68 | + Tools |
| 69 | + </a> |
| 70 | + <a |
| 71 | + className="text-xl font-normal my-4" |
39 | 72 | href="contact" |
40 | | - className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200" |
| 73 | + onClick={() => |
| 74 | + setTimeout(() => { |
| 75 | + setOpen(!open); |
| 76 | + }, 100) |
| 77 | + } |
41 | 78 | > |
42 | | - Contact Us |
| 79 | + Contact |
43 | 80 | </a> |
44 | 81 | </div> |
| 82 | + </div> |
| 83 | + ); |
| 84 | +} |
45 | 85 |
|
46 | | - <div className="flex items-center space-x-5 text-slate-700"> |
47 | | - |
| 86 | +export default function Navbar() { |
| 87 | + const [open, setOpen] = useState(false); |
| 88 | + return ( |
| 89 | + <nav className="flex justify-between filter drop-shadow-md bg-white px-4 py-4 h-25"> |
| 90 | + <MobileNav open={open} setOpen={setOpen} /> |
| 91 | + <div className="w-44 object-contain cursor-pointer"> |
| 92 | + <a href="/"> |
| 93 | + <img src="/chaintool--header-logo.svg" alt="" /> |
| 94 | + </a> |
48 | 95 | </div> |
49 | | - </header> |
| 96 | + <div className="w-9/12 flex justify-end items-center"> |
| 97 | + <div |
| 98 | + className="z-50 flex relative w-8 h-8 flex-col justify-between items-center md:hidden" |
| 99 | + onClick={() => { |
| 100 | + setOpen(!open); |
| 101 | + }} |
| 102 | + > |
| 103 | + {/* hamburger button */} |
| 104 | + <span |
| 105 | + className={`h-1 w-full bg-black rounded-lg transform transition duration-300 ease-in-out ${ |
| 106 | + open ? "rotate-45 translate-y-3.5" : "" |
| 107 | + }`} |
| 108 | + /> |
| 109 | + <span |
| 110 | + className={`h-1 w-full bg-black rounded-lg transition-all duration-300 ease-in-out ${ |
| 111 | + open ? "w-0" : "w-full" |
| 112 | + }`} |
| 113 | + /> |
| 114 | + <span |
| 115 | + className={`h-1 w-full bg-black rounded-lg transform transition duration-300 ease-in-out ${ |
| 116 | + open ? "-rotate-45 -translate-y-3.5" : "" |
| 117 | + }`} |
| 118 | + /> |
| 119 | + </div> |
| 120 | + |
| 121 | + <div className="hidden md:flex space-x-2"> |
| 122 | + <button className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200"> |
| 123 | + <NavLink to="/networks">Networks</NavLink> |
| 124 | + </button> |
| 125 | + |
| 126 | + <button className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200"> |
| 127 | + <NavLink to="/services">Services</NavLink> |
| 128 | + </button> |
| 129 | + |
| 130 | + <button className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200"> |
| 131 | + <NavLink to="/education">Education</NavLink> |
| 132 | + </button> |
| 133 | + |
| 134 | + <button className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200"> |
| 135 | + <NavLink to="/tools">Tools</NavLink> |
| 136 | + </button> |
| 137 | + <button className="border px-4 py-1 rounded-full hover:bg-gray-300 object-contain cursor-pointer transition-all duration-200"> |
| 138 | + <NavLink to="/contact">Contact Us</NavLink> |
| 139 | + </button> |
| 140 | + </div> |
| 141 | + </div> |
| 142 | + </nav> |
50 | 143 | ); |
51 | 144 | } |
52 | | - |
53 | | -export default Header; |
|
0 commit comments