Skip to content

Commit 6d28e54

Browse files
committed
feat: added nav bar and made changes
1 parent eba72a3 commit 6d28e54

File tree

5 files changed

+81
-45
lines changed

5 files changed

+81
-45
lines changed

src/App.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ import { ToastContainer } from "react-toastify";
33
import routes from "@/routes/index";
44
import Navbar from '@/components/Navbar/index';
55

6+
const navLinks = [
7+
{name: "About Us", path: "/about-us"},
8+
{name: "Our Team", path: "/teams"},
9+
{name: "Gallery", path: "/gallery"},
10+
{name: "Contact", path: "/contact"},
11+
{name: "Projects", path: "/projects"}
12+
13+
];
14+
615
function App() {
716
return (
817
<Router>
9-
<Navbar/>
18+
<Navbar links={navLinks}/>
19+
1020
<ToastContainer />
1121
<Routes>
1222
{routes.map((route) => (

src/assets/images/close.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/images/menu.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/styles/index.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
@import "@fontsource/poppins/900.css";
66
@import "@fontsource/league-gothic";
77

8+
89
/* Reset default browser styles */
910
* {
1011
margin: 0;
@@ -13,6 +14,10 @@
1314
font-family: "poppins", "sans-serif";
1415
}
1516

17+
body{
18+
background-color: theme("colors.secondary.light");
19+
}
20+
1621
a {
1722
text-decoration: none;
1823
color: inherit;
@@ -22,3 +27,7 @@ a {
2227
-webkit-text-stroke-width: 2px;
2328
-webkit-text-stroke-color: #737373;
2429
}
30+
31+
.active{
32+
border-bottom: red solid;
33+
}

src/components/Navbar/index.jsx

Lines changed: 59 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,66 @@
1-
// import React from 'react';
2-
import { Link } from "react-router-dom";
3-
// import { Bars3BottomRightIcon, XMarkIcon } from "@heroicons/react/24/solid";
41
import { useState } from "react";
2+
import { Link, useLocation } from "react-router-dom";
3+
import PropTypes from "prop-types";
54
import Logo from "@/assets/images/logo.svg";
5+
import closeIcon from "@/assets/images/close.svg";
6+
import menuIcon from "@/assets/images/menu.svg";
7+
8+
function Navbar({ links }) {
9+
const [isOpen, setIsOpen] = useState(false);
10+
const location = useLocation();
611

7-
const links = [
8-
{ name: "About Us", path: "#" },
9-
{ name: "Our Team", path: "#" },
10-
{ name: "Gallery", path: "#" },
11-
{ name: "Contact", path: "#" },
12-
{ name: "Projects", path: "#" },
13-
];
14-
function Header () {
15-
const [activeLink, setActiveLink] = useState(null);
16-
// const [isOpen, _ ] = useState(false);
1712
return (
18-
<div className="shadow-md w-full fixed top-0 left-0">
19-
<div className="md:px-10 py-4 px-7 md:flex justify-between items-center bg-black ">
20-
<div className="flex text-2x1 cursor-pointer items-center gap-2">
21-
{/* <logo/> */}
22-
<img src={Logo} alt="logo" className="w-22 h-22" />
23-
</div>
24-
25-
<Link
26-
to='/'
27-
className="w-7 h-7 text-white absolute right-8 top-6 cursor-pointer md:hidden"
28-
>
29-
{/* {isOpen ? <XMarkIcon /> : <Bars3BottomRightIcon />} */}
30-
</Link>
31-
32-
<ul
33-
className={`md:flex md:items-center md:pb-0 pb-12 absolute md:static md:z-auto z-[-1] left-0 w-full md:w-auto md:pl-0 pl-9 transition-all duration-500 ease-in `}
34-
>
35-
{links.map((link, index) => (
36-
<li
37-
key={link.name}
38-
className={`font-semibold my-7 md:my-0 md:ml-8 ${activeLink === index ? "hover:border-b-2 border-red-500" : ""}`}
39-
>
40-
<Link to={link.path} className="hover:border-b-2 border-white transition-all duration-300 ease-in-out" onClick={() => setActiveLink(index)}>{link.name}</Link>
41-
</li>
42-
43-
44-
))}
45-
</ul>
46-
</div>
47-
</div>
13+
<nav className=" shadow-md w-full flex justify-between items-center px-6 bg-secondary-dark">
14+
<Link to="/" className="cursor-pointer">
15+
<img src={Logo} alt="logo" />
16+
</Link>
17+
18+
<ul
19+
className={`
20+
md:flex pl-0 justify-start md:justify-center md:items-center md:pb-0 md:z-auto left-0
21+
transition-all duration-500 ease-in
22+
${isOpen ? "flex flex-col " : "hidden"}
23+
`}
24+
>
25+
{links.map((link) => (
26+
<li
27+
key={link.name}
28+
className={`
29+
font-semibold text-white md:my-0 md:ml-8
30+
border-b-2
31+
${
32+
location.pathname .toLowerCase().includes(link.path.toLowerCase())
33+
? "border-red-500 hover:border-red-700"
34+
: "border-transparent hover:border-red-500"
35+
}
36+
`}
37+
>
38+
<Link to={link.path}>{link.name}</Link>
39+
</li>
40+
))}
41+
</ul>
42+
<button
43+
type="button"
44+
onClick={() => setIsOpen(!isOpen)}
45+
className="w-7 h-7 text-white cursor-pointer md:hidden"
46+
>
47+
{isOpen ? (
48+
<img src={closeIcon} alt="close" />
49+
) : (
50+
<img src={menuIcon} alt="menu" />
51+
)}
52+
</button>
53+
</nav>
4854
);
55+
}
56+
57+
Navbar.propTypes = {
58+
links: PropTypes.arrayOf(
59+
PropTypes.shape({
60+
name: PropTypes.string.isRequired,
61+
path: PropTypes.string.isRequired,
62+
}),
63+
).isRequired,
4964
};
5065

51-
export default Header;
66+
export default Navbar;

0 commit comments

Comments
 (0)