Skip to content
This repository was archived by the owner on Apr 28, 2024. It is now read-only.

Commit

Permalink
feat: NavBar
Browse files Browse the repository at this point in the history
  • Loading branch information
DavDeDev committed Mar 7, 2023
1 parent 52a1abb commit 9ba2d83
Show file tree
Hide file tree
Showing 7 changed files with 169 additions and 72 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React</title>
<title>David | Portfolio</title>
</head>
<body>
<div id="root"></div>
Expand Down
1 change: 1 addition & 0 deletions logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"@types/react": "^18.0.27",
"@types/react-dom": "^18.0.10",
"@vitejs/plugin-react": "^3.1.0",
"autoprefixer": "^10.4.13",
"postcss": "^8.4.21",
"tailwindcss": "^3.2.7",
"vite": "^4.1.0"
}
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
67 changes: 1 addition & 66 deletions src/assets/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 75 additions & 5 deletions src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,79 @@
import React from 'react'
import React, { useEffect, useState } from "react";
import { Link } from "react-router-dom";

import { styles } from "../styles";
import { navLinks } from "../constants";
import { logo, menu, close } from "../assets";

const Navbar = () => {
const [active, setActive] = useState("");
const [toggle, setToggle] = useState(false);

return (
<div>Navbar</div>
)
}
<nav
className={`${styles.paddingX} w-full flex items-center py-5 fixed top-0 x-20 bg-primary `}
>
<div className="w-full flex justify-between items-center max-w-7xl mx-auto">
<Link
to="/"
className="flex items-center gap-2"
onClick={() => {
setActive("");
window.scrollTo(0, 0);
}}
>
<img src={logo} alt="logo" className="w-9 h-9 object-contain" />
<p className="text-white text-[18px] font-bold cursor-pointer flex">
David &nbsp;<span className="sm:block hidden">Pietrocola</span>
</p>
</Link>
<ul className="list-none hidden sm:flex flex-row gap-10">
{navLinks.map((link) => (
<li
key={link.id}
className={`${
active === link.tilte ? "text-white" : "text-secondary"
} hover:text-white text-[18px] font-medium cursor-pointer`}
onClick={() => setActive(link.title)}
>
<a href={`#${link.id}`}>{link.title}</a>
</li>
))}
</ul>

<div className="sm:hidden flex flex-1 justify-end items-center">
<img
src={toggle ? close : menu}
alt="menu"
className="w-[28px] h-[28px] object-contain cursor-pointer"
onClick={() => setToggle(!toggle)}
/>
<div
className={`${
!toggle ? "hidden" : "flex"
} p-6 black-gradient absolute top-20 right-0 mx-4 my-2 min-w-[140px] z-10 rounded-xl`}
>
<ul className="list-none flex justify-end items-start flex-col gap-4">
{navLinks.map((link) => (
<li
key={link.id}
className={`${
active === link.title ? "text-white" : "text-secondary"
}font-poppins font-medium cursor-pointer text-[16px]`}
onClick={() => {
setToggle(!toggle);
setActive(link.title);
}}
>
<a href={`#${link.id}`}>{link.title}</a>
</li>
))}
</ul>
</div>
</div>
</div>
</nav>
);
};

export default Navbar
export default Navbar;

0 comments on commit 9ba2d83

Please sign in to comment.