forked from trezor/trezor-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(suite): add staking/unstaking instant amount forecasting
- Loading branch information
Showing
8 changed files
with
211 additions
and
7 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
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
33 changes: 33 additions & 0 deletions
33
...c/views/wallet/staking/components/EthStakingDashboard/components/ApproximateEthAmount.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,33 @@ | ||
import { FormattedCryptoAmount } from 'src/components/suite'; | ||
import styled from 'styled-components'; | ||
import { Tooltip, variables } from '@trezor/components'; | ||
import { BigNumber } from '@trezor/utils/src/bigNumber'; | ||
|
||
const StyledFormattedCryptoAmount = styled(FormattedCryptoAmount)` | ||
display: block; | ||
font-size: ${variables.FONT_SIZE.NORMAL}; | ||
`; | ||
|
||
interface ApproximateEthAmountProps { | ||
value: string | number; | ||
symbol: string; | ||
} | ||
|
||
const DEFAULT_MAX_DECIMAL_PLACES = 5; | ||
|
||
export const ApproximateEthAmount = ({ value, symbol }: ApproximateEthAmountProps) => { | ||
const hasDecimals = value.toString().includes('.'); | ||
|
||
if (!hasDecimals) { | ||
return <StyledFormattedCryptoAmount value={value} symbol={symbol} />; | ||
} | ||
|
||
const valueBig = new BigNumber(value); | ||
const trimmedAmount = valueBig.toFixed(DEFAULT_MAX_DECIMAL_PLACES, 1); | ||
|
||
return ( | ||
<Tooltip content={<StyledFormattedCryptoAmount value={value} symbol={symbol} />}> | ||
<StyledFormattedCryptoAmount value={trimmedAmount} symbol={symbol} /> | ||
</Tooltip> | ||
); | ||
}; |