"use client"; import { cn } from "@/lib/utils"; import { Tab, tabs, useMediaPanelStore } from "./store"; import { Tooltip, TooltipContent, TooltipTrigger, } from "@/components/ui/tooltip"; import { useEffect, useRef, useState } from "react"; export function TabBar() { const { activeTab, setActiveTab } = useMediaPanelStore(); const scrollRef = useRef(null); const [showTopFade, setShowTopFade] = useState(false); const [showBottomFade, setShowBottomFade] = useState(false); const checkScrollPosition = () => { const element = scrollRef.current; if (!element) return; const { scrollTop, scrollHeight, clientHeight } = element; setShowTopFade(scrollTop > 0); setShowBottomFade(scrollTop < scrollHeight - clientHeight - 1); }; useEffect(() => { const element = scrollRef.current; if (!element) return; checkScrollPosition(); element.addEventListener("scroll", checkScrollPosition); const resizeObserver = new ResizeObserver(checkScrollPosition); resizeObserver.observe(element); return () => { element.removeEventListener("scroll", checkScrollPosition); resizeObserver.disconnect(); }; }, []); return (
{(Object.keys(tabs) as Tab[]).map((tabKey) => { const tab = tabs[tabKey]; return (
setActiveTab(tabKey)} key={tabKey} >
{tab.label}
); })}
); } function FadeOverlay({ direction, show }: { direction: "top" | "bottom", show: boolean }) { return (
); }