|
| 1 | +'use client' |
| 2 | + |
| 3 | +import Image from 'next/image'; |
| 4 | +import Link from 'next/link'; |
| 5 | +import React, { useState } from 'react'; |
| 6 | +import { Button } from './ui/button'; |
| 7 | + |
| 8 | +const Header = () => { |
| 9 | + const [state, setState] = useState(false); |
| 10 | + |
| 11 | + // Replace javascript:void(0) path with your path |
| 12 | + const navigation = [ |
| 13 | + { title: 'Race', path: '/' }, |
| 14 | + { title: 'Leaderboard', path: '/' }, |
| 15 | + { title: 'About', path: '/' }, |
| 16 | + ]; |
| 17 | + |
| 18 | + return ( |
| 19 | + <div> |
| 20 | + <nav className="bg-white w-full border-b md:border-0 md:static"> |
| 21 | + <div className="items-center px-4 max-w-screen-xl mx-auto md:flex md:px-8"> |
| 22 | + <div className="flex items-center justify-between py-3 md:py-5 md:block"> |
| 23 | + <Link href="javascript:void(0)"> |
| 24 | + <Image |
| 25 | + src="https://res.cloudinary.com/dfrtxrh9c/image/upload/v1688858445/Web-Dev-Cody/Logo_lvkfmp.png" |
| 26 | + width={96} |
| 27 | + height={96} |
| 28 | + alt="Code Racer Logo" |
| 29 | + /> |
| 30 | + </Link> |
| 31 | + <div className="md:hidden"> |
| 32 | + <button |
| 33 | + className="text-gray-700 outline-none p-2 rounded-md focus:border-gray-400 focus:border" |
| 34 | + onClick={() => setState(!state)} |
| 35 | + > |
| 36 | + {state ? ( |
| 37 | + <svg |
| 38 | + xmlns="http://www.w3.org/2000/svg" |
| 39 | + className="h-6 w-6" |
| 40 | + viewBox="0 0 20 20" |
| 41 | + fill="currentColor" |
| 42 | + > |
| 43 | + <path |
| 44 | + fillRule="evenodd" |
| 45 | + d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" |
| 46 | + clipRule="evenodd" |
| 47 | + /> |
| 48 | + </svg> |
| 49 | + ) : ( |
| 50 | + <svg |
| 51 | + xmlns="http://www.w3.org/2000/svg" |
| 52 | + className="h-6 w-6" |
| 53 | + fill="none" |
| 54 | + viewBox="0 0 24 24" |
| 55 | + stroke="currentColor" |
| 56 | + > |
| 57 | + <path |
| 58 | + strokeLinecap="round" |
| 59 | + strokeLinejoin="round" |
| 60 | + strokeWidth={2} |
| 61 | + d="M4 8h16M4 16h16" |
| 62 | + /> |
| 63 | + </svg> |
| 64 | + )} |
| 65 | + </button> |
| 66 | + </div> |
| 67 | + </div> |
| 68 | + <div |
| 69 | + className={`flex-1 justify-self-center pb-3 mt-8 md:block md:pb-0 md:mt-0 ${ |
| 70 | + state ? 'block' : 'hidden' |
| 71 | + }`} |
| 72 | + > |
| 73 | + <ul className="justify-center items-center space-y-8 md:flex md:space-x-6 md:space-y-0"> |
| 74 | + {navigation.map((item, idx) => { |
| 75 | + return ( |
| 76 | + <li key={idx} className="text-gray-600 p-2 rounded-lg hover:bg-gray-50"> |
| 77 | + <Link href={item.path}>{item.title}</Link> |
| 78 | + </li> |
| 79 | + ); |
| 80 | + })} |
| 81 | + </ul> |
| 82 | + </div> |
| 83 | + <div className="hidden md:inline-block"> |
| 84 | + <Button>Login</Button> |
| 85 | + </div> |
| 86 | + </div> |
| 87 | + </nav> |
| 88 | + </div> |
| 89 | + ); |
| 90 | +}; |
| 91 | + |
| 92 | +export default Header; |
0 commit comments