Clean up app component
This commit is contained in:
committed by
Michael Vines
parent
8e081c70f2
commit
d629e67b32
@ -1,20 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
|
||||||
import { ClusterProvider } from "./providers/cluster";
|
|
||||||
import {
|
|
||||||
TransactionsProvider,
|
|
||||||
useTransactionsDispatch,
|
|
||||||
useTransactions,
|
|
||||||
ActionType
|
|
||||||
} from "./providers/transactions";
|
|
||||||
import {
|
|
||||||
AccountsProvider,
|
|
||||||
useSelectedAccount,
|
|
||||||
useAccountsDispatch,
|
|
||||||
ActionType as AccountActionType
|
|
||||||
} from "./providers/accounts";
|
|
||||||
import { BlocksProvider } from "./providers/blocks";
|
|
||||||
import ClusterStatusButton from "./components/ClusterStatusButton";
|
import ClusterStatusButton from "./components/ClusterStatusButton";
|
||||||
import AccountsCard from "./components/AccountsCard";
|
import AccountsCard from "./components/AccountsCard";
|
||||||
import TransactionsCard from "./components/TransactionsCard";
|
import TransactionsCard from "./components/TransactionsCard";
|
||||||
@ -28,10 +14,7 @@ function App() {
|
|||||||
const [showClusterModal, setShowClusterModal] = React.useState(false);
|
const [showClusterModal, setShowClusterModal] = React.useState(false);
|
||||||
const currentTab = useCurrentTab();
|
const currentTab = useCurrentTab();
|
||||||
return (
|
return (
|
||||||
<ClusterProvider>
|
<>
|
||||||
<AccountsProvider>
|
|
||||||
<TransactionsProvider>
|
|
||||||
<BlocksProvider>
|
|
||||||
<ClusterModal
|
<ClusterModal
|
||||||
show={showClusterModal}
|
show={showClusterModal}
|
||||||
onClose={() => setShowClusterModal(false)}
|
onClose={() => setShowClusterModal(false)}
|
||||||
@ -84,9 +67,7 @@ function App() {
|
|||||||
<div className="container">
|
<div className="container">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
{currentTab === "Transactions" ? (
|
{currentTab === "Transactions" ? <TransactionsCard /> : null}
|
||||||
<TransactionsCard />
|
|
||||||
) : null}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
@ -96,14 +77,7 @@ function App() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<Overlay
|
</>
|
||||||
show={showClusterModal}
|
|
||||||
onClick={() => setShowClusterModal(false)}
|
|
||||||
/>
|
|
||||||
</BlocksProvider>
|
|
||||||
</TransactionsProvider>
|
|
||||||
</AccountsProvider>
|
|
||||||
</ClusterProvider>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,30 +94,4 @@ function NavLink({ href, tab }: { href: string; tab: Tab }) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type OverlayProps = {
|
|
||||||
show: boolean;
|
|
||||||
onClick: () => void;
|
|
||||||
};
|
|
||||||
|
|
||||||
function Overlay({ show, onClick }: OverlayProps) {
|
|
||||||
const { selected } = useTransactions();
|
|
||||||
const selectedAccount = useSelectedAccount();
|
|
||||||
const txDispatch = useTransactionsDispatch();
|
|
||||||
const accountDispatch = useAccountsDispatch();
|
|
||||||
|
|
||||||
if (show || !!selected || !!selectedAccount)
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className="modal-backdrop fade show"
|
|
||||||
onClick={() => {
|
|
||||||
onClick();
|
|
||||||
txDispatch({ type: ActionType.Deselect });
|
|
||||||
accountDispatch({ type: AccountActionType.Select });
|
|
||||||
}}
|
|
||||||
></div>
|
|
||||||
);
|
|
||||||
|
|
||||||
return <div className="fade"></div>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
} from "../providers/accounts";
|
} from "../providers/accounts";
|
||||||
import { TransactionError } from "@solana/web3.js";
|
import { TransactionError } from "@solana/web3.js";
|
||||||
import Copyable from "./Copyable";
|
import Copyable from "./Copyable";
|
||||||
|
import Overlay from "./Overlay";
|
||||||
|
|
||||||
function AccountModal() {
|
function AccountModal() {
|
||||||
const selected = useSelectedAccount();
|
const selected = useSelectedAccount();
|
||||||
@ -37,9 +38,12 @@ function AccountModal() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<div className={`modal fade${show ? " show" : ""}`} onClick={onClose}>
|
<div className={`modal fade${show ? " show" : ""}`} onClick={onClose}>
|
||||||
{renderContent()}
|
{renderContent()}
|
||||||
</div>
|
</div>
|
||||||
|
<Overlay show={show} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
Cluster
|
Cluster
|
||||||
} from "../providers/cluster";
|
} from "../providers/cluster";
|
||||||
import { assertUnreachable } from "../utils";
|
import { assertUnreachable } from "../utils";
|
||||||
|
import Overlay from "./Overlay";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
show: boolean;
|
show: boolean;
|
||||||
@ -18,6 +19,7 @@ type Props = {
|
|||||||
|
|
||||||
function ClusterModal({ show, onClose }: Props) {
|
function ClusterModal({ show, onClose }: Props) {
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<div
|
<div
|
||||||
className={`modal fade fixed-right${show ? " show" : ""}`}
|
className={`modal fade fixed-right${show ? " show" : ""}`}
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
@ -36,6 +38,9 @@ function ClusterModal({ show, onClose }: Props) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<Overlay show={show} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
explorer/src/components/Overlay.tsx
Normal file
9
explorer/src/components/Overlay.tsx
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
type OverlayProps = {
|
||||||
|
show: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function Overlay({ show }: OverlayProps) {
|
||||||
|
return <div className={`modal-backdrop fade${show ? " show" : ""}`}></div>;
|
||||||
|
}
|
@ -14,6 +14,7 @@ import {
|
|||||||
TransactionInstruction
|
TransactionInstruction
|
||||||
} from "@solana/web3.js";
|
} from "@solana/web3.js";
|
||||||
import Copyable from "./Copyable";
|
import Copyable from "./Copyable";
|
||||||
|
import Overlay from "./Overlay";
|
||||||
|
|
||||||
function TransactionModal() {
|
function TransactionModal() {
|
||||||
const { selected } = useTransactions();
|
const { selected } = useTransactions();
|
||||||
@ -43,9 +44,12 @@ function TransactionModal() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<>
|
||||||
<div className={`modal fade${show ? " show" : ""}`} onClick={onClose}>
|
<div className={`modal fade${show ? " show" : ""}`} onClick={onClose}>
|
||||||
{renderContent()}
|
{renderContent()}
|
||||||
</div>
|
</div>
|
||||||
|
<Overlay show={show} />
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,12 +4,24 @@ import { BrowserRouter as Router } from "react-router-dom";
|
|||||||
import "./scss/theme.scss";
|
import "./scss/theme.scss";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import * as serviceWorker from "./serviceWorker";
|
import * as serviceWorker from "./serviceWorker";
|
||||||
|
import { ClusterProvider } from "./providers/cluster";
|
||||||
|
import { BlocksProvider } from "./providers/blocks";
|
||||||
|
import { TransactionsProvider } from "./providers/transactions";
|
||||||
|
import { AccountsProvider } from "./providers/accounts";
|
||||||
import { TabProvider } from "./providers/tab";
|
import { TabProvider } from "./providers/tab";
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Router>
|
<Router>
|
||||||
<TabProvider>
|
<TabProvider>
|
||||||
|
<ClusterProvider>
|
||||||
|
<AccountsProvider>
|
||||||
|
<TransactionsProvider>
|
||||||
|
<BlocksProvider>
|
||||||
<App />
|
<App />
|
||||||
|
</BlocksProvider>
|
||||||
|
</TransactionsProvider>
|
||||||
|
</AccountsProvider>
|
||||||
|
</ClusterProvider>
|
||||||
</TabProvider>
|
</TabProvider>
|
||||||
</Router>,
|
</Router>,
|
||||||
document.getElementById("root")
|
document.getElementById("root")
|
||||||
|
@ -32,6 +32,10 @@ code {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.modal-backdrop {
|
||||||
|
pointer-events: none;
|
||||||
|
}
|
||||||
|
|
||||||
.modal.show {
|
.modal.show {
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user