Skip to content

Commit

Permalink
Added new image + added smooth scrolling for navar
Browse files Browse the repository at this point in the history
  • Loading branch information
ArushYadlapati committed Aug 16, 2024
1 parent 05b87c8 commit 2a1d975
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 28 deletions.
90 changes: 62 additions & 28 deletions app/components/navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,71 @@
'use client';

// @flow strict
import Link from "next/link";

import { useEffect } from "react";
import { useRouter } from 'next/navigation';

function Navbar() {
return (
<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">
arushyadlapati.com
</Link>
</div>
const router = useRouter();

useEffect(() => {
const handleSmoothScroll = (e) => {
const href = e.currentTarget.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
window.history.pushState({}, '', href);
}
}
};

<ul className="mt-4 flex h-screen max-h-0 w-full flex-col items-start text-sm opacity-0 md:mt-0 md:h-auto md:max-h-screen md:w-auto md:flex-row md:space-x-1 md:border-0 md:opacity-100" id="navbar-default">
<li>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#about">
<div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">ABOUT</div>
const links = document.querySelectorAll('a[href^="/#"]');
links.forEach(link => {
link.addEventListener("click", handleSmoothScroll);
});

return () => {
links.forEach(link => {
link.removeEventListener("click", handleSmoothScroll);
});
};
}, []);

return (
<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">
arushyadlapati.com
</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>
</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>
</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>
</li>
</ul>
</div>
</nav>
</div>

<ul className="mt-4 flex h-screen max-h-0 w-full flex-col items-start text-sm opacity-0 md:mt-0 md:h-auto md:max-h-screen md:w-auto md:flex-row md:space-x-1 md:border-0 md:opacity-100" id="navbar-default">
<li>
<Link className="block px-4 py-2 no-underline outline-none hover:no-underline" href="/#about">
<div className="text-sm text-white transition-colors duration-300 hover:text-pink-600">ABOUT</div>
</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>
</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>
</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>
</li>
</ul>
</div>
</nav>
);
};

Expand Down
Binary file modified public/profile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2a1d975

Please sign in to comment.