diff --git a/AppImage/components/proxmox-dashboard.tsx b/AppImage/components/proxmox-dashboard.tsx index 4d415e7..1b10ad5 100644 --- a/AppImage/components/proxmox-dashboard.tsx +++ b/AppImage/components/proxmox-dashboard.tsx @@ -27,6 +27,7 @@ import { import Image from "next/image" import { ThemeToggle } from "./theme-toggle" import { Sheet, SheetContent, SheetTrigger } from "./ui/sheet" +import { useScrollDirection } from "@/hooks/use-scroll-direction" interface SystemStatus { status: "healthy" | "warning" | "critical" @@ -60,6 +61,8 @@ export function ProxmoxDashboard() { const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const [activeTab, setActiveTab] = useState("overview") + const { scrollDirection, isAtTop } = useScrollDirection() + const fetchSystemData = useCallback(async () => { console.log("[v0] Fetching system data from Flask server...") console.log("[v0] Current window location:", window.location.href) @@ -294,145 +297,155 @@ export function ProxmoxDashboard() {
- - - Overview - - - Storage - - - Network - - - VMs & LXCs - - - Hardware - - - System Logs - - +
+ + + Overview + + + Storage + + + Network + + + VMs & LXCs + + + Hardware + + + System Logs + + - -
- - - -
- -
- - - - - - + +
+ + +
- -
+ +
+ + + + + + +
+
+ +
diff --git a/AppImage/hooks/use-scroll-direction.ts b/AppImage/hooks/use-scroll-direction.ts new file mode 100644 index 0000000..b799108 --- /dev/null +++ b/AppImage/hooks/use-scroll-direction.ts @@ -0,0 +1,43 @@ +"use client" + +import { useState, useEffect } from "react" + +export function useScrollDirection() { + const [scrollDirection, setScrollDirection] = useState<"up" | "down" | null>(null) + const [isAtTop, setIsAtTop] = useState(true) + + useEffect(() => { + let lastScrollY = window.scrollY + let ticking = false + + const updateScrollDirection = () => { + const scrollY = window.scrollY + + // Check if we're at the top of the page + setIsAtTop(scrollY < 10) + + // Only update direction if we've scrolled more than 5px + if (Math.abs(scrollY - lastScrollY) < 5) { + ticking = false + return + } + + setScrollDirection(scrollY > lastScrollY ? "down" : "up") + lastScrollY = scrollY > 0 ? scrollY : 0 + ticking = false + } + + const onScroll = () => { + if (!ticking) { + window.requestAnimationFrame(updateScrollDirection) + ticking = true + } + } + + window.addEventListener("scroll", onScroll) + + return () => window.removeEventListener("scroll", onScroll) + }, []) + + return { scrollDirection, isAtTop } +}