import React, { useState } from 'react'; type MenuItem = { title: string; icon?: JSX.Element; action: () => void; }; type SliderMenuProps = { items: MenuItem[]; width: number; arrowColor?: string; activeArrowColor?: string; borderColor?: string; backgroundColor?: string; itemBackgroundColor?: string; itemWidth?: number; itemHeight?: number; itemBorder?: string; fontSize?: number; activeItemBorderColor?: string; activeItemBoxShadow?: string; }; // eslint-disable-next-line react/function-component-definition const SliderMenu = ({ items, width, arrowColor = 'black', activeArrowColor = 'red', borderColor = 'gray', backgroundColor = 'white', itemBackgroundColor = 'lightgray', itemWidth = 100, itemHeight = 20, itemBorder = '1px solid gray', fontSize = 14, activeItemBorderColor = 'blue', activeItemBoxShadow = '2px 2px 4px rgba(0, 0, 0, 0.2)', }:SliderMenuProps) => { const [currentIndex, setCurrentIndex] = useState(-1); const [hoveredIndex, setHoveredIndex] = useState(null); const handlePrev = () => { setCurrentIndex((currentIndex - 1 + items.length) % items.length); }; const handleNext = () => { setCurrentIndex((currentIndex + 1) % items.length); }; const handleItemClick = (index: number, action: () => void) => { setCurrentIndex(index); action(); }; return (
{items.map((item, index) => (
handleItemClick(index, item.action)} onMouseEnter={() => setHoveredIndex(index)} onMouseLeave={() => setHoveredIndex(null)} > {item.icon && (
{item.icon}
)} {item.title}
))}
); }; export default SliderMenu;