Skip to content

Commit 994f6ee

Browse files
authored
Merge pull request #30 from codeXsit/codex-6-Navbar
Codex 6 navbar
2 parents ae7de96 + d81a6a6 commit 994f6ee

File tree

9 files changed

+99
-3
lines changed

9 files changed

+99
-3
lines changed

.husky/commit-msg

100644100755
File mode changed.

.husky/pre-commit

100644100755
File mode changed.

src/App.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
import { HashRouter as Router, Routes, Route } from "react-router-dom";
22
import { ToastContainer } from "react-toastify";
33
import routes from "@/routes/index";
4+
import Navbar from "@/components/Navbar/index";
5+
6+
7+
8+
const navLinks = [
9+
{name: "About Us", path: "/about-us"},
10+
{name: "Our Team", path: "/teams"},
11+
{name: "Gallery", path: "/gallery"},
12+
{name: "Contact", path: "/contact"},
13+
{name: "Projects", path: "/projects"}
14+
15+
];
416

517
function App() {
618
return (
719
<Router>
20+
<Navbar links={navLinks}/>
21+
822
<ToastContainer />
923
<Routes>
1024
{routes.map((route) => (

src/assets/images/close.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/images/logo.svg

Lines changed: 9 additions & 0 deletions
Loading

src/assets/images/menu.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/styles/index.css

Lines changed: 5 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;

src/components/Navbar/index.jsx

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { useState } from "react";
2+
import { Link, useLocation } from "react-router-dom";
3+
import PropTypes from "prop-types";
4+
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();
11+
12+
return (
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>
54+
);
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,
64+
};
65+
66+
export default Navbar;

tailwind.config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ export default {
2222
text: {
2323
light: "#F7F7F7",
2424
dark: "#232323",
25-
},
25+
},
2626
gradient: {
2727
light: "#383838",
2828
dark: "#222222 ",
29-
}
29+
},
3030
},
3131
screens: {
3232
xs: "0px",
@@ -37,7 +37,7 @@ export default {
3737
},
3838
fontFamily: {
3939
poppins: ["Poppins", "sans-serif"],
40-
gothic: ["League Gothic", "sans-serif"]
40+
gothic: ["League Gothic", "sans-serif"],
4141
},
4242
},
4343
},

0 commit comments

Comments
 (0)