Skip to content

Commit d74e61b

Browse files
committed
Fix Swap Fees layout in Pay UI drawer (#4390)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on fixing the Swap Fees layout in the fees drawer in the pay UI. ### Detailed summary - Updated `SwapFees` component layout in `Fees.tsx` to align items to the left - Removed `align` prop from `SwapFees` component in `BuyScreen.tsx` - Created `SwapFeesRightAligned` component for right-aligned fees display in `ConfirmationScreen.tsx` > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent d8f55ef commit d74e61b

File tree

4 files changed

+48
-13
lines changed

4 files changed

+48
-13
lines changed

.changeset/honest-poems-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix Swap Fees layout in fees drawer in pay UI

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/BuyScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ function SwapScreenContent(props: {
11381138
Fees
11391139
</Text>
11401140
<Spacer y="lg" />
1141-
<SwapFees quote={quoteQuery.data} align="left" />
1141+
<SwapFees quote={quoteQuery.data} />
11421142
</div>
11431143
)}
11441144
</Drawer>

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/ConfirmationScreen.tsx

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import type { ERC20OrNativeToken } from "../../nativeToken.js";
2727
import { PayTokenIcon } from "../PayTokenIcon.js";
2828
import { Step } from "../Stepper.js";
2929
import type { PayerInfo } from "../types.js";
30-
import { SwapFees } from "./Fees.js";
3130
import { formatSeconds } from "./formatSeconds.js";
3231
import { addPendingTx } from "./pendingSwapTx.js";
3332

@@ -111,7 +110,7 @@ export function SwapConfirmationScreen(props: {
111110

112111
{/* Fees */}
113112
<ConfirmItem label="Fees">
114-
<SwapFees quote={props.quote} align="right" />
113+
<SwapFeesRightAligned quote={props.quote} />
115114
</ConfirmItem>
116115

117116
{/* Time */}
@@ -329,3 +328,39 @@ function ConfirmItem(props: {
329328
</>
330329
);
331330
}
331+
332+
/**
333+
* @internal
334+
*/
335+
export function SwapFeesRightAligned(props: {
336+
quote: BuyWithCryptoQuote;
337+
}) {
338+
return (
339+
<Container
340+
flex="column"
341+
gap="xs"
342+
style={{
343+
alignItems: "flex-end",
344+
}}
345+
>
346+
{props.quote.processingFees.map((fee) => {
347+
const feeAmount = formatNumber(Number(fee.amount), 6);
348+
return (
349+
<Container
350+
key={`${fee.token.chainId}_${fee.token.tokenAddress}_${feeAmount}`}
351+
flex="row"
352+
gap="xxs"
353+
>
354+
<Text color="primaryText" size="sm">
355+
{feeAmount === 0 ? "~" : ""}
356+
{feeAmount} {fee.token.symbol}
357+
</Text>
358+
<Text color="secondaryText" size="sm">
359+
(${(fee.amountUSDCents / 100).toFixed(2)})
360+
</Text>
361+
</Container>
362+
);
363+
})}
364+
</Container>
365+
);
366+
}

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/swap/Fees.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,29 @@ import { Text } from "../../../../components/text.js";
1010
*/
1111
export function SwapFees(props: {
1212
quote: BuyWithCryptoQuote;
13-
align: "left" | "right";
1413
}) {
1514
return (
1615
<Container
1716
flex="column"
1817
gap="xs"
1918
style={{
20-
alignItems: props.align === "right" ? "flex-end" : "flex-start",
19+
alignItems: "flex-start",
2120
}}
2221
>
2322
{props.quote.processingFees.map((fee) => {
2423
const feeAmount = formatNumber(Number(fee.amount), 6);
2524
return (
2625
<Container
2726
key={`${fee.token.chainId}_${fee.token.tokenAddress}_${feeAmount}`}
28-
flex="column"
27+
flex="row"
2928
gap="xxs"
3029
>
31-
<Text color="primaryText" size="sm" style={{ textAlign: "right" }}>
30+
<Text color="primaryText" size="sm">
3231
{feeAmount === 0 ? "~" : ""}
3332
{feeAmount} {fee.token.symbol}
3433
</Text>
35-
<Text
36-
color="secondaryText"
37-
size="xs"
38-
style={{ textAlign: "right" }}
39-
>
40-
${(fee.amountUSDCents / 100).toFixed(2)}
34+
<Text color="secondaryText" size="sm">
35+
(${(fee.amountUSDCents / 100).toFixed(2)})
4136
</Text>
4237
</Container>
4338
);

0 commit comments

Comments
 (0)