From 411553ee916b8a63b2a934a7e1274bc449041016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20K=C3=B6hler?= Date: Tue, 25 Nov 2025 11:13:01 -0300 Subject: [PATCH] feat: tooltips for tool settings (#5586) --- .../core/src/services/ToolBarService/types.ts | 1 + .../OHIFToolSettings/RowDoubleRange.tsx | 24 +++- .../OHIFToolSettings/RowSegmentedControl.tsx | 15 +- .../OHIFToolSettings/ToolSettings.tsx | 132 ++++++++++++------ 4 files changed, 130 insertions(+), 42 deletions(-) diff --git a/platform/core/src/services/ToolBarService/types.ts b/platform/core/src/services/ToolBarService/types.ts index 9d7b4df8e..df8a21b1b 100644 --- a/platform/core/src/services/ToolBarService/types.ts +++ b/platform/core/src/services/ToolBarService/types.ts @@ -36,6 +36,7 @@ export type ButtonOptions = { id: string; type: 'range' | 'radio' | 'double-range' | 'custom' | 'checkbox' | 'select' | 'button'; name?: string; + tooltip?: string; min?: number; max?: number; step?: number; diff --git a/platform/ui-next/src/components/OHIFToolSettings/RowDoubleRange.tsx b/platform/ui-next/src/components/OHIFToolSettings/RowDoubleRange.tsx index 58cc3f3a0..defd71583 100644 --- a/platform/ui-next/src/components/OHIFToolSettings/RowDoubleRange.tsx +++ b/platform/ui-next/src/components/OHIFToolSettings/RowDoubleRange.tsx @@ -1,6 +1,7 @@ import React from 'react'; import Numeric from '../Numeric'; import { cn } from '../../lib/utils'; +import { Tooltip, TooltipContent, TooltipTrigger } from '../Tooltip'; interface RowDoubleRangeProps { values: [number, number]; @@ -10,6 +11,7 @@ interface RowDoubleRangeProps { step: number; showLabel?: boolean; label?: string; + tooltip?: string; className?: string; } @@ -21,8 +23,28 @@ const RowDoubleRange: React.FC = ({ step, showLabel = false, label = '', + tooltip, className, }) => { + const renderLabel = () => { + if (!showLabel || !label) { + return null; + } + + const labelNode = {label}; + + if (!tooltip) { + return labelNode; + } + + return ( + + {labelNode} + {tooltip} + + ); + }; + return ( = ({ step={step} className={cn('flex flex-col space-y-2', className)} > - {showLabel && {label}} + {renderLabel()} ); diff --git a/platform/ui-next/src/components/OHIFToolSettings/RowSegmentedControl.tsx b/platform/ui-next/src/components/OHIFToolSettings/RowSegmentedControl.tsx index e41c6e3d9..d86baaf72 100644 --- a/platform/ui-next/src/components/OHIFToolSettings/RowSegmentedControl.tsx +++ b/platform/ui-next/src/components/OHIFToolSettings/RowSegmentedControl.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Label } from '../Label'; import { Tabs, TabsList, TabsTrigger } from '../Tabs'; import { cn } from '../../lib/utils'; +import { Tooltip, TooltipContent, TooltipTrigger } from '../Tooltip'; interface RadioValue { value: string; @@ -14,6 +15,7 @@ interface RadioOption { value: string; values: RadioValue[]; onChange?: (val: string) => void; + tooltip?: string; } interface RowSegmentedControlProps { @@ -38,7 +40,18 @@ export const RowSegmentedControl: React.FC = ({ className={cn('flex items-center justify-between text-[13px]', className)} key={option.id} > - +
{ + if (!label) { + return null; + } + + if (!tooltip) { + return {label}; + } + + return ( + + + {label} + + {tooltip} + + ); +}; + const renderRangeSetting = option => { return (
-
{option.name}
+
{renderLabelWithTooltip(option.name, option.tooltip)}
{ function renderDoubleRangeSetting(option) { return ( - + > +
+ {renderLabelWithTooltip(option.name, option.tooltip)} +
+
+ +
+
); } @@ -119,15 +149,38 @@ const renderCustomSetting = option => { }; const renderButtonSetting = option => { - return ( + const button = ( ); + + if (option.tooltip) { + return ( + + {button} + {option.tooltip} + + ); + } + + return button; +}; + +const renderCheckboxLabel = option => { + return ( + + ); }; const renderCheckboxSetting = option => { @@ -143,12 +196,7 @@ const renderCheckboxSetting = option => { option.onChange?.(checked); }} /> - + {renderCheckboxLabel(option)}
); }; @@ -166,37 +214,41 @@ const renderSwitchSetting = option => { option.onChange?.(checked); }} /> - + {renderCheckboxLabel(option)}
); }; const renderSelectSetting = option => { return ( - +
+ {renderLabelWithTooltip(option.name, option.tooltip)} +
+
+ +
+ ); };