From 9237fb4b461645c655d7935d82922aaa27487de9 Mon Sep 17 00:00:00 2001 From: aldin4u Date: Tue, 23 Dec 2025 09:53:44 +0000 Subject: [PATCH] fix(pulse): token selector responsiveness and daily price change data - Refactored token selector in Buy and Sell components to use a flexible flexbox layout, resolving text overlap and width issues. - Fixed dailyPriceChange data mapping in Search.tsx to correctly handle both 'price_change_24h' and 'priceChange24h' properties. - Updated Buy.tsx to include price change data when pre-selecting tokens from URL. --- src/apps/pulse/components/Buy/Buy.tsx | 112 +++++++++--------- src/apps/pulse/components/Search/Search.tsx | 32 +++-- src/apps/pulse/components/Sell/Sell.tsx | 125 ++++++++++---------- 3 files changed, 133 insertions(+), 136 deletions(-) diff --git a/src/apps/pulse/components/Buy/Buy.tsx b/src/apps/pulse/components/Buy/Buy.tsx index 9e56be2c..0e800a8c 100644 --- a/src/apps/pulse/components/Buy/Buy.tsx +++ b/src/apps/pulse/components/Buy/Buy.tsx @@ -200,17 +200,17 @@ export default function Buy(props: BuyProps) { } = useTokenPnL( token && accountAddress && portfolioToken ? { - token: { - contract: token.address || '', - symbol: token.symbol, - decimals: token.decimals || 18, - balance: portfolioToken.balance || 0, - price: portfolioToken.price || 0, - }, - transactionsData, - walletAddress: accountAddress, - chainId: token.chainId, - } + token: { + contract: token.address || '', + symbol: token.symbol, + decimals: token.decimals || 18, + balance: portfolioToken.balance || 0, + price: portfolioToken.price || 0, + }, + transactionsData, + walletAddress: accountAddress, + chainId: token.chainId, + } : null ); @@ -245,7 +245,7 @@ export default function Buy(props: BuyProps) { const nativeToken = portfolioTokens.find( (t) => Number(getChainId(t.blockchain as MobulaChainNames)) === - maxStableCoinBalance.chainId && isNativeToken(t.contract) + maxStableCoinBalance.chainId && isNativeToken(t.contract) ); if (!nativeToken) { @@ -598,7 +598,7 @@ export default function Buy(props: BuyProps) { ? foundToken.decimals[0] || 18 : foundToken.decimals || 18, usdValue: foundToken.price?.toString() || '0', - dailyPriceChange: 0, + dailyPriceChange: foundToken.price_change_24h || 0, }; setBuyToken(tokenToSelect as SelectedToken); @@ -642,11 +642,11 @@ export default function Buy(props: BuyProps) { > {token ? (
{/* Logo */} -
+
{token.logo ? (
- {/* Top Row: Symbol and Name */} -
-

- {token.symbol} -

-

- {token.name} -

-
+ {/* Text Container */} +
+ {/* Top Row: Symbol and Name */} +
+

+ {token.symbol} +

+

+ {token.name} +

+
+ + {/* Bottom Row: Price and Change */} +
+

+ ${token.usdValue} +

- {/* Bottom Row: Price and Change */} -
-

- ${token.usdValue} -

- -
- {/* Triangle Indicator */} - {token.dailyPriceChange !== 0 && ( -
= 0 - ? 'border-b-[6px] border-b-[#5CFF93]' - : 'border-t-[6px] border-t-[#FF366C]' - } opacity-50`} - /> - )} - -

= 0 +

+ {/* Triangle Indicator */} + {token.dailyPriceChange !== 0 && ( +
= 0 + ? 'border-b-[4px] border-b-[#5CFF93]' + : 'border-t-[4px] border-t-[#FF366C]' + } opacity-50`} + /> + )} + +

= 0 ? 'text-[#5CFF93]' : 'text-[#FF366C]' - }`} - > - {Math.abs(token.dailyPriceChange).toFixed(2)}% -

+ }`} + > + {Math.abs(token.dailyPriceChange).toFixed(2)}% +

+
{/* Chevron */} -
+
arrow-down
@@ -852,11 +853,10 @@ export default function Buy(props: BuyProps) { className="flex bg-black ml-2.5 mr-2.5 w-[75px] h-[30px] rounded-[10px] p-0.5 pb-1 pt-0.5" >