diff --git a/src/components/trade/_shared/TradeInputSelector.tsx b/src/components/trade/_shared/TradeInputSelector.tsx deleted file mode 100644 index 02f9aca5c..000000000 --- a/src/components/trade/_shared/TradeInputSelector.tsx +++ /dev/null @@ -1,175 +0,0 @@ -import Image from 'next/image' -import { colors, useColorStyles } from '@/lib/styles/colors' - -import { ChevronDownIcon } from '@chakra-ui/icons' -import { Box, Flex, Input, Text } from '@chakra-ui/react' - -import { Token } from '@/constants/tokens' - -interface InputSelectorConfig { - isDarkMode: boolean - isNarrowVersion: boolean - isInputDisabled?: boolean - isSelectorDisabled?: boolean - isReadOnly?: boolean - showMaxLabel: boolean -} - -const TradeInputSelector = (props: { - config: InputSelectorConfig - formattedFiat: string - // Used from swap to show price impact behind fiat value - priceImpact?: { priceImpact: string; colorCoding: string } - selectedToken: Token - selectedTokenAmount: string - selectedTokenBalance: string - onClickBalance: () => void - onSelectedToken: (symbol: string) => void - onChangeInput?: (token: Token, input: string) => void -}) => { - const { styles } = useColorStyles() - const { config, selectedToken, selectedTokenAmount, selectedTokenBalance } = - props - const borderColor = styles.border - const borderRadius = 16 - const selectedTokenSymbol = selectedToken.symbol - - const onChangeInput = (amount: string) => { - if ( - props.onChangeInput === undefined || - config.isInputDisabled || - config.isSelectorDisabled || - config.isReadOnly - ) - return - props.onChangeInput(selectedToken, amount) - } - - return ( - - - - { - onChangeInput(event.target.value) - }} - /> - props.onSelectedToken(selectedTokenSymbol)} - selectedTokenImage={selectedToken.image} - selectedTokenSymbol={selectedTokenSymbol} - /> - - - - - {props.formattedFiat} - - {props.priceImpact && ( - -  {props.priceImpact.priceImpact} - - )} - - - - - - ) -} - -type BalanceProps = { - balance: string - onClick: () => void - showMaxLabel: boolean -} - -const Balance = ({ balance, onClick, showMaxLabel }: BalanceProps) => ( - - - Balance: {balance} - - {showMaxLabel && ( - - - MAX - - - )} - -) - -type SelectorProps = { - onClick: () => void - selectedTokenImage: string - selectedTokenSymbol: string -} - -const SelectorButton = ({ - onClick, - selectedTokenImage, - selectedTokenSymbol, -}: SelectorProps) => ( - - - {`${selectedTokenSymbol} - - - {selectedTokenSymbol} - - - -) - -export default TradeInputSelector diff --git a/src/components/trade/flashmint/DirectIssuance.tsx b/src/components/trade/flashmint/DirectIssuance.tsx index 001fcaa39..0324b4618 100644 --- a/src/components/trade/flashmint/DirectIssuance.tsx +++ b/src/components/trade/flashmint/DirectIssuance.tsx @@ -10,7 +10,7 @@ import { Box, Flex, Image, Text } from '@chakra-ui/react' import { Token } from '@/constants/tokens' -import TradeInputSelector from '../_shared/TradeInputSelector' +import { TradeInputSelector } from '../trade-input-selector' type DirectIssuanceProps = { indexToken: Token @@ -43,7 +43,6 @@ const DirectIssuance = ({ inputOutputTokenFiatFormatted, isIssue, isMintable, - isNarrow, onClickBalance, onChangeBuyTokenAmount, onSelectIndexToken, @@ -74,22 +73,23 @@ const DirectIssuance = ({ paddingTop='16px' > onSelectIndexToken()} + onSelectToken={onSelectIndexToken} /> {isIssue diff --git a/src/components/trade/swap/index.tsx b/src/components/trade/swap/index.tsx index ae802b3aa..3a343da45 100644 --- a/src/components/trade/swap/index.tsx +++ b/src/components/trade/swap/index.tsx @@ -35,12 +35,13 @@ import { getTradeInfoData0x, shouldShowWarningSign, } from '../_shared/QuickTradeFormatter' -import TradeInputSelector from '../_shared/TradeInputSelector' import { getSelectTokenListItems, SelectTokenModal, } from '../_shared/SelectTokenModal' +import { TradeInputSelector } from '../trade-input-selector' + import { BetterQuoteState, BetterQuoteView } from './BetterQuoteView' import { TradeDetails } from './trade-details' import { TradeInfoItem } from './trade-details/trade-info' @@ -472,52 +473,51 @@ const QuickTrade = (props: QuickTradeProps) => { return ( - + { + onSelectToken={() => { if (inputTokenItems.length > 1) onOpenSelectInputToken() }} /> - + } onClick={onSwitchTokens} /> { + onSelectToken={() => { if (outputTokenItems.length > 1) onOpenSelectOutputToken() }} />