Use standard TransactionValue component; add docs

This commit is contained in:
Willian Mitsuda 2022-02-19 15:19:56 -03:00
parent 4b6910d2a1
commit dcc125293a
3 changed files with 13 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import React, { useContext, useEffect, useMemo, useState } from "react";
import { BlockTag } from "@ethersproject/providers";
import ContentFrame from "../ContentFrame";
import InfoRow from "../components/InfoRow";
import FormattedBalance from "../components/FormattedBalance";
import TransactionValue from "../components/TransactionValue";
import TransactionAddress from "../components/TransactionAddress";
import Copy from "../components/Copy";
import TransactionLink from "../components/TransactionLink";
@ -131,7 +131,7 @@ const AddressTransactionResults: React.FC<AddressTransactionResultsProps> = ({
<SelectionContext.Provider value={selectionCtx}>
{balance && (
<InfoRow title="Balance">
<FormattedBalance value={balance} /> Ether
<TransactionValue value={balance} />
</InfoRow>
)}
{creator && (

View File

@ -7,6 +7,7 @@ type FormatterBalanceProps = {
decimals?: number;
};
// TODO: remove duplication with TransactionValue component
const FormattedBalance: React.FC<FormatterBalanceProps> = ({
value,
decimals = 18,

View File

@ -8,6 +8,16 @@ type TransactionValueProps = {
hideUnit?: boolean;
};
/**
* Standard component for displaying balances. It:
*
* - Commify non-decimal parts, i.e., 1,000,000.00
* - Light gray absolute zero values
* - Cut out decimal part is it is 0 to reduce UI clutter, i.e., show
* 123 instead of 123.00
*
* TODO: remove duplication with FormattedBalance
*/
const TransactionValue: React.FC<TransactionValueProps> = ({
value,
decimals = 18,