-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(trading): add swap and cross chain deposit standalone pages (#6573
- Loading branch information
1 parent
1f8b38f
commit d3e4fb6
Showing
16 changed files
with
225 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,106 @@ | ||
import { useT } from '../../lib/use-t'; | ||
import { Links } from '../../lib/links'; | ||
import { Links, Routes } from '../../lib/links'; | ||
import classNames from 'classnames'; | ||
import { NavLink, Outlet } from 'react-router-dom'; | ||
import { NavLink, Outlet, useLocation, useNavigate } from 'react-router-dom'; | ||
import { | ||
TradingDropdown, | ||
TradingDropdownContent, | ||
TradingDropdownItem, | ||
TradingDropdownTrigger, | ||
VegaIcon, | ||
VegaIconNames, | ||
} from '@vegaprotocol/ui-toolkit'; | ||
|
||
export const Assets = () => { | ||
const navigate = useNavigate(); | ||
const t = useT(); | ||
|
||
const title = useTitle(); | ||
|
||
const linkClasses = ({ isActive }: { isActive: boolean }) => { | ||
return classNames('border-b-2 border-transparent', { | ||
'border-vega-yellow': isActive, | ||
}); | ||
}; | ||
|
||
return ( | ||
<div className="max-w-[500px] px-4 mx-auto my-8"> | ||
<nav className="flex mb-6 text-lg gap-4"> | ||
<div className="max-w-[600px] p-4 mx-auto"> | ||
<div className="lg:hidden py-2"> | ||
<TradingDropdown | ||
trigger={ | ||
<TradingDropdownTrigger> | ||
<button className="flex items-center gap-2"> | ||
{title} <VegaIcon name={VegaIconNames.CHEVRON_DOWN} /> | ||
</button> | ||
</TradingDropdownTrigger> | ||
} | ||
> | ||
<TradingDropdownContent> | ||
<TradingDropdownItem onClick={() => navigate(Links.DEPOSIT())}> | ||
{t('Deposit')} | ||
</TradingDropdownItem> | ||
<TradingDropdownItem | ||
onClick={() => navigate(Links.DEPOSIT_CROSS_CHAIN())} | ||
> | ||
{t('Deposit (cross chain)')} | ||
</TradingDropdownItem> | ||
<TradingDropdownItem onClick={() => navigate(Links.WITHDRAW())}> | ||
{t('Withdraw')} | ||
</TradingDropdownItem> | ||
<TradingDropdownItem onClick={() => navigate(Links.TRANSFER())}> | ||
{t('Transfer')} | ||
</TradingDropdownItem> | ||
<TradingDropdownItem onClick={() => navigate(Links.SWAP())}> | ||
{t('Swap')} | ||
</TradingDropdownItem> | ||
</TradingDropdownContent> | ||
</TradingDropdown> | ||
</div> | ||
<nav className="hidden lg:flex mb-6 text-lg gap-4"> | ||
<NavLink to={Links.DEPOSIT()} className={linkClasses}> | ||
{t('Deposit')} | ||
</NavLink> | ||
<NavLink to={Links.DEPOSIT_CROSS_CHAIN()} className={linkClasses}> | ||
{t('Deposit (cross chain)')} | ||
</NavLink> | ||
<NavLink to={Links.WITHDRAW()} className={linkClasses}> | ||
{t('Withdraw')} | ||
</NavLink> | ||
<NavLink to={Links.TRANSFER()} className={linkClasses}> | ||
{t('Transfer')} | ||
</NavLink> | ||
<NavLink to={Links.SWAP()} className={linkClasses}> | ||
{t('Swap')} | ||
</NavLink> | ||
</nav> | ||
<div className="pt-4 border-t md:p-6 md:border md:rounded-xl border-default"> | ||
<Outlet /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const useTitle = () => { | ||
const t = useT(); | ||
const { pathname } = useLocation(); | ||
|
||
if (pathname === Routes.DEPOSIT) { | ||
return t('Deposit'); | ||
} | ||
|
||
if (pathname === Routes.DEPOSIT_CROSS_CHAIN) { | ||
return t('Deposit (cross chain)'); | ||
} | ||
|
||
if (pathname === Routes.WITHDRAW) { | ||
return t('Withdraw'); | ||
} | ||
|
||
if (pathname === Routes.TRANSFER) { | ||
return t('Transfer'); | ||
} | ||
|
||
if (pathname === Routes.SWAP) { | ||
return t('Swap'); | ||
} | ||
}; |
11 changes: 11 additions & 0 deletions
11
apps/trading/client-pages/deposit-cross-chain/deposit-cross-chain.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { SquidContainer } from '../../components/squid-container'; | ||
|
||
export const DepositCrossChain = () => { | ||
return ( | ||
<div className="flex flex-col gap-6 items-center"> | ||
<div> | ||
<SquidContainer /> | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { DepositCrossChain } from './deposit-cross-chain'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Swap } from './swap'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { SwapContainer } from '../../components/swap'; | ||
|
||
export const Swap = () => { | ||
return ( | ||
<div className="flex flex-col gap-6"> | ||
<SwapContainer /> | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,40 @@ | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { TransferContainer } from '@vegaprotocol/accounts'; | ||
import { GetStarted } from '../../components/welcome-dialog/get-started'; | ||
import { useDialogStore, useVegaWallet } from '@vegaprotocol/wallet-react'; | ||
import { ExternalLink, Intent, Notification } from '@vegaprotocol/ui-toolkit'; | ||
import { useT } from '../../lib/use-t'; | ||
import { Trans } from 'react-i18next'; | ||
|
||
export const Transfer = () => { | ||
const t = useT(); | ||
const [searchParams] = useSearchParams(); | ||
const assetId = searchParams.get('assetId') || undefined; | ||
|
||
const open = useDialogStore((store) => store.open); | ||
const { pubKey } = useVegaWallet(); | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-col gap-4"> | ||
<TransferContainer assetId={assetId} /> | ||
<GetStarted /> | ||
</> | ||
{!pubKey && ( | ||
<Notification | ||
intent={Intent.Info} | ||
message={ | ||
<Trans | ||
defaults="Connect a <0>Vega wallet</0> to transfer." | ||
components={[ | ||
<ExternalLink href="https://vega.xyz/wallet" key="link"> | ||
Vega wallet | ||
</ExternalLink>, | ||
]} | ||
/> | ||
} | ||
buttonProps={{ | ||
text: t('Connect wallet'), | ||
action: open, | ||
}} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,41 @@ | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { GetStarted } from '../../components/welcome-dialog/get-started'; | ||
import { WithdrawContainer } from '../../components/withdraw-container'; | ||
|
||
import { useDialogStore, useVegaWallet } from '@vegaprotocol/wallet-react'; | ||
import { ExternalLink, Intent, Notification } from '@vegaprotocol/ui-toolkit'; | ||
import { useT } from '../../lib/use-t'; | ||
import { Trans } from 'react-i18next'; | ||
|
||
export const Withdraw = () => { | ||
const t = useT(); | ||
const [searchParams] = useSearchParams(); | ||
const assetId = searchParams.get('assetId') || undefined; | ||
|
||
const open = useDialogStore((store) => store.open); | ||
const { pubKey } = useVegaWallet(); | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-col gap-4"> | ||
<WithdrawContainer assetId={assetId} /> | ||
<GetStarted /> | ||
</> | ||
{!pubKey && ( | ||
<Notification | ||
intent={Intent.Info} | ||
message={ | ||
<Trans | ||
defaults="Connect a <0>Vega wallet</0> to withdraw." | ||
components={[ | ||
<ExternalLink href="https://vega.xyz/wallet" key="link"> | ||
Vega wallet | ||
</ExternalLink>, | ||
]} | ||
/> | ||
} | ||
buttonProps={{ | ||
text: t('Connect wallet'), | ||
action: open, | ||
}} | ||
/> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.