Skip to content

Commit

Permalink
fix: The route is imroved.
Browse files Browse the repository at this point in the history
  • Loading branch information
Suraj-kumar00 committed Sep 14, 2024
1 parent fff50de commit d37ab8c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/sections/Contact.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const ContactSection = () => {
href="mailto:[email protected]"
className="inline-block"
>
<button className="text-white bg-gray-900 inline-flex items-center px-6 h-12 rounded-xl gap-2 w-max border border-gray-900 hover:bg-gray-700 z-1000">
<button className="text-white bg-gray-900 inline-flex items-center px-6 h-12 rounded-xl gap-2 w-max border border-gray-900 hover:bg-gray-700 ">
Contact Me
<ArrowUpRightIcon className="w-4 h-4" />
</button>
Expand Down
39 changes: 36 additions & 3 deletions src/sections/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,51 @@
"use client";
// Updated to use next/navigation
import { useRouter } from "next/navigation";
import { MouseEvent } from "react";

export const Header = () => {
const router = useRouter();

const handleNavigation = (
e: MouseEvent<HTMLAnchorElement>,
sectionId: string
) => {
e.preventDefault(); // Prevent default anchor behavior (removes the # from URL)
const section = document.getElementById(sectionId);
if (section) {
section.scrollIntoView({ behavior: "smooth" });
// Use router.push to update the URL without the hash
// router.push("/");
}
};

return (
<div className="flex justify-center items-center fixed top-3 w-full z-10">
<nav className="flex gap-1 p-0.5 border border-white/15 rounded-full bg-white/10 backdrop-blur">
<a href="#home" className="nav-item">
<a
href="#home"
onClick={(e) => handleNavigation(e, "home")}
className="nav-item"
>
Home
</a>
<a href="#project" className="nav-item">
<a
href="#project"
onClick={(e) => handleNavigation(e, "project")}
className="nav-item"
>
Project
</a>
<a href="#about" className="nav-item">
<a
href="#about"
onClick={(e) => handleNavigation(e, "about")}
className="nav-item"
>
About
</a>
<a
href="#contact"
onClick={(e) => handleNavigation(e, "contact")}
className="nav-item bg-white text-gray-900 hover:bg-white/70 hover:text-gray-900"
>
Contact
Expand Down

0 comments on commit d37ab8c

Please sign in to comment.