Refactorings
This commit is contained in:
parent
a76a2d71a2
commit
fe336c5c43
|
@ -216,16 +216,12 @@ const AddressTransactions: React.FC = () => {
|
||||||
</StandardSubtitle>
|
</StandardSubtitle>
|
||||||
<Tab.Group>
|
<Tab.Group>
|
||||||
<Tab.List className="flex space-x-2 border-l border-r border-t rounded-t-lg bg-white">
|
<Tab.List className="flex space-x-2 border-l border-r border-t rounded-t-lg bg-white">
|
||||||
<Tab as={Fragment}>
|
|
||||||
<NavTab href={`/address/${checksummedAddress}`}>
|
<NavTab href={`/address/${checksummedAddress}`}>
|
||||||
Overview
|
Overview
|
||||||
</NavTab>
|
</NavTab>
|
||||||
</Tab>
|
|
||||||
<Tab as={Fragment}>
|
|
||||||
<NavTab href={`/address/${checksummedAddress}/contract`}>
|
<NavTab href={`/address/${checksummedAddress}/contract`}>
|
||||||
Contract
|
Contract
|
||||||
</NavTab>
|
</NavTab>
|
||||||
</Tab>
|
|
||||||
</Tab.List>
|
</Tab.List>
|
||||||
<Tab.Panels>
|
<Tab.Panels>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { useMemo, useContext } from "react";
|
import React, { useMemo, useContext } from "react";
|
||||||
import { Route, Switch, useParams } from "react-router-dom";
|
import { Route, Switch, useParams } from "react-router-dom";
|
||||||
|
import { Tab } from "@headlessui/react";
|
||||||
import StandardFrame from "./StandardFrame";
|
import StandardFrame from "./StandardFrame";
|
||||||
import StandardSubtitle from "./StandardSubtitle";
|
import StandardSubtitle from "./StandardSubtitle";
|
||||||
import ContentFrame from "./ContentFrame";
|
import ContentFrame from "./ContentFrame";
|
||||||
import TabGroup from "./components/TabGroup";
|
|
||||||
import NavTab from "./components/NavTab";
|
import NavTab from "./components/NavTab";
|
||||||
import Details from "./transaction/Details";
|
import Details from "./transaction/Details";
|
||||||
import Logs from "./transaction/Logs";
|
import Logs from "./transaction/Logs";
|
||||||
|
@ -56,14 +56,17 @@ const Transaction: React.FC = () => {
|
||||||
)}
|
)}
|
||||||
{txData && (
|
{txData && (
|
||||||
<SelectionContext.Provider value={selectionCtx}>
|
<SelectionContext.Provider value={selectionCtx}>
|
||||||
<TabGroup>
|
<Tab.Group>
|
||||||
|
<Tab.List className="flex space-x-2 border-l border-r border-t rounded-t-lg bg-white">
|
||||||
<NavTab href={`/tx/${txhash}`}>Overview</NavTab>
|
<NavTab href={`/tx/${txhash}`}>Overview</NavTab>
|
||||||
{txData.confirmedData?.blockNumber !== undefined && (
|
{txData.confirmedData?.blockNumber !== undefined && (
|
||||||
<NavTab href={`/tx/${txhash}/logs`}>
|
<NavTab href={`/tx/${txhash}/logs`}>
|
||||||
Logs{txData && ` (${txData.confirmedData?.logs?.length ?? 0})`}
|
Logs
|
||||||
|
{txData && ` (${txData.confirmedData?.logs?.length ?? 0})`}
|
||||||
</NavTab>
|
</NavTab>
|
||||||
)}
|
)}
|
||||||
</TabGroup>
|
</Tab.List>
|
||||||
|
</Tab.Group>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route path="/tx/:txhash/" exact>
|
<Route path="/tx/:txhash/" exact>
|
||||||
<Details
|
<Details
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import React, { useState, useEffect, useContext } from "react";
|
import React, { useState, useEffect, useContext, Fragment } from "react";
|
||||||
import { ethers } from "ethers";
|
import { commify } from "@ethersproject/units";
|
||||||
|
import { Tab } from "@headlessui/react";
|
||||||
import ContentFrame from "../ContentFrame";
|
import ContentFrame from "../ContentFrame";
|
||||||
import InfoRow from "../components/InfoRow";
|
import InfoRow from "../components/InfoRow";
|
||||||
import Contract from "./Contract";
|
import Contract from "./Contract";
|
||||||
|
@ -40,7 +41,7 @@ const Contracts: React.FC<ContractsProps> = ({
|
||||||
<span>
|
<span>
|
||||||
<span className="font-bold text-green-600">Yes</span> with{" "}
|
<span className="font-bold text-green-600">Yes</span> with{" "}
|
||||||
<span className="font-bold text-green-600">
|
<span className="font-bold text-green-600">
|
||||||
{ethers.utils.commify(optimizer?.runs)}
|
{commify(optimizer?.runs)}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
runs
|
runs
|
||||||
</span>
|
</span>
|
||||||
|
@ -56,8 +57,10 @@ const Contracts: React.FC<ContractsProps> = ({
|
||||||
)}
|
)}
|
||||||
{rawMetadata !== undefined && rawMetadata !== null && (
|
{rawMetadata !== undefined && rawMetadata !== null && (
|
||||||
<div>
|
<div>
|
||||||
<div className="flex truncate">
|
<Tab.Group>
|
||||||
|
<Tab.List className="flex truncate">
|
||||||
{Object.entries(rawMetadata.sources).map(([k]) => (
|
{Object.entries(rawMetadata.sources).map(([k]) => (
|
||||||
|
<Tab key={k} as={Fragment}>
|
||||||
<button
|
<button
|
||||||
className={`border-b-2 border-transparent rounded-t text-sm px-2 py-1 ${
|
className={`border-b-2 border-transparent rounded-t text-sm px-2 py-1 ${
|
||||||
selected === k
|
selected === k
|
||||||
|
@ -68,8 +71,10 @@ const Contracts: React.FC<ContractsProps> = ({
|
||||||
>
|
>
|
||||||
{k}
|
{k}
|
||||||
</button>
|
</button>
|
||||||
|
</Tab>
|
||||||
))}
|
))}
|
||||||
</div>
|
</Tab.List>
|
||||||
|
</Tab.Group>
|
||||||
{selected && (
|
{selected && (
|
||||||
<Contract
|
<Contract
|
||||||
checksummedAddress={checksummedAddress}
|
checksummedAddress={checksummedAddress}
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import React from "react";
|
import React, { Fragment } from "react";
|
||||||
import { NavLink } from "react-router-dom";
|
import { NavLink } from "react-router-dom";
|
||||||
|
import { Tab } from "@headlessui/react";
|
||||||
|
|
||||||
type NavTabProps = {
|
type NavTabProps = {
|
||||||
href: string;
|
href: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
const NavTab: React.FC<NavTabProps> = ({ href, children }) => (
|
const NavTab: React.FC<NavTabProps> = ({ href, children }) => (
|
||||||
|
<Tab as={Fragment}>
|
||||||
<NavLink
|
<NavLink
|
||||||
className="text-gray-500 border-transparent hover:text-link-blue text-sm font-bold px-3 py-3 border-b-2"
|
className="text-gray-500 border-transparent hover:text-link-blue text-sm font-bold px-3 py-3 border-b-2"
|
||||||
activeClassName="text-link-blue border-link-blue"
|
activeClassName="text-link-blue border-link-blue"
|
||||||
|
@ -15,6 +17,7 @@ const NavTab: React.FC<NavTabProps> = ({ href, children }) => (
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</NavLink>
|
</NavLink>
|
||||||
|
</Tab>
|
||||||
);
|
);
|
||||||
|
|
||||||
export default NavTab;
|
export default NavTab;
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
const TabGroup: React.FC = ({ children }) => (
|
|
||||||
<div className="flex space-x-2 border-l border-r border-t rounded-t-lg bg-white">
|
|
||||||
{children}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default TabGroup;
|
|
Loading…
Reference in New Issue