Skip to content

Commit

Permalink
fix(widgets): correctly position the arrows (#3083)
Browse files Browse the repository at this point in the history
* correctly position the arrows

* update reverse button css and remove popover logic

* px->em
  • Loading branch information
JFrankfurt authored Jan 11, 2022
1 parent c9bc166 commit 4f89636
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
17 changes: 8 additions & 9 deletions src/lib/components/Swap/Input.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Trans } from '@lingui/macro'
import { CurrencyAmount, Token } from '@uniswap/sdk-core'
import { useAtomValue } from 'jotai/utils'
import { inputAtom, useUpdateInputToken, useUpdateInputValue } from 'lib/state/swap'
import styled, { ThemedText } from 'lib/theme'
import { ReactNode } from 'react'

import Column from '../Column'
import Row from '../Row'
import TokenImg from '../TokenImg'
import TokenInput from './TokenInput'

const mockBalance = 123.45
const mockToken = new Token(1, '0x8b3192f5eebd8579568a2ed41e6feb402f93f73f', 9, 'STM', 'Saitama')
const mockCurrencyAmount = CurrencyAmount.fromRawAmount(mockToken, '134108514895957704114061')

const InputColumn = styled(Column)<{ approved?: boolean }>`
margin: 0.75em;
Expand All @@ -23,14 +24,13 @@ const InputColumn = styled(Column)<{ approved?: boolean }>`

interface InputProps {
disabled?: boolean
children: ReactNode
}

export default function Input({ disabled, children }: InputProps) {
export default function Input({ disabled }: InputProps) {
const input = useAtomValue(inputAtom)
const setValue = useUpdateInputValue(inputAtom)
const setToken = useUpdateInputToken(inputAtom)
const balance = mockBalance
const balance = mockCurrencyAmount

return (
<InputColumn gap={0.5} approved={input.approved !== false}>
Expand All @@ -42,23 +42,22 @@ export default function Input({ disabled, children }: InputProps) {
<TokenInput
input={input}
disabled={disabled}
onMax={balance ? () => setValue(balance) : undefined}
onMax={balance ? () => setValue(1234) : undefined}
onChangeInput={setValue}
onChangeToken={setToken}
>
<ThemedText.Body2 color="secondary">
<Row>
{input.usdc ? `~ $${input.usdc.toLocaleString('en')}` : '-'}
{balance && (
<ThemedText.Body2 color={input.value && input.value > balance ? 'error' : undefined}>
Balance: <span style={{ userSelect: 'text' }}>{balance}</span>
<ThemedText.Body2 color={input.value && balance.lessThan(input.value) ? 'error' : undefined}>
Balance: <span style={{ userSelect: 'text' }}>{balance.toExact()}</span>
</ThemedText.Body2>
)}
</Row>
</ThemedText.Body2>
</TokenInput>
<Row />
{children}
</InputColumn>
)
}
5 changes: 3 additions & 2 deletions src/lib/components/Swap/ReverseButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import Button from '../Button'
import Row from '../Row'

const ReverseRow = styled(Row)`
bottom: -1.5em;
left: 50%;
position: absolute;
width: 100%;
top: 7.45em;
transform: translateX(-50%);
z-index: ${Layer.OVERLAY};
`

Expand Down
5 changes: 2 additions & 3 deletions src/lib/components/Swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ export default function Swap() {
</Header>
<div ref={setBoundary}>
<BoundaryProvider value={boundary}>
<Input disabled={!active}>
<ReverseButton disabled={!active} />
</Input>
<Input disabled={!active} />
<ReverseButton disabled={!active} />
<Output disabled={!active}>
<Toolbar disabled={!active} />
<SwapButton />
Expand Down

0 comments on commit 4f89636

Please sign in to comment.