Skip to content

Commit

Permalink
Updating navbar to fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushYadlapati committed Aug 16, 2024
1 parent c763c94 commit 9eb1e63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
1 change: 0 additions & 1 deletion app/components/homepage/about/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import { personalData } from "@/utils/data/personal-data";
import Image from "next/image";


function AboutSection() {
return (
<div id="about" className="my-12 lg:my-16 relative">
Expand Down
30 changes: 16 additions & 14 deletions app/components/navbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,14 @@ function Navbar() {

useEffect(() => {
const handleSmoothScroll = (e) => {
const href = e.currentTarget.href;
e.preventDefault();
const href = e.currentTarget.getAttribute('href');
const targetId = href.replace(/.*\#/, "");

if (targetId) {
e.preventDefault();
const targetElement = document.getElementById(targetId);
if (targetElement) {
targetElement.scrollIntoView({
behavior: "smooth"
});
// Update the URL without a page reload
targetElement.scrollIntoView({ behavior: "smooth" });
window.history.pushState({}, '', href);
}
}
Expand All @@ -41,9 +39,7 @@ function Navbar() {
<nav className="bg-transparent">
<div className="flex items-center justify-between py-5">
<div className="flex flex-shrink-0 items-center">
<Link
href="./"
className="text-[#16f2b3] text-3xl font-bold">
<Link href="./" className="text-[#16f2b3] text-3xl font-bold">
arushyadlapati.com
</Link>
</div>
Expand All @@ -55,18 +51,24 @@ function Navbar() {
</Link>
</li>
<li>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#experience"><div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">EXPERIENCE</div></Link>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#experience">
<div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">EXPERIENCE</div>
</Link>
</li>
<li>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#skills"><div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">SKILLS</div></Link>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#skills">
<div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">SKILLS</div>
</Link>
</li>
<li>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#projects"><div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">PROJECTS</div></Link>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#projects">
<div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">PROJECTS</div>
</Link>
</li>
</ul>
</div>
</nav>
);
};
}

export default Navbar;
export default Navbar;

0 comments on commit 9eb1e63

Please sign in to comment.