From 906ac9e6a5597feff5dc3b5c276cba9812e4d19d Mon Sep 17 00:00:00 2001 From: Connor Barr Date: Thu, 8 Aug 2024 20:08:02 +0100 Subject: [PATCH] feat: more responsive changes for trade tool --- .../web/components/complex/asset-fieldset.tsx | 5 +- packages/web/components/swap-tool/alt.tsx | 8 +- packages/web/components/ui/recap-row.tsx | 2 +- packages/web/modals/review-order.tsx | 73 ++++++++++--------- packages/web/utils/formatter.ts | 1 - 5 files changed, 44 insertions(+), 45 deletions(-) diff --git a/packages/web/components/complex/asset-fieldset.tsx b/packages/web/components/complex/asset-fieldset.tsx index 13b822c1e8..5437a14aeb 100644 --- a/packages/web/components/complex/asset-fieldset.tsx +++ b/packages/web/components/complex/asset-fieldset.tsx @@ -118,12 +118,11 @@ const AssetFieldsetInput = forwardRef< >(({ inputPrefix, inputValue, onInputChange, outputValue, ...rest }, ref) => { const { isMobile } = useWindowSize(Breakpoint.sm); const fontSize = calcFontSize((inputValue ?? "").length, isMobile); - return (
{inputPrefix} diff --git a/packages/web/components/swap-tool/alt.tsx b/packages/web/components/swap-tool/alt.tsx index 091a9dac0d..74fad3acc4 100644 --- a/packages/web/components/swap-tool/alt.tsx +++ b/packages/web/components/swap-tool/alt.tsx @@ -431,9 +431,9 @@ export const AltSwapTool: FunctionComponent = observer(
= observer( maximumSignificantDigits: 6, maxDecimals: 10, notation: "standard", - }).length, + }).replace(/[,\.]/g, "").length, isMobile ) : undefined, @@ -465,7 +465,7 @@ export const AltSwapTool: FunctionComponent = observer( notation: "standard", }) : "0"} - + } /> - {left} + {left} {right}
); diff --git a/packages/web/modals/review-order.tsx b/packages/web/modals/review-order.tsx index 6e4e11a943..467aaa3d32 100644 --- a/packages/web/modals/review-order.tsx +++ b/packages/web/modals/review-order.tsx @@ -20,9 +20,11 @@ import { RecapRow } from "~/components/ui/recap-row"; import { Skeleton } from "~/components/ui/skeleton"; import { EventName, EventPage } from "~/config/analytics-events"; import { + Breakpoint, useAmplitudeAnalytics, useOneClickTradingSession, useTranslation, + useWindowSize, } from "~/hooks"; import { isValidNumericalRawInput } from "~/hooks/input/use-amount-input"; import { useSwap } from "~/hooks/use-swap"; @@ -95,6 +97,7 @@ export function ReviewOrder({ "type", parseAsString.withDefault("market") ); + const { isMobile } = useWindowSize(Breakpoint.sm); const isManualSlippageTooHigh = +manualSlippage > 1; const isManualSlippageTooLow = manualSlippage !== "" && +manualSlippage < 0.1; @@ -173,11 +176,11 @@ export function ReviewOrder({ title={t("swap.gas.gasEstimationError")} body={gasFeeError} > - + {" "} {t("swap.gas.unknown")} @@ -186,7 +189,7 @@ export function ReviewOrder({ ) : ( @@ -194,7 +197,7 @@ export function ReviewOrder({ {gasAmount && gasAmount.toString()} ); - }, [gasAmount, isGasLoading, gasFeeError, t]); + }, [gasAmount, isGasLoading, gasFeeError, isMobile, t]); return ( {orderType === "limit" && tab !== "swap" && ( -
+
{(tab === "buy" && !isBeyondOppositePrice) || @@ -241,7 +244,7 @@ export function ReviewOrder({ /> )}
- + If {baseDenom} price reaches{" "} {limitPriceFiat && formatPretty( @@ -300,29 +303,27 @@ export function ReviewOrder({ /> )}
-

+

{tab === "buy" ? t("limitOrders.pay") : t("limitOrders.sell")}

{inAmountToken && ( - + {formatPretty(inAmountToken)} )}
-
-

- {formatPretty( - inAmountFiat ?? new PricePretty(DEFAULT_VS_CURRENCY, 0), - { - ...getPriceExtendedFormatOptions( - inAmountFiat?.toDec() ?? new Dec(0) - ), - } - )} -

+
+ {formatPretty( + inAmountFiat ?? new PricePretty(DEFAULT_VS_CURRENCY, 0), + { + ...getPriceExtendedFormatOptions( + inAmountFiat?.toDec() ?? new Dec(0) + ), + } + )}
@@ -347,12 +348,12 @@ export function ReviewOrder({ /> )}
-

+

{tab === "sell" ? t("limitOrders.receive") : t("portfolio.buy")}

- + {expectedOutput && ( <> {formatPretty(expectedOutput.toDec(), { @@ -372,14 +373,14 @@ export function ReviewOrder({ {outputDifference && ( {`-${outputDifference}`} )} - + {formatPretty(expectedOutputFiat ?? new Dec(0), { ...getPriceExtendedFormatOptions( expectedOutputFiat?.toDec() ?? new Dec(0) @@ -416,7 +417,7 @@ export function ReviewOrder({ } > -
+
{isBeyondOppositePrice && (
- + {t("limitOrders.errors.tradeMayResultInLossOfValue")} - + {t("limitOrders.lowerSlippageToleranceRecommended")}
@@ -540,10 +541,10 @@ export function ReviewOrder({ />
- + {t("limitOrders.errors.tradeMayNotExecuted")} - + {t("limitOrders.tryHigherSlippage")}
@@ -558,7 +559,7 @@ export function ReviewOrder({ + {outAmountLessSlippage && outFiatAmountLessSlippage && toAsset && ( @@ -587,7 +588,7 @@ export function ReviewOrder({ + {t("transfer.free")} } @@ -614,13 +615,13 @@ export function ReviewOrder({ height={24} className="text-rust-400" /> -
- +
+ {tab === "buy" ? t("limitOrders.aboveMarket.title") : t("limitOrders.belowMarket.title")} - + {tab === "buy" ? t("limitOrders.aboveMarket.description") : t("limitOrders.belowMarket.description")} @@ -634,7 +635,7 @@ export function ReviewOrder({ mode="primary" onClick={confirmAction} disabled={isConfirmationDisabled} - className="body2 !rounded-2xl" + className="body2 sm:caption !rounded-2xl" >
{t("limitOrders.confirm")}
diff --git a/packages/web/utils/formatter.ts b/packages/web/utils/formatter.ts index 7043d8fd29..1531e58375 100644 --- a/packages/web/utils/formatter.ts +++ b/packages/web/utils/formatter.ts @@ -389,7 +389,6 @@ export function calcFontSize(numChars: number, isMobile: boolean): string { 16: "28px", 33: "24px", }; - for (const [key, value] of Object.entries(sizeMapping)) { if (numChars <= Number(key)) { return value;