import { useCallback, useRef, useState, useEffect } from 'react'; import type { MainContentHeaderProps } from '../../types/types'; import MobileMenuButton from './MobileMenuButton'; import MainContentTabSwitcher from './MainContentTabSwitcher'; import MainContentTitle from './MainContentTitle'; export default function MainContentHeader({ activeTab, setActiveTab, selectedProject, selectedSession, shouldShowTasksTab, shouldShowBrowserTab, isMobile, onMenuClick, }: MainContentHeaderProps) { const scrollRef = useRef(null); const [canScrollLeft, setCanScrollLeft] = useState(false); const [canScrollRight, setCanScrollRight] = useState(false); const updateScrollState = useCallback(() => { const el = scrollRef.current; if (!el) return; setCanScrollLeft(el.scrollLeft > 2); setCanScrollRight(el.scrollLeft < el.scrollWidth - el.clientWidth - 2); }, []); useEffect(() => { const el = scrollRef.current; if (!el) return; updateScrollState(); const observer = new ResizeObserver(updateScrollState); observer.observe(el); return () => observer.disconnect(); }, [updateScrollState]); return (
{isMobile && }
{canScrollLeft && (
)}
{canScrollRight && (
)}
); }