-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: feedback for insufficient ETH to cover transaction fees (#1683)
- Closes #1676 --- | 📷 Demo | | --- | | <img width="367" alt="Screenshot 2024-12-05 at 16 23 13" src="https://github.com/user-attachments/assets/08ed04e2-d97b-42b6-8802-8a25b7c5d66b"> |
- Loading branch information
1 parent
771962b
commit a7e6e48
Showing
5 changed files
with
97 additions
and
26 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
Fix feedback when user has insufficient ETH to cover fees. |
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 @@ | ||
--- | ||
"fuels-wallet": patch | ||
--- | ||
|
||
Fix large amounts breaking the UI on the homescreen. |
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
75 changes: 75 additions & 0 deletions
75
packages/app/src/systems/Asset/components/AssetItem/AssetItemAmount.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,75 @@ | ||
import { cssObj } from '@fuel-ui/css'; | ||
import { Box, Text, Tooltip } from '@fuel-ui/react'; | ||
import type { BNInput } from 'fuels'; | ||
import { useEffect, useMemo, useRef, useState } from 'react'; | ||
import { AmountVisibility, formatBalance } from '~/systems/Core'; | ||
import { useBalanceVisibility } from '~/systems/Core/hooks/useVisibility'; | ||
|
||
type AssetItemAmountProps = { | ||
amount: BNInput; | ||
decimals: number | undefined; | ||
symbol: string | undefined; | ||
}; | ||
|
||
export const AssetItemAmount = ({ | ||
amount, | ||
decimals, | ||
symbol, | ||
}: AssetItemAmountProps) => { | ||
const { visibility } = useBalanceVisibility(); | ||
const { original, tooltip } = formatBalance(amount, decimals); | ||
|
||
const amountRef = useRef<HTMLSpanElement>(null); | ||
const [isTruncated, setIsTruncated] = useState(false); | ||
|
||
const open = useMemo<boolean | undefined>(() => { | ||
if (visibility && (tooltip || isTruncated)) return undefined; | ||
return false; | ||
}, [tooltip, visibility, isTruncated]); | ||
|
||
useEffect(() => { | ||
if (!tooltip && amountRef.current) { | ||
const amountEl = amountRef.current; | ||
setIsTruncated(amountEl.scrollWidth > amountEl.clientWidth); | ||
} | ||
}, [tooltip]); | ||
|
||
return ( | ||
<Tooltip content={original.display} delayDuration={0} open={open}> | ||
<Box css={styles.root}> | ||
<Text as="span" ref={amountRef} css={styles.amount}> | ||
<AmountVisibility | ||
value={amount} | ||
units={decimals} | ||
visibility={visibility} | ||
/> | ||
</Text> | ||
<Text as="span" css={styles.symbol}> | ||
{symbol} | ||
</Text> | ||
</Box> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
const styles = { | ||
root: cssObj({ | ||
display: 'inline-flex', | ||
columnGap: '$1', | ||
minWidth: 0, | ||
alignItems: 'center', | ||
flexWrap: 'nowrap', | ||
fontSize: '$sm', | ||
fontWeight: '$normal', | ||
textAlign: 'right', | ||
paddingLeft: '$2', | ||
}), | ||
amount: cssObj({ | ||
display: 'inline-block', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
}), | ||
symbol: cssObj({ | ||
flexShrink: 0, | ||
}), | ||
}; |
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