From 322b18cd15ef67c29a3af435899cd2afbd3e0158 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 9 Jan 2025 11:22:08 +1000 Subject: [PATCH] feat: Update confirmation popup amount styling --- .../TransactionSummaryModal/FeeSummary.tsx | 1 + .../TransactionSummaryModal/TokenInfo.tsx | 79 +++++++++++++------ .../TransferSummary.tsx | 23 ++++++ 3 files changed, 81 insertions(+), 22 deletions(-) diff --git a/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/FeeSummary.tsx b/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/FeeSummary.tsx index 9c56e862..af65f2ce 100644 --- a/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/FeeSummary.tsx +++ b/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/FeeSummary.tsx @@ -19,6 +19,7 @@ export const FeeSummary = () => { h={['auto', 'auto', '60px']} borderRadius={'8px'} bg={theme.colors[colorMode].background.modal} + className="bccb-widget-transaction-summary-modal-fee-summary" > {isGlobalFeeLoading ? ( diff --git a/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TokenInfo.tsx b/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TokenInfo.tsx index 4a6798e6..1663f152 100644 --- a/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TokenInfo.tsx +++ b/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TokenInfo.tsx @@ -1,4 +1,4 @@ -import { Box, Flex, Skeleton, theme, useColorMode } from '@bnb-chain/space'; +import { Flex, Skeleton, useColorMode, useTheme } from '@bnb-chain/space'; import { IconImage } from '@/core/components/IconImage'; import { useAppSelector } from '@/modules/store/StoreProvider'; @@ -9,14 +9,15 @@ export const TokenInfo = ({ chainName, amount, tokenSymbol, + isLongText, }: { chainIconUrl?: string; tokenIconUrl?: string; chainName?: string; amount?: string; tokenSymbol?: string; + isLongText: boolean; }) => { - const { colorMode } = useColorMode(); const isGlobalFeeLoading = useAppSelector((state) => state.transfer.isGlobalFeeLoading); return ( @@ -26,6 +27,7 @@ export const TokenInfo = ({ w={'100%'} alignItems={'center'} gap={'16px'} + className="bccb-widget-transaction-summary-modal-token-info" > + - - - {chainName} - - - {isGlobalFeeLoading ? ( - - ) : ( - {amount ?? '--'} {tokenSymbol} + + {chainName} + + {isLongText && !isGlobalFeeLoading && ( + + )} + + {!isLongText && !isGlobalFeeLoading && ( + )} + {isGlobalFeeLoading && ( + + )} + + ); +}; + +const TokenAmount = ({ amount, tokenSymbol }: { amount: string; tokenSymbol: string }) => { + const { colorMode } = useColorMode(); + const theme = useTheme(); + return ( + + {amount} {tokenSymbol} ); }; diff --git a/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TransferSummary.tsx b/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TransferSummary.tsx index 66b4d9b0..88de0e1c 100644 --- a/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TransferSummary.tsx +++ b/packages/canonical-bridge-widget/src/modules/transfer/components/Modal/TransactionSummaryModal/TransferSummary.tsx @@ -47,6 +47,26 @@ export const TransferSummary = () => { [toTokenAddress, toChain?.chainType], ); + const isLongFromAmount = useMemo(() => { + if (isBase) return true; + try { + if (sendValue && selectedToken?.symbol) { + return sendValue.length + selectedToken.symbol.length - 1 > 16; + } + } catch {} + return false; + }, [sendValue, selectedToken?.symbol, isBase]); + + const isLongToAmount = useMemo(() => { + if (isBase) return true; + try { + if (receiveAmt && toTokenInfo?.symbol) { + return String(receiveAmt).length + toTokenInfo?.symbol.length - 1 > 16; + } + } catch {} + return false; + }, [receiveAmt, toTokenInfo?.symbol, isBase]); + return ( { gap={'4px'} borderRadius={'8px'} bg={theme.colors[colorMode].background.modal} + className="bccb-widget-transaction-summary-modal-summary-wrapper" > { chainName={fromChain?.name} amount={!!sendValue ? `- ${sendValue}` : ''} tokenSymbol={selectedToken?.symbol ?? ''} + isLongText={isLongFromAmount || isLongToAmount} /> { chainName={toChain?.name} amount={!!receiveAmt ? `+ ${receiveAmt}` : ''} tokenSymbol={toTokenInfo?.symbol ?? ''} + isLongText={isLongFromAmount || isLongToAmount} />