Commit b2a30b9b authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: style nits (#3352)

* fix: prefix output usdc with $

* fix: space in output estimate warning

* fix: reset slippage warnings

* fix: display link icon for etherscan
parent dfad7b89
import { SupportedChainId } from 'constants/chains' import { SupportedChainId } from 'constants/chains'
import useActiveWeb3React from 'lib/hooks/useActiveWeb3React' import useActiveWeb3React from 'lib/hooks/useActiveWeb3React'
import { Link } from 'lib/icons'
import styled, { Color } from 'lib/theme' import styled, { Color } from 'lib/theme'
import { ReactNode, useMemo } from 'react' import { ReactNode, useMemo } from 'react'
import { ExplorerDataType, getExplorerLink } from 'utils/getExplorerLink' import { ExplorerDataType, getExplorerLink } from 'utils/getExplorerLink'
import ExternalLink from './ExternalLink' import ExternalLink from './ExternalLink'
import Row from './Row'
const Link = styled(ExternalLink)<{ color: Color }>` const StyledExternalLink = styled(ExternalLink)<{ color: Color }>`
color: ${({ theme, color }) => theme[color]}; color: ${({ theme, color }) => theme[color]};
text-decoration: none; text-decoration: none;
` `
...@@ -25,8 +27,10 @@ export default function EtherscanLink({ data, type, color = 'currentColor', chil ...@@ -25,8 +27,10 @@ export default function EtherscanLink({ data, type, color = 'currentColor', chil
[chainId, data, type] [chainId, data, type]
) )
return ( return (
<Link href={url} color={color} target="_blank"> <StyledExternalLink href={url} color={color} target="_blank">
{children} <Row gap={0.25}>
</Link> {children} <Link />
</Row>
</StyledExternalLink>
) )
} }
...@@ -97,7 +97,7 @@ export default function Output({ disabled, focused, children }: PropsWithChildre ...@@ -97,7 +97,7 @@ export default function Output({ disabled, focused, children }: PropsWithChildre
<ThemedText.Body2 color="secondary"> <ThemedText.Body2 color="secondary">
<Row> <Row>
<LoadingRow gap={0.5} $loading={isLoading}> <LoadingRow gap={0.5} $loading={isLoading}>
{outputUSDC?.toFixed(2)} {priceImpact} {outputUSDC ? `$${outputUSDC.toFixed(2)}` : '-'} {priceImpact}
</LoadingRow> </LoadingRow>
{balance && ( {balance && (
<Balance focused={focused}> <Balance focused={focused}>
......
...@@ -6,7 +6,7 @@ import { getSlippageWarning, toPercent } from 'lib/hooks/useAllowedSlippage' ...@@ -6,7 +6,7 @@ import { getSlippageWarning, toPercent } from 'lib/hooks/useAllowedSlippage'
import { AlertTriangle, Check, Icon, LargeIcon, XOctagon } from 'lib/icons' import { AlertTriangle, Check, Icon, LargeIcon, XOctagon } from 'lib/icons'
import { autoSlippageAtom, maxSlippageAtom } from 'lib/state/settings' import { autoSlippageAtom, maxSlippageAtom } from 'lib/state/settings'
import styled, { ThemedText } from 'lib/theme' import styled, { ThemedText } from 'lib/theme'
import { forwardRef, memo, ReactNode, useCallback, useMemo, useRef, useState } from 'react' import { forwardRef, memo, ReactNode, useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { BaseButton, TextButton } from '../../Button' import { BaseButton, TextButton } from '../../Button'
import Column from '../../Column' import Column from '../../Column'
...@@ -88,7 +88,6 @@ export default function MaxSlippageSelect() { ...@@ -88,7 +88,6 @@ export default function MaxSlippageSelect() {
const [autoSlippage, setAutoSlippage] = useAtom(autoSlippageAtom) const [autoSlippage, setAutoSlippage] = useAtom(autoSlippageAtom)
const [maxSlippage, setMaxSlippage] = useAtom(maxSlippageAtom) const [maxSlippage, setMaxSlippage] = useAtom(maxSlippageAtom)
const maxSlippageInput = useMemo(() => maxSlippage?.toString() || '', [maxSlippage]) const maxSlippageInput = useMemo(() => maxSlippage?.toString() || '', [maxSlippage])
const [warning, setWarning] = useState<'warning' | 'error' | undefined>(getSlippageWarning(toPercent(maxSlippage)))
const option = useRef<HTMLButtonElement>(null) const option = useRef<HTMLButtonElement>(null)
const showTooltip = useTooltip(option.current) const showTooltip = useTooltip(option.current)
...@@ -96,20 +95,27 @@ export default function MaxSlippageSelect() { ...@@ -96,20 +95,27 @@ export default function MaxSlippageSelect() {
const input = useRef<HTMLInputElement>(null) const input = useRef<HTMLInputElement>(null)
const focus = useCallback(() => input.current?.focus(), [input]) const focus = useCallback(() => input.current?.focus(), [input])
const [warning, setWarning] = useState<'warning' | 'error' | undefined>(getSlippageWarning(toPercent(maxSlippage)))
useEffect(() => {
setWarning(getSlippageWarning(toPercent(maxSlippage)))
}, [maxSlippage])
const onInputSelect = useCallback(() => {
focus()
const percent = toPercent(maxSlippage)
const warning = getSlippageWarning(percent)
setAutoSlippage(!percent || warning === 'error')
}, [focus, maxSlippage, setAutoSlippage])
const processValue = useCallback( const processValue = useCallback(
(value: number | undefined) => { (value: number | undefined) => {
const percent = toPercent(value) const percent = toPercent(value)
const warning = getSlippageWarning(percent) const warning = getSlippageWarning(percent)
setWarning(warning)
setMaxSlippage(value) setMaxSlippage(value)
setAutoSlippage(!percent || warning === 'error') setAutoSlippage(!percent || warning === 'error')
}, },
[setAutoSlippage, setMaxSlippage] [setAutoSlippage, setMaxSlippage]
) )
const onInputSelect = useCallback(() => {
focus()
processValue(maxSlippage)
}, [focus, maxSlippage, processValue])
return ( return (
<Column gap={0.75}> <Column gap={0.75}>
......
...@@ -158,7 +158,7 @@ export function SummaryDialog({ trade, allowedSlippage, onConfirm }: SummaryDial ...@@ -158,7 +158,7 @@ export function SummaryDialog({ trade, allowedSlippage, onConfirm }: SummaryDial
</Column> </Column>
</DetailsColumn> </DetailsColumn>
<Estimate color="secondary"> <Estimate color="secondary">
<Trans>Output is estimated.</Trans> <Trans>Output is estimated.</Trans>{' '}
{tradeType === TradeType.EXACT_INPUT && ( {tradeType === TradeType.EXACT_INPUT && (
<Trans> <Trans>
You will receive at least{' '} You will receive at least{' '}
......
...@@ -13,7 +13,7 @@ import { useAddTransaction } from 'lib/hooks/transactions' ...@@ -13,7 +13,7 @@ import { useAddTransaction } from 'lib/hooks/transactions'
import { usePendingApproval } from 'lib/hooks/transactions' import { usePendingApproval } from 'lib/hooks/transactions'
import useActiveWeb3React from 'lib/hooks/useActiveWeb3React' import useActiveWeb3React from 'lib/hooks/useActiveWeb3React'
import useTransactionDeadline from 'lib/hooks/useTransactionDeadline' import useTransactionDeadline from 'lib/hooks/useTransactionDeadline'
import { Link, Spinner } from 'lib/icons' import { Spinner } from 'lib/icons'
import { displayTxHashAtom, Field } from 'lib/state/swap' import { displayTxHashAtom, Field } from 'lib/state/swap'
import { TransactionType } from 'lib/state/transactions' import { TransactionType } from 'lib/state/transactions'
import { useTheme } from 'lib/theme' import { useTheme } from 'lib/theme'
...@@ -24,7 +24,6 @@ import { ExplorerDataType } from 'utils/getExplorerLink' ...@@ -24,7 +24,6 @@ import { ExplorerDataType } from 'utils/getExplorerLink'
import ActionButton, { ActionButtonProps } from '../ActionButton' import ActionButton, { ActionButtonProps } from '../ActionButton'
import Dialog from '../Dialog' import Dialog from '../Dialog'
import EtherscanLink from '../EtherscanLink' import EtherscanLink from '../EtherscanLink'
import Row from '../Row'
import { SummaryDialog } from './Summary' import { SummaryDialog } from './Summary'
interface SwapButtonProps { interface SwapButtonProps {
...@@ -100,11 +99,7 @@ export default function SwapButton({ disabled }: SwapButtonProps) { ...@@ -100,11 +99,7 @@ export default function SwapButton({ disabled }: SwapButtonProps) {
action: { action: {
message: ( message: (
<EtherscanLink type={ExplorerDataType.TRANSACTION} data={approvalHash}> <EtherscanLink type={ExplorerDataType.TRANSACTION} data={approvalHash}>
<Row gap={0.25}> <Trans>Approval pending</Trans>
<Trans>
Approval pending <Link />
</Trans>
</Row>
</EtherscanLink> </EtherscanLink>
), ),
icon: Spinner, icon: Spinner,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment