Skip to content

Commit

Permalink
Implement Swap Form switch assets button for #450 (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
soulBit authored Mar 19, 2021
1 parent 4d8566f commit 61b5e1d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
31 changes: 25 additions & 6 deletions src/app/containers/SwapTradeForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
import { Icon } from '@blueprintjs/core';
import { Icon, Tooltip } from '@blueprintjs/core';
import { FieldGroup } from '../../components/FieldGroup';
import { FormSelect } from '../../components/FormSelect';
import { AmountField } from '../AmountField';
Expand Down Expand Up @@ -48,8 +48,8 @@ export function SwapTradeForm() {
const isConnected = useCanInteract();

const [amount, setAmount] = useState('');
const [sourceToken, setSourceToken] = useState(Asset.DOC);
const [targetToken, setTargetToken] = useState(Asset.BTC);
const [sourceToken, setSourceToken] = useState(Asset.BTC);
const [targetToken, setTargetToken] = useState(Asset.DOC);
const [sourceOptions, setSourceOptions] = useState<any[]>([]);
const [targetOptions, setTargetOptions] = useState<any[]>([]);

Expand Down Expand Up @@ -122,7 +122,6 @@ export function SwapTradeForm() {
);

const { value: tokenBalance } = useAssetBalanceOf(sourceToken);

const { state } = useLocation();

useEffect(() => {
Expand Down Expand Up @@ -161,8 +160,28 @@ export function SwapTradeForm() {
</div>
</FieldGroup>

<div className="d-flex justify-content-center align-items-center py-2">
<Icon icon="arrow-down" />
<div className="row">
<div className="col-8">
<div className="d-flex h-100 w-100 justify-content-center align-items-center">
<Icon icon="arrow-down" />
</div>
</div>
<div className="col-4">
<div className="d-flex h-100 w-100 justify-content-center align-items-center">
<div
className="cursor-pointer p-1"
onClick={e => {
setTargetToken(sourceToken);
setSourceToken(targetToken);
setAmount('0');
}}
>
<Tooltip content={t(s.buttons.switchAssets)}>
<Icon icon="double-caret-vertical" />
</Tooltip>
</div>
</div>
</div>
</div>

<FieldGroup label={t(s.fields.receive)} labelColor={color}>
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
"receive": "You receive"
},
"buttons": {
"submit": "Place Trade"
"submit": "Place Trade",
"switchAssets": "Switch Assets"
}
},
"amountField": {
Expand Down

1 comment on commit 61b5e1d

@vercel
Copy link

@vercel vercel bot commented on 61b5e1d Mar 19, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.