2022-03-30 09:49:48 +00:00
|
|
|
import type { AppProps } from 'next/app';
|
2022-02-11 13:56:28 +00:00
|
|
|
import Head from 'next/head';
|
2022-02-17 05:08:17 +00:00
|
|
|
import { Navbar } from '../components/navbar';
|
2022-03-31 17:16:30 +00:00
|
|
|
import { t, ThemeContext, useThemeSwitcher } from '@vegaprotocol/react-helpers';
|
|
|
|
import {
|
|
|
|
VegaConnectDialog,
|
|
|
|
VegaManageDialog,
|
|
|
|
VegaWalletProvider,
|
|
|
|
} from '@vegaprotocol/wallet';
|
2022-03-25 07:44:10 +00:00
|
|
|
import { Connectors } from '../lib/vega-connectors';
|
2022-03-31 17:16:30 +00:00
|
|
|
import { 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';
|
2022-03-31 17:16:30 +00:00
|
|
|
import { VegaWalletConnectButton } from '../components/vega-wallet-connect-button';
|
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-03-31 17:16:30 +00:00
|
|
|
const [vegaWallet, setVegaWallet] = useState({
|
|
|
|
connect: false,
|
|
|
|
manage: false,
|
|
|
|
});
|
2022-03-14 13:18:11 +00:00
|
|
|
const [theme, toggleTheme] = useThemeSwitcher();
|
2022-02-24 00:04:58 +00:00
|
|
|
|
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>
|
2022-04-06 10:36:36 +00:00
|
|
|
<link
|
|
|
|
rel="preload"
|
|
|
|
href="https://static.vega.xyz/AlphaLyrae-Medium.woff2"
|
|
|
|
as="font"
|
|
|
|
type="font/woff2"
|
|
|
|
crossOrigin="anonymous"
|
|
|
|
/>
|
2022-03-31 01:08:25 +00:00
|
|
|
<title>{t('Welcome to Vega trading!')}</title>
|
2022-03-14 13:18:11 +00:00
|
|
|
<link
|
|
|
|
rel="icon"
|
2022-04-06 10:36:36 +00:00
|
|
|
type="image/x-icon"
|
|
|
|
href="https://static.vega.xyz/favicon.ico"
|
2022-03-14 13:18:11 +00:00
|
|
|
/>
|
2022-04-06 10:36:36 +00:00
|
|
|
<link rel="stylesheet" href="https://static.vega.xyz/fonts.css" />
|
2022-03-14 13:18:11 +00:00
|
|
|
</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 />
|
2022-03-31 17:16:30 +00:00
|
|
|
<div className="flex items-center gap-4 ml-auto mr-8">
|
|
|
|
<VegaWalletConnectButton
|
|
|
|
setConnectDialog={(open) =>
|
|
|
|
setVegaWallet((x) => ({ ...x, connect: open }))
|
|
|
|
}
|
|
|
|
setManageDialog={(open) =>
|
|
|
|
setVegaWallet((x) => ({ ...x, manage: open }))
|
|
|
|
}
|
|
|
|
/>
|
2022-03-14 13:18:11 +00:00
|
|
|
<ThemeSwitcher onToggle={toggleTheme} className="-my-4" />
|
|
|
|
</div>
|
2022-03-11 00:28:48 +00:00
|
|
|
</div>
|
2022-04-12 11:04:26 +00:00
|
|
|
<main data-testid={pageProps.page}>
|
2022-03-14 13:18:11 +00:00
|
|
|
<Component {...pageProps} />
|
|
|
|
</main>
|
|
|
|
<VegaConnectDialog
|
|
|
|
connectors={Connectors}
|
2022-03-31 17:16:30 +00:00
|
|
|
dialogOpen={vegaWallet.connect}
|
|
|
|
setDialogOpen={(open) =>
|
|
|
|
setVegaWallet((x) => ({ ...x, connect: open }))
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<VegaManageDialog
|
|
|
|
dialogOpen={vegaWallet.manage}
|
|
|
|
setDialogOpen={(open) =>
|
|
|
|
setVegaWallet((x) => ({ ...x, manage: open }))
|
|
|
|
}
|
2022-03-14 13:18:11 +00:00
|
|
|
/>
|
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;
|