Skip to content

Commit

Permalink
fix: propagate field in input (#271)
Browse files Browse the repository at this point in the history
* fix: propagate field in input

* refactor: FieldWrapper
  • Loading branch information
zzmp authored Oct 12, 2022
1 parent 5a542fc commit a78654d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/components/Swap/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,20 @@ export function useFormattedFieldAmount({
}, [currencyAmount, fieldAmount])
}

interface InputWrapperProps {
interface FieldWrapperProps {
field: Field
impact?: PriceImpact
maxAmount?: string
isSufficientBalance?: boolean
}

export function InputWrapper({
export function FieldWrapper({
field,
impact,
maxAmount,
isSufficientBalance,
className,
}: InputWrapperProps & { className?: string }) {
}: FieldWrapperProps & { className?: string }) {
const {
[field]: { balance, amount: currencyAmount, usdc },
error,
Expand All @@ -118,7 +118,7 @@ export function InputWrapper({

const isDisabled = error !== undefined
const isRouteLoading = isDisabled || tradeState === TradeState.LOADING
const isDependentField = !useIsSwapFieldIndependent(Field.INPUT)
const isDependentField = !useIsSwapFieldIndependent(field)
const isLoading = isRouteLoading && isDependentField

const isWrap = useIsWrap()
Expand All @@ -141,7 +141,7 @@ export function InputWrapper({
amount={formattedAmount}
currency={currency}
disabled={isDisabled}
field={Field.INPUT}
field={field}
onChangeInput={updateAmount}
onChangeCurrency={updateCurrency}
loading={isLoading}
Expand Down Expand Up @@ -192,5 +192,5 @@ export default function Input() {
return max.toExact()
}, [balance, currencyAmount])

return <InputWrapper field={Field.INPUT} isSufficientBalance={isSufficientBalance} maxAmount={maxAmount} />
return <FieldWrapper field={Field.INPUT} isSufficientBalance={isSufficientBalance} maxAmount={maxAmount} />
}
4 changes: 2 additions & 2 deletions src/components/Swap/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { Field } from 'state/swap'
import styled from 'styled-components/macro'
import { DynamicThemeProvider } from 'theme'

import { InputWrapper } from './Input'
import { FieldWrapper } from './Input'

export const colorAtom = atom<string | undefined>(undefined)

const OutputWrapper = styled(InputWrapper)<{ hasColor?: boolean | null }>`
const OutputWrapper = styled(FieldWrapper)<{ hasColor?: boolean | null }>`
border-bottom: 1px solid ${({ theme }) => theme.container};
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
Expand Down

1 comment on commit a78654d

@vercel
Copy link

@vercel vercel bot commented on a78654d Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

widgets – ./

widgets-seven-tau.vercel.app
widgets-uniswap.vercel.app
widgets-git-main-uniswap.vercel.app

Please sign in to comment.