From e214117f47fab35b8e58e0ac6ea2755df6efea5f Mon Sep 17 00:00:00 2001 From: Willian Mitsuda Date: Wed, 28 Jul 2021 04:40:38 -0300 Subject: [PATCH] Extract PercentageBar component; apply percentage bar to tx gas usage --- src/Block.tsx | 13 ++----------- src/components/PercentageBar.tsx | 21 +++++++++++++++++++++ src/transaction/Details.tsx | 10 ++++++++-- 3 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 src/components/PercentageBar.tsx diff --git a/src/Block.tsx b/src/Block.tsx index afa68f4..83ab187 100644 --- a/src/Block.tsx +++ b/src/Block.tsx @@ -8,6 +8,7 @@ import ContentFrame from "./ContentFrame"; import InfoRow from "./components/InfoRow"; import Timestamp from "./components/Timestamp"; import GasValue from "./components/GasValue"; +import PercentageBar from "./components/PercentageBar"; import BlockLink from "./components/BlockLink"; import DecoratedAddressLink from "./components/DecoratedAddressLink"; import TransactionValue from "./components/TransactionValue"; @@ -133,17 +134,7 @@ const Block: React.FC = () => { /{" "} -
-
-
-
- {gasUsedPerc}% -
-
-
+ diff --git a/src/components/PercentageBar.tsx b/src/components/PercentageBar.tsx new file mode 100644 index 0000000..a868784 --- /dev/null +++ b/src/components/PercentageBar.tsx @@ -0,0 +1,21 @@ +import React from "react"; + +type PercentageBarProps = { + perc: number; +}; + +const PercentageBar: React.FC = ({ perc }) => ( +
+
+
+
+ {perc}% +
+
+
+); + +export default React.memo(PercentageBar); diff --git a/src/transaction/Details.tsx b/src/transaction/Details.tsx index 71cef91..2619204 100644 --- a/src/transaction/Details.tsx +++ b/src/transaction/Details.tsx @@ -20,6 +20,7 @@ import GasValue from "../components/GasValue"; import FormattedBalance from "../components/FormattedBalance"; import TokenTransferItem from "../TokenTransferItem"; import { TransactionData, InternalOperation } from "../types"; +import PercentageBar from "../components/PercentageBar"; type DetailsProps = { txData: TransactionData; @@ -171,8 +172,13 @@ const Details: React.FC = ({
- / {" "} - ({(txData.gasUsedPerc * 100).toFixed(2)}%) +
+
+ /{" "} + +
+ +
N/A {txData.nonce}