import type { FC } from 'react' import cn from 'classnames' type Option = { value: string text: string } type TabSliderProps = { className?: string itemWidth?: number value: string onChange: (v: string) => void options: Option[] } const TabSlider: FC = ({ className, itemWidth = 118, value, onChange, options, }) => { const currentIndex = options.findIndex(option => option.value === value) const current = options[currentIndex] return (
{ options.map((option, index) => (
onChange(option.value)} > {option.text}
)) } { current && (
{current.text}
) }
) } export default TabSlider