import { Box } from './Box'; import { Stack } from './Stack'; import { Text } from './Text'; interface SegmentedControlOption { value: string; label: string; description?: string; disabled?: boolean; } interface SegmentedControlProps { options: SegmentedControlOption[]; value: string; onChange?: (value: string) => void; } export function SegmentedControl({ options, value, onChange, }: SegmentedControlProps) { const handleSelect = (optionValue: string, optionDisabled?: boolean) => { if (!onChange || optionDisabled) return; if (optionValue === value) return; onChange(optionValue); }; return ( {options.map((option) => { const isSelected = option.value === value; return ( handleSelect(option.value, option.disabled)} aria-pressed={isSelected} disabled={option.disabled} style={{ flex: 1, minWidth: '140px', padding: '0.375rem 0.75rem', borderRadius: '9999px', transition: 'all 0.2s', textAlign: 'left', backgroundColor: isSelected ? '#3b82f6' : 'transparent', color: isSelected ? 'white' : '#d1d5db', opacity: option.disabled ? 0.5 : 1, cursor: option.disabled ? 'not-allowed' : 'pointer', border: 'none' }} > {option.label} {option.description && ( {option.description} )} ); })} ); }