2022-02-11 13:56:28 +00:00
|
|
|
import { AppProps } from 'next/app';
|
|
|
|
import Head from 'next/head';
|
2022-02-17 05:08:17 +00:00
|
|
|
import { Navbar } from '../components/navbar';
|
2022-03-14 13:18:11 +00:00
|
|
|
import { ThemeContext } from '@vegaprotocol/react-helpers';
|
|
|
|
import { VegaConnectDialog, VegaWalletProvider } from '@vegaprotocol/wallet';
|
2022-03-25 07:44:10 +00:00
|
|
|
import { Connectors } from '../lib/vega-connectors';
|
2022-03-11 00:28:48 +00:00
|
|
|
import { useCallback, useMemo, useState } from 'react';
|
2022-02-28 23:43:36 +00:00
|
|
|
import { createClient } from '../lib/apollo-client';
|
2022-03-09 13:05:42 +00:00
|
|
|
import { ThemeSwitcher } from '@vegaprotocol/ui-toolkit';
|
2022-02-24 00:04:58 +00:00
|
|
|
import { ApolloProvider } from '@apollo/client';
|
2022-03-11 00:28:48 +00:00
|
|
|
import { AppLoader } from '../components/app-loader';
|
|
|
|
import { VegaWalletButton } from '../components/vega-wallet-connect-button';
|
2022-03-25 16:45:12 +00:00
|
|
|
import { useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
2022-02-11 13:56:28 +00:00
|
|
|
|
2022-03-14 13:18:11 +00:00
|
|
|
import './styles.css';
|
|
|
|
|
2022-02-17 05:03:46 +00:00
|
|
|
function VegaTradingApp({ Component, pageProps }: AppProps) {
|
2022-03-25 07:44:10 +00:00
|
|
|
const client = useMemo(() => createClient(process.env['NX_VEGA_URL']), []);
|
2022-02-24 00:04:58 +00:00
|
|
|
const [dialogOpen, setDialogOpen] = useState(false);
|
2022-03-14 13:18:11 +00:00
|
|
|
const [theme, toggleTheme] = useThemeSwitcher();
|
2022-02-24 00:04:58 +00:00
|
|
|
|
|
|
|
const setConnectDialog = useCallback((isOpen?: boolean) => {
|
|
|
|
setDialogOpen((curr) => {
|
|
|
|
if (isOpen === undefined) return !curr;
|
|
|
|
return isOpen;
|
|
|
|
});
|
|
|
|
}, []);
|
|
|
|
|
2022-02-11 13:56:28 +00:00
|
|
|
return (
|
2022-03-14 13:18:11 +00:00
|
|
|
<ThemeContext.Provider value={theme}>
|
|
|
|
<ApolloProvider client={client}>
|
|
|
|
<VegaWalletProvider>
|
|
|
|
<AppLoader>
|
|
|
|
<Head>
|
|
|
|
<title>Welcome to trading!</title>
|
|
|
|
<link
|
|
|
|
rel="icon"
|
|
|
|
href="https://vega.xyz/favicon-32x32.png"
|
|
|
|
type="image/png"
|
|
|
|
/>
|
|
|
|
</Head>
|
|
|
|
<div className="h-full dark:bg-black dark:text-white-60 bg-white text-black-60 grid grid-rows-[min-content,1fr]">
|
|
|
|
<div className="flex items-stretch border-b-[7px] border-vega-yellow">
|
|
|
|
<Navbar />
|
|
|
|
<div className="flex items-center ml-auto mr-8">
|
|
|
|
<VegaWalletButton setConnectDialog={setConnectDialog} />
|
|
|
|
<ThemeSwitcher onToggle={toggleTheme} className="-my-4" />
|
|
|
|
</div>
|
2022-03-11 00:28:48 +00:00
|
|
|
</div>
|
2022-03-14 13:18:11 +00:00
|
|
|
<main>
|
|
|
|
<Component {...pageProps} />
|
|
|
|
</main>
|
|
|
|
<VegaConnectDialog
|
|
|
|
connectors={Connectors}
|
|
|
|
dialogOpen={dialogOpen}
|
|
|
|
setDialogOpen={setDialogOpen}
|
|
|
|
/>
|
2022-03-10 00:39:59 +00:00
|
|
|
</div>
|
2022-03-14 13:18:11 +00:00
|
|
|
</AppLoader>
|
|
|
|
</VegaWalletProvider>
|
|
|
|
</ApolloProvider>
|
|
|
|
</ThemeContext.Provider>
|
2022-02-11 13:56:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-17 05:03:46 +00:00
|
|
|
export default VegaTradingApp;
|