From 9e26dce71723d4794e455a2c5e1ab6ff16e14f75 Mon Sep 17 00:00:00 2001 From: sasha-astiadi Date: Wed, 17 Sep 2025 15:45:33 +0200 Subject: [PATCH] add --- src/app/(main)/page.tsx | 3 +++ src/app/layout.tsx | 3 +-- src/components/NavLinks.tsx | 15 +++++++++++++ src/components/SmoothScrollProvider.tsx | 8 ------- src/hooks/use-smooth-scroll.ts | 28 ------------------------- 5 files changed, 19 insertions(+), 38 deletions(-) delete mode 100644 src/components/SmoothScrollProvider.tsx delete mode 100644 src/hooks/use-smooth-scroll.ts diff --git a/src/app/(main)/page.tsx b/src/app/(main)/page.tsx index b2e933e..d227a96 100644 --- a/src/app/(main)/page.tsx +++ b/src/app/(main)/page.tsx @@ -35,6 +35,9 @@ export default function Home() {
+
diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 159df5e..6e6ef92 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,7 +1,6 @@ import { type Metadata } from 'next' import { Mulish } from 'next/font/google' import clsx from 'clsx' -import SmoothScrollProvider from '@/components/SmoothScrollProvider' import '@/styles/tailwind.css' @@ -27,7 +26,7 @@ export default function RootLayout({ }) { return ( - {children} + {children} ) } diff --git a/src/components/NavLinks.tsx b/src/components/NavLinks.tsx index cd50bcf..44d2a31 100644 --- a/src/components/NavLinks.tsx +++ b/src/components/NavLinks.tsx @@ -8,6 +8,20 @@ export function NavLinks() { let [hoveredIndex, setHoveredIndex] = useState(null) let timeoutRef = useRef(null) + const handleClick = (e: React.MouseEvent, href: string) => { + if (href.startsWith('/#')) { + e.preventDefault(); + const targetId = href.substring(2); + const targetElement = document.getElementById(targetId); + + if (targetElement) { + targetElement.scrollIntoView({ + behavior: 'smooth', + }); + } + } + }; + return [ ['About', '/#about'], ['Network', '/#network'], @@ -20,6 +34,7 @@ export function NavLinks() { key={label} href={href} className="relative -mx-3 -my-2 rounded-lg px-3 py-2 text-sm text-white transition-colors delay-150 hover:text-gray-300 hover:delay-0" + onClick={(e) => handleClick(e, href)} onMouseEnter={() => { if (timeoutRef.current) { window.clearTimeout(timeoutRef.current) diff --git a/src/components/SmoothScrollProvider.tsx b/src/components/SmoothScrollProvider.tsx deleted file mode 100644 index 0aaef7b..0000000 --- a/src/components/SmoothScrollProvider.tsx +++ /dev/null @@ -1,8 +0,0 @@ -'use client' - -import { useSmoothScroll } from '@/hooks/use-smooth-scroll'; - -export default function SmoothScrollProvider({ children }: { children: React.ReactNode }) { - useSmoothScroll(); - return <>{children}; -} diff --git a/src/hooks/use-smooth-scroll.ts b/src/hooks/use-smooth-scroll.ts deleted file mode 100644 index 6cb5881..0000000 --- a/src/hooks/use-smooth-scroll.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { useEffect } from 'react'; - -export const useSmoothScroll = () => { - useEffect(() => { - const handleLinkClick = (e: MouseEvent) => { - const target = e.target as HTMLAnchorElement; - const href = target.getAttribute('href'); - - if (href && href.startsWith('#')) { - e.preventDefault(); - const targetId = href.substring(1); - const targetElement = document.getElementById(targetId); - - if (targetElement) { - targetElement.scrollIntoView({ - behavior: 'smooth', - }); - } - } - }; - - document.addEventListener('click', handleLinkClick); - - return () => { - document.removeEventListener('click', handleLinkClick); - }; - }, []); -};