From f0371e28ea5e13efd0b8d52e54cb6d764544a423 Mon Sep 17 00:00:00 2001 From: eddie <66155195+just-toby@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:48:17 -0700 Subject: [PATCH] feat: add text tooltips to price change and expando fields (#566) --- src/components/Swap/Input.tsx | 5 ++++- src/components/Swap/PriceImpactRow.tsx | 7 ++++--- src/components/Swap/Toolbar/ToolbarTradeSummary.tsx | 12 ++++++------ src/components/Swap/Toolbar/index.tsx | 12 +++++++----- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/components/Swap/Input.tsx b/src/components/Swap/Input.tsx index 838b9a59b..b55ab199a 100644 --- a/src/components/Swap/Input.tsx +++ b/src/components/Swap/Input.tsx @@ -164,7 +164,10 @@ export function FieldWrapper({ {usdc && `${formatCurrencyAmount(usdc, NumberType.FiatTokenQuantity)}`} - + {balance && ( diff --git a/src/components/Swap/PriceImpactRow.tsx b/src/components/Swap/PriceImpactRow.tsx index bb0a3570c..61330d637 100644 --- a/src/components/Swap/PriceImpactRow.tsx +++ b/src/components/Swap/PriceImpactRow.tsx @@ -1,24 +1,25 @@ import { Trans } from '@lingui/macro' import { formatPriceImpact } from '@uniswap/conedison/format' import Row from 'components/Row' -import Tooltip, { SmallToolTipBody } from 'components/Tooltip' +import Tooltip, { SmallToolTipBody, TooltipText } from 'components/Tooltip' import { PriceImpact } from 'hooks/usePriceImpact' import { AlertTriangle } from 'icons' import { ThemedText } from 'theme' interface PriceImpactProps { impact: PriceImpact | undefined | null + tooltipText?: string reverse?: boolean } -export function PriceImpactRow({ impact, reverse }: PriceImpactProps) { +export function PriceImpactRow({ impact, reverse, tooltipText }: PriceImpactProps) { if (!impact) { return null } return ( - ({formatPriceImpact(impact?.percent)}) + {tooltipText} {impact?.warning && ( diff --git a/src/components/Swap/Toolbar/ToolbarTradeSummary.tsx b/src/components/Swap/Toolbar/ToolbarTradeSummary.tsx index 65095c9f4..7c409852a 100644 --- a/src/components/Swap/Toolbar/ToolbarTradeSummary.tsx +++ b/src/components/Swap/Toolbar/ToolbarTradeSummary.tsx @@ -1,6 +1,6 @@ import Column from 'components/Column' import Row from 'components/Row' -import Tooltip from 'components/Tooltip' +import Tooltip, { TooltipText } from 'components/Tooltip' import { Icon } from 'icons' import { ReactNode } from 'react' import styled from 'styled-components/macro' @@ -31,7 +31,6 @@ export interface SummaryRowProps { color?: Color nameTooltip?: { content: ReactNode - icon: Icon } valueTooltip?: { content: ReactNode @@ -44,10 +43,11 @@ function SummaryRow({ name, value, color, nameTooltip, valueTooltip }: SummaryRo {nameTooltip ? ( - {name} - - {nameTooltip.content} - + + + {nameTooltip.content} + + ) : ( {name} diff --git a/src/components/Swap/Toolbar/index.tsx b/src/components/Swap/Toolbar/index.tsx index 96bb9f4f8..d97f6d52e 100644 --- a/src/components/Swap/Toolbar/index.tsx +++ b/src/components/Swap/Toolbar/index.tsx @@ -5,14 +5,14 @@ import Column from 'components/Column' import Expando from 'components/Expando' import { ChainError, useIsAmountPopulated, useSwapInfo } from 'hooks/swap' import { useIsWrap } from 'hooks/swap/useWrapCallback' -import { AlertTriangle, Info } from 'icons' +import { AlertTriangle } from 'icons' import { memo, ReactNode, useCallback, useContext, useMemo } from 'react' import { TradeState } from 'state/routing/types' import { Field } from 'state/swap' import styled from 'styled-components/macro' import Row from '../../Row' -import SwapInputOutputEstimate, { getEstimateMessage } from '../Summary/Estimate' +import { getEstimateMessage } from '../Summary/Estimate' import SwapActionButton from '../SwapActionButton' import * as Caption from './Caption' import { Context as ToolbarContext, Provider as ToolbarContextProvider } from './ToolbarContext' @@ -113,15 +113,17 @@ function CaptionRow() { const tradeSummaryRows: SummaryRowProps[] = useMemo(() => { const currencySymbol = trade?.outputAmount?.currency.symbol ?? '' - const { descriptor, value } = getEstimateMessage(trade, slippage) + const { descriptor, value, estimateMessage } = getEstimateMessage(trade, slippage) const rows: SummaryRowProps[] = [ { name: t`Network fee`, + nameTooltip: { content: t`The fee paid to miners to process your transaction. This must be paid in ETH.` }, value: gasUseEstimateUSD ? `~${formatCurrencyAmount(gasUseEstimateUSD, NumberType.FiatGasPrice)}` : '-', }, { color: impact?.warning, name: t`Price impact`, + nameTooltip: { content: t`The impact your trade has on the market price of this pool.` }, value: impact?.percent ? formatPriceImpact(impact.percent) : '-', valueTooltip: impact?.warning ? { @@ -134,14 +136,14 @@ function CaptionRow() { // min/max output/input after slippage name:
{descriptor}
, value, + nameTooltip: { content: estimateMessage }, }, { name: t`Expected output`, value: trade ? `${formatCurrencyAmount(trade?.outputAmount)} ${currencySymbol}` : '-', nameTooltip: trade ? { - icon: Info, - content: , + content: t`The amount you expect to receive at the current market price. You may receive less or more if the market price changes while your transaction is pending.`, } : undefined, },