import { IconDefinition } from "@fortawesome/fontawesome-svg-core"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import React, { useRef } from "react"; interface SegmentedControlProps { value: string; onChange: (value: string) => void; data: { label: string; value: string; icon?: IconDefinition }[]; } export const SegmentedControl = ({ value, onChange, data, }: SegmentedControlProps) => { const containerRef = useRef(null); const handleClick = (newValue: string) => { onChange(newValue); }; const currentIndex = data.findIndex((item) => item.value === value); const highlightStyle: React.CSSProperties = { width: `${100 / data.length}%`, transform: `translateX(${currentIndex * 100}%)`, transition: "transform 0.2s ease", }; return (
{data.map((item) => ( ))}
); };