diff --git a/web/src/components/ui/segmented/AppSegmented.tsx b/web/src/components/ui/segmented/AppSegmented.tsx index 7cb10ee3c..2bf37e220 100644 --- a/web/src/components/ui/segmented/AppSegmented.tsx +++ b/web/src/components/ui/segmented/AppSegmented.tsx @@ -28,16 +28,22 @@ export interface AppSegmentedProps { disabled?: boolean; } +const heightVariants = cva('h-[24px]', { + variants: { + size: { + default: 'h-[24px]', + medium: 'h-[28px]', + large: 'h-[50px]' + } + } +}); + const segmentedVariants = cva('relative inline-flex items-center rounded', { variants: { block: { true: 'w-full', false: '' }, - size: { - default: '', - large: '' - }, type: { button: 'bg-transparent', track: 'bg-item-select' @@ -46,11 +52,12 @@ const segmentedVariants = cva('relative inline-flex items-center rounded', { }); const triggerVariants = cva( - 'relative z-10 flex items-center justify-center gap-x-1.5 gap-y-1 rounded transition-colors', + 'relative z-10 flex items-center justify-center gap-x-1.5 gap-y-1 rounded transition-colors ', { variants: { size: { - default: 'px-2.5 flex-row', + default: 'px-2 flex-row', + medium: 'px-3 flex-row', large: 'px-3 flex-col' }, block: { @@ -65,6 +72,12 @@ const triggerVariants = cva( true: 'text-foreground', false: 'text-gray-dark hover:text-foreground' } + }, + defaultVariants: { + size: 'default', + block: false, + disabled: false, + selected: false } } ); @@ -108,8 +121,6 @@ export const AppSegmented: AppSegmentedComponent = React.memo( }); const [isMeasured, setIsMeasured] = useState(false); - const height = size === 'default' ? 'h-[28px]' : 'h-[50px]'; - useEffect(() => { if (value !== undefined && value !== selectedValue) { setSelectedValue(value); @@ -154,10 +165,10 @@ export const AppSegmented: AppSegmentedComponent = React.memo( ref={ref} value={selectedValue as string} onValueChange={handleTabClick} - className={cn(segmentedVariants({ block, type }), height, className)}> + className={cn(segmentedVariants({ block, type }), heightVariants({ size }), className)}> {isMeasured && ( )} {options.map((item) => ( { function SegmentedTriggerComponent(props: SegmentedTriggerProps) { const { item, selectedValue, size, block, tabRefs } = props; - const NodeWrapper = item.tooltip - ? ({ children }: { children: React.ReactNode }) => ( -
{children}
- ) - : React.Fragment; - return ( ; + return ( + + ); }); MetricsFilters.displayName = 'MetricsFilters';