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

View File

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

View File

@ -8,6 +8,16 @@ type TransactionValueProps = {
hideUnit?: boolean; 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> = ({ const TransactionValue: React.FC<TransactionValueProps> = ({
value, value,
decimals = 18, decimals = 18,