From 4f2c98acb852f249cf9989a6d78de54a929767ba Mon Sep 17 00:00:00 2001 From: gandholi-kumar Date: Sat, 7 Oct 2023 21:49:49 +0530 Subject: [PATCH] Added Hamburger menu for smaller devices --- src/components/Header/Header.jsx | 128 ++++++++++++++++++------------- src/index.css | 5 +- 2 files changed, 77 insertions(+), 56 deletions(-) diff --git a/src/components/Header/Header.jsx b/src/components/Header/Header.jsx index 0156090..05ec865 100644 --- a/src/components/Header/Header.jsx +++ b/src/components/Header/Header.jsx @@ -1,82 +1,104 @@ -import { MdPeople, MdInsertDriveFile } from "react-icons/md"; +import { + MdPeople, + MdInsertDriveFile, + MdClose, + MdMenu, + MdHome, +} from "react-icons/md"; import { AiFillGithub } from "react-icons/ai"; import { Link } from "react-router-dom"; import { HiMoon, HiSun } from "react-icons/hi"; -import { ThemeContext } from '../../context/ThemeContext' -import { useContext } from "react"; +import { ThemeContext } from "../../context/ThemeContext"; +import { useContext, useState } from "react"; function Header({ notice }) { - const { toggleTheme } = useContext(ThemeContext); - + const { theme, toggleTheme } = useContext(ThemeContext); + const [open, setOpen] = useState(false); const navLink = [ { - name: 'Home', - link: '/', - icon: '' + name: "Home", + link: "/", + icon: , }, { - name: 'Doc', - link: '/doc', - icon: + name: "Doc", + link: "/doc", + icon: , }, { - name: 'Contributors', - link: '/Contributors', - icon: + name: "Contributors", + link: "/Contributors", + icon: , }, { - name: '', - link: 'https://github.com/devvsakib/github-error-solve', - icon: - } - ] + name: "Github", + link: "https://github.com/devvsakib/github-error-solve", + icon: , + isExternalURL: true, + }, + ]; return (
-
- {/*

- GITHUB ERROR SOLVE -

*/} - - GES +
+ {/* Logo */} + + GES -
- { - navLink.map((link, index) => { - return ( - link.name == "" ? ({link.icon} - ) : link.name == "Doc" ? ({link.icon}{link.name} - ) : link.name == "Contributors" ? ({link.icon}{link.name} - ) : link.name == "Home" ? ({link.icon}{link.name} - ) : null - ) - }) - } + {/* Menu icon */} +
setOpen((val) => !val)} + className="cursor-pointer md:hidden" + > + {open ? : } +
-

+ {/* Nav link items */} +

+ {navLink.map((link, index) => { + return ( +
+ {link?.isExternalURL ? ( + + {link.icon} + + ) : ( + + {link.icon} + {link.name} + + )} +
+ ); + })} + +
-

- - - - {/* -
Under Construction
- - Doc - - Contributors - - */} - - +
); } -export default Header; \ No newline at end of file +export default Header; diff --git a/src/index.css b/src/index.css index 20bde79..49cd9cd 100644 --- a/src/index.css +++ b/src/index.css @@ -77,7 +77,7 @@ html { scrollbar-width: none; } -.githubbtn { +.githubBtn { color: #9912d8; animation: pulse 2s linear infinite alternate; } @@ -96,5 +96,4 @@ html { } } - -/*# sourceMappingURL=style.css.map */ \ No newline at end of file +/*# sourceMappingURL=style.css.map */