From eea87ac02f0ca87d7732fcfac2e2ebb8a81f8012 Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Mon, 13 Jan 2025 11:08:04 -0800 Subject: [PATCH] Better SegmentedControl styles --- src-web/components/core/SegmentedControl.tsx | 43 ++++++++++++-------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src-web/components/core/SegmentedControl.tsx b/src-web/components/core/SegmentedControl.tsx index 3ed7bf41..4241a7b5 100644 --- a/src-web/components/core/SegmentedControl.tsx +++ b/src-web/components/core/SegmentedControl.tsx @@ -1,3 +1,4 @@ +import classNames from 'classnames'; import { useRef } from 'react'; import { useStateWithDeps } from '../../hooks/useStateWithDeps'; import type { IconProps } from './Icon'; @@ -18,10 +19,10 @@ export function SegmentedControl({ value, onChange, options, n return ( { const selectedIndex = options.findIndex((o) => o.value === selectedValue); if (e.key === 'ArrowRight') { @@ -37,20 +38,30 @@ export function SegmentedControl({ value, onChange, options, n } }} > - {options.map((o, i) => ( - onChange(o.value)} - /> - ))} + {options.map((o, i) => { + const isSelected = selectedValue === o.value; + const isActive = value === o.value; + return ( + onChange(o.value)} + /> + ); + })} ); }