From a15d1866fd70c0e4342e2b35d9e001b633bd63de Mon Sep 17 00:00:00 2001 From: Robin Pyon Date: Thu, 26 Oct 2023 14:13:33 +0100 Subject: [PATCH] refactor: slightly DRY tooltip component --- packages/sanity/src/ui/tooltip/Tooltip.tsx | 32 ++++++++++++++-------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/sanity/src/ui/tooltip/Tooltip.tsx b/packages/sanity/src/ui/tooltip/Tooltip.tsx index face503fa07..9e26172c7ea 100644 --- a/packages/sanity/src/ui/tooltip/Tooltip.tsx +++ b/packages/sanity/src/ui/tooltip/Tooltip.tsx @@ -6,6 +6,10 @@ export interface TooltipProps extends UITooltipProps { ref?: React.ForwardedRef } +const TOOLTIP_DELAY_PROPS = { + open: 500, +} + /** * Studio UI . * @@ -20,16 +24,20 @@ export const Tooltip = forwardRef(function Tooltip( ) { const {content, ...rest} = props - if (typeof content === 'string') { - return ( - {content}} - delay={{open: 500}} - ref={ref} - {...rest} - /> - ) - } - - return + return ( + + {content} + + ) : ( + content + ) + } + delay={TOOLTIP_DELAY_PROPS} + ref={ref} + {...rest} + /> + ) })