From 9b3c620706c264b5e49297d67760a51231a374c3 Mon Sep 17 00:00:00 2001 From: sasha-astiadi Date: Thu, 23 Oct 2025 16:36:37 +0200 Subject: [PATCH] refactor: simplify header component and improve hero section layouts --- src/components/Header.tsx | 168 +++++++++++----------------------- src/components/Layout.tsx | 9 +- src/pages/home/HomeAurora.tsx | 2 +- src/pages/home/HomeHero.tsx | 13 ++- src/pages/network/Hero.tsx | 6 +- 5 files changed, 64 insertions(+), 134 deletions(-) diff --git a/src/components/Header.tsx b/src/components/Header.tsx index d04986c..6d6f233 100644 --- a/src/components/Header.tsx +++ b/src/components/Header.tsx @@ -1,123 +1,61 @@ -'use client' - - -import { useEffect, useRef, useState } from 'react' import { Link } from 'react-router-dom' -import { AnimatePresence, motion } from 'framer-motion' -import clsx from 'clsx' +import { Container } from './Container' import { Button } from './Button' - -function NavLinks() { - let [hoveredIndex, setHoveredIndex] = useState(null) - let timeoutRef = useRef(null) - - return ( - <> - {[ - ['Home', '/'], - ['Cloud', '/cloud'], - ['Network', '/network'], - ['Agents', '/agents'], - ].map(([label, href], index) => ( - { - if (timeoutRef.current) { - window.clearTimeout(timeoutRef.current) - } - setHoveredIndex(index) - }} - onMouseLeave={() => { - timeoutRef.current = window.setTimeout(() => { - setHoveredIndex(null) - }, 200) - }} - > - - {hoveredIndex === index && ( - - )} - - {label} - - ))} - - ) -} - export function Header() { - const [isVisible, setIsVisible] = useState(true) - const [lastScrollY, setLastScrollY] = useState(0) - - const controlHeader = () => { - if (typeof window !== 'undefined') { - if (window.scrollY > lastScrollY && window.scrollY > 100) { - // Hides when scrolling down past 100px - setIsVisible(false) - } else { - // Shows when scrolling up - setIsVisible(true) - } - setLastScrollY(window.scrollY) - } - } - - useEffect(() => { - if (typeof window !== 'undefined') { - window.addEventListener('scroll', controlHeader) - return () => { - window.removeEventListener('scroll', controlHeader) - } - } - }, [lastScrollY]) - return ( - -
-
- - Mycelium - -
-
- -
-
-
- - +
+
-
- +
+
+ + +
+
+ + + ) } diff --git a/src/components/Layout.tsx b/src/components/Layout.tsx index 334f71e..79fb774 100644 --- a/src/components/Layout.tsx +++ b/src/components/Layout.tsx @@ -1,20 +1,13 @@ import { Outlet } from 'react-router-dom' -import { FloatingNav } from './ui/floating-navbar' import { Footer } from './Footer' import { Header } from './Header' export function Layout() { - const navItems = [ - { name: 'Home', link: '/' }, - { name: 'Cloud', link: '/cloud' }, - { name: 'Network', link: '/network' }, - { name: 'Agents', link: '/agents' }, - ]; return (
-
+