This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:FuelLabs/swayswap into refac/swap
* 'master' of github.com:FuelLabs/swayswap: feat: move check branch to commit step (#292) feat: add agreement and update copy (#290) fix: correct behavior when typing only "." in the coin input (#291) fix: coin input value being cut by bottom line balance (#286)
- Loading branch information
Showing
29 changed files
with
286 additions
and
141 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
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 |
---|---|---|
|
@@ -41,7 +41,7 @@ node_modules | |
|
||
# testing | ||
coverage | ||
cypress | ||
/cypress | ||
|
||
# next.js | ||
.next/ | ||
|
Empty file.
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,3 +1 @@ | ||
.env.test | ||
cypress/videos/ | ||
cypress/screenshots/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/// <reference types="cypress" /> | ||
|
||
declare namespace Cypress { | ||
interface Chainable { | ||
/** | ||
* Get element by aria-label | ||
* @example | ||
* cy.getByAriaLabel('Aria Label'); | ||
* cy.getByAriaLabel('Aria Label', { log: false, timeout: 6000 }); | ||
*/ | ||
getByAriaLabel( | ||
ariaLabel: string, | ||
options?: Partial<Loggable & Timeoutable & Withinable & Shadow> | ||
): Chainable<JQuery<E>>; | ||
} | ||
} |
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,5 @@ | ||
@layer components { | ||
.coinBalance--maxButton { | ||
@apply text-xs py-0 px-1 h-auto bg-primary-800/60 text-primary-500 hover:bg-primary-800; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { useMemo } from "react"; | ||
|
||
import { useBalances } from "../hooks"; | ||
import { parseToFormattedNumber } from "../utils"; | ||
|
||
import { Button, Tooltip } from "~/systems/UI"; | ||
import type { Coin, Maybe } from "~/types"; | ||
|
||
export type CoinBalanceProps = { | ||
coin?: Maybe<Coin>; | ||
showMaxButton?: boolean; | ||
onSetMaxBalance?: () => void; | ||
gasFee?: Maybe<bigint>; | ||
}; | ||
|
||
export const CoinBalance = ({ | ||
coin, | ||
showMaxButton = true, | ||
onSetMaxBalance, | ||
gasFee, | ||
}: CoinBalanceProps) => { | ||
const { data: balances } = useBalances({ enabled: true }); | ||
|
||
const balance = useMemo(() => { | ||
const coinBalance = balances?.find( | ||
(item) => item.assetId === coin?.assetId | ||
); | ||
return parseToFormattedNumber(coinBalance?.amount || BigInt(0)); | ||
}, [balances, coin?.assetId]); | ||
|
||
return ( | ||
<div className="flex items-center justify-end gap-2 mt-2 whitespace-nowrap"> | ||
<div | ||
className="text-xs text-gray-400" | ||
aria-label={`${coin?.symbol} balance`} | ||
> | ||
Balance: {balance} | ||
</div> | ||
{showMaxButton && ( | ||
<Tooltip | ||
content={`Max = ${balance}(${coin?.symbol} balance)${ | ||
gasFee ? ` - ${parseToFormattedNumber(gasFee)}(network fee)` : `` | ||
}`} | ||
> | ||
<Button | ||
aria-label="Set Maximun Balance" | ||
size="sm" | ||
onPress={onSetMaxBalance} | ||
className="text-xs py-0 px-1 h-auto bg-primary-800/60 text-primary-500 hover:bg-primary-800" | ||
variant="ghost" | ||
> | ||
Max | ||
</Button> | ||
</Tooltip> | ||
)} | ||
</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
Oops, something went wrong.