import React, { useCallback, useRef, useState } from 'react'; import { useTranslation } from 'react-i18next'; import ArrowLeft from '../assets/arrow-left.svg'; import ArrowRight from '../assets/arrow-right.svg'; type HiddenGradientType = 'left' | 'right' | undefined; const useTabs = () => { const { t } = useTranslation(); const tabs = [ t('settings.general.label'), t('settings.sources.label'), t('settings.analytics.label'), t('settings.logs.label'), t('settings.tools.label'), ]; return tabs; }; interface SettingsBarProps { setActiveTab: React.Dispatch>; activeTab: string; } const SettingsBar = ({ setActiveTab, activeTab }: SettingsBarProps) => { const [hiddenGradient, setHiddenGradient] = useState('left'); const containerRef = useRef(null); const tabs = useTabs(); const scrollTabs = useCallback( (direction: number) => { if (containerRef.current) { const container = containerRef.current; container.scrollLeft += direction * 100; // Adjust the scroll amount as needed if (container.scrollLeft === 0) { setHiddenGradient('left'); } else if ( container.scrollLeft + container.offsetWidth === container.scrollWidth ) { setHiddenGradient('right'); } else { setHiddenGradient(undefined); } } }, [containerRef.current], ); return (
{tabs.map((tab, index) => ( ))}
); }; export default SettingsBar;