From 76f59b3a481abff69e48cd1e15042a3461921643 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Tue, 18 Feb 2025 11:05:59 +1300 Subject: [PATCH] [SDK] fix: Text wrapping and balance display in token selector --- .changeset/tall-buckets-build.md | 5 ++ .../chains/chain-definitions/arbitrum-nova.ts | 2 +- .../ConnectWallet/screens/Buy/BuyScreen.tsx | 6 +- .../screens/Buy/swap/TokenSelectorScreen.tsx | 80 ++++++++++++++++--- 4 files changed, 78 insertions(+), 15 deletions(-) create mode 100644 .changeset/tall-buckets-build.md diff --git a/.changeset/tall-buckets-build.md b/.changeset/tall-buckets-build.md new file mode 100644 index 00000000000..44be1dacd79 --- /dev/null +++ b/.changeset/tall-buckets-build.md @@ -0,0 +1,5 @@ +--- +"thirdweb": patch +--- + +Fix text wrapping for long balances in token selector diff --git a/packages/thirdweb/src/chains/chain-definitions/arbitrum-nova.ts b/packages/thirdweb/src/chains/chain-definitions/arbitrum-nova.ts index 638978caaa1..79bf4ac2624 100644 --- a/packages/thirdweb/src/chains/chain-definitions/arbitrum-nova.ts +++ b/packages/thirdweb/src/chains/chain-definitions/arbitrum-nova.ts @@ -10,7 +10,7 @@ export const arbitrumNova = /* @__PURE__ */ defineChain({ blockExplorers: [ { name: "Arbiscan", - url: "https://nova-explorer.arbitrum.io/", + url: "https://nova.arbiscan.io/", }, ], }); diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx index 9984a284ae0..bc6a6a7e26d 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx @@ -635,11 +635,7 @@ function SelectedTokenInfo(props: { placeholder="0" type="text" data-placeholder={props.tokenAmount === ""} - value={ - props.tokenAmount - ? formatNumber(Number(props.tokenAmount), 5) - : "0" - } + value={props.tokenAmount || "0"} disabled={props.disabled} onClick={(e) => { // put cursor at the end of the input diff --git a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx index a7c0a0efdbc..61327a66ab9 100644 --- a/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx +++ b/packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/TokenSelectorScreen.tsx @@ -381,33 +381,90 @@ function TokenBalanceRow(props: { onClick(tokenBalance.token, wallet)} variant="secondary" - style={style} + style={{ + ...style, + display: "flex", + justifyContent: "space-between", + minWidth: 0, // Needed for text truncation to work + }} > - + - - + + {tokenBalance.token.symbol} - {chainInfo && {chainInfo.name}} + {chainInfo && ( + + {chainInfo.name} + + )} - + + - + {formatTokenBalance(tokenBalance.balance, true, 2)} - + ); @@ -429,6 +490,7 @@ const StyledButton = /* @__PURE__ */ styled(Button)((props) => { return { background: "transparent", justifyContent: "space-between", + flexWrap: "nowrap", flexDirection: "row", padding: spacing.sm, paddingRight: spacing.xs,