From ff4e858c63a702cc2050599d53ad46ab3d0b7027 Mon Sep 17 00:00:00 2001 From: Izumi Hoshino Date: Fri, 12 Jul 2024 06:37:02 +0900 Subject: [PATCH] Added tooltip icon for NFT royalties info (#2420) --- .../components/offers2/OfferBuilderValue.tsx | 90 ++++++++++--------- 1 file changed, 50 insertions(+), 40 deletions(-) diff --git a/packages/gui/src/components/offers2/OfferBuilderValue.tsx b/packages/gui/src/components/offers2/OfferBuilderValue.tsx index 081e0f8f6c..42ef740cb0 100644 --- a/packages/gui/src/components/offers2/OfferBuilderValue.tsx +++ b/packages/gui/src/components/offers2/OfferBuilderValue.tsx @@ -9,7 +9,6 @@ import { Link, Loading, StateColor, - Tooltip, TooltipIcon, } from '@chia-network/core'; import { Trans } from '@lingui/macro'; @@ -67,15 +66,49 @@ export default function OfferBuilderValue(props: OfferBuilderValueProps) { }); const readOnly = disableReadOnly ? false : builderReadOnly; - const displayValue = - amountWithRoyalties || - (!value ? ( - Not Available - ) : ['amount', 'fee', 'token'].includes(type) && Number.isFinite(value) ? ( - - ) : ( - value - )); + const displayValue = React.useMemo( + () => + amountWithRoyalties || + (!value ? ( + Not Available + ) : ['amount', 'fee', 'token'].includes(type) && Number.isFinite(value) ? ( + + ) : ( + value + )), + [amountWithRoyalties, type, value], + ); + + const tooltip = React.useMemo(() => { + if (isLoading || !readOnly) { + return null; + } + return ( + + {royaltyPayments && amountWithRoyalties ? ( + + ) : ( + + + + {displayValue} + {type === 'token' ? ( + + Search on Tail Database + + ) : null} + + + + + )} + + ); + }, [amountWithRoyalties, displayValue, isLoading, royaltyPayments, type, value, readOnly]); return ( @@ -86,32 +119,8 @@ export default function OfferBuilderValue(props: OfferBuilderValueProps) { {label} - - ) : ( - - - - {displayValue} - {type === 'token' ? ( - - Search on Tail Database - - ) : null} - - - - - ) - } - > - + + {type === 'token' ? ( ) : ( - <> +
{displayValue}   {symbol} - +
)} -
-
+ {tooltip} +
+ ) : (