Skip to content

Commit

Permalink
Minor tweaks. Added timespans to gas/txcount label above contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
mokelgit committed Aug 20, 2023
1 parent b21a3af commit 74dcc33
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions components/layout/CategoryMetrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export default function CategoryMetrics({
optimism: true,
polygon_zkevm: true,
imx: true,
base: true,
});

const [contracts, setContracts] = useState<{ [key: string]: ContractInfo }>(
Expand Down Expand Up @@ -966,6 +967,7 @@ export default function CategoryMetrics({
},
});

console.log(maxDisplayedContracts);
return (
<div className="w-full flex-col relative">
<Container>
Expand Down Expand Up @@ -1764,6 +1766,9 @@ export default function CategoryMetrics({
setContractCategory("value");
}}
>
<p className="font-normal">
({timespans[selectedTimespan].label})
</p>
{selectedMode === "gas_fees_"
? "Gas Fees "
: "Transaction Count "}
Expand All @@ -1788,7 +1793,7 @@ export default function CategoryMetrics({
</div>
{!sortOrder
? Object.keys(sortedContracts).map((key, i) => {
if (!showMore && i >= maxDisplayedContracts) {
if (i >= maxDisplayedContracts) {
return null;
}

Expand Down Expand Up @@ -1935,7 +1940,7 @@ export default function CategoryMetrics({
: Object.keys(sortedContracts)
.reverse()
.map((key, i) => {
if (!showMore && i >= maxDisplayedContracts) {
if (i >= maxDisplayedContracts) {
return null;
}

Expand Down Expand Up @@ -2081,24 +2086,27 @@ export default function CategoryMetrics({
</div>
);
})}
<button
className={`relative mx-auto top-[21px] w-[125px] h-[40px] border-forest-50 border-[1px] rounded-full bg-forest-700 p-[6px 16px] ${
Object.keys(sortedContracts).length <= 10 ? "hidden" : "visible"
}`}
onClick={() => {
setShowMore(!showMore);
if (Object.keys(sortedContracts).length > maxDisplayedContracts) {
setMaxDisplayedContracts(maxDisplayedContracts + 10);
} else {
setMaxDisplayedContracts(10);
}
}}
>
{Object.keys(sortedContracts).length}
{Object.keys(sortedContracts).length < maxDisplayedContracts
? "Show Less"
: "Show More"}
</button>
<div className="w-full flex justify-center mb-2">
<button
className={`relative mx-auto top-[21px] w-[125px] h-[40px] border-forest-50 border-[1px] rounded-full hover:bg-forest-700 p-[6px 16px] ${
Object.keys(sortedContracts).length <= 10 ? "hidden" : "visible"
}`}
onClick={() => {
setShowMore(!showMore);
if (
Object.keys(sortedContracts).length > maxDisplayedContracts
) {
setMaxDisplayedContracts(maxDisplayedContracts + 10);
} else {
setMaxDisplayedContracts(10);
}
}}
>
{Object.keys(sortedContracts).length <= maxDisplayedContracts
? "Show Less"
: "Show More"}
</button>
</div>
</div>
</Container>
</div>
Expand Down

0 comments on commit 74dcc33

Please sign in to comment.