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-08-04 09:14:49 +00:00
|
|
|
import { EnvironmentProvider } from '@vegaprotocol/environment';
|
2022-03-25 07:44:10 +00:00
|
|
|
import { Connectors } from '../lib/vega-connectors';
|
2022-03-09 13:05:42 +00:00
|
|
|
import { ThemeSwitcher } from '@vegaprotocol/ui-toolkit';
|
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-06-01 14:21:36 +00:00
|
|
|
import { useGlobalStore } from '../stores';
|
2022-08-17 14:10:01 +00:00
|
|
|
import {
|
|
|
|
AssetDetailsDialog,
|
|
|
|
useAssetDetailsDialogStore,
|
2022-08-26 15:39:40 +00:00
|
|
|
} from '@vegaprotocol/assets';
|
2022-03-14 13:18:11 +00:00
|
|
|
|
2022-06-10 09:15:38 +00:00
|
|
|
function AppBody({ Component, pageProps }: AppProps) {
|
2022-06-01 14:21:36 +00:00
|
|
|
const store = useGlobalStore();
|
2022-08-17 14:10:01 +00:00
|
|
|
const {
|
|
|
|
isAssetDetailsDialogOpen,
|
|
|
|
assetDetailsDialogSymbol,
|
|
|
|
setAssetDetailsDialogOpen,
|
|
|
|
} = useAssetDetailsDialogStore();
|
2022-06-24 03:16:01 +00:00
|
|
|
const [theme, toggleTheme] = useThemeSwitcher();
|
2022-06-10 09:15:38 +00:00
|
|
|
|
|
|
|
return (
|
2022-06-24 03:16:01 +00:00
|
|
|
<ThemeContext.Provider value={theme}>
|
2022-07-29 16:50:32 +00:00
|
|
|
<div className="h-full relative text-black-60 dark:text-white-60 z-0 grid grid-rows-[min-content,1fr]">
|
2022-06-24 03:16:01 +00:00
|
|
|
<AppLoader>
|
2022-07-14 16:03:17 +00:00
|
|
|
<div className="flex items-stretch border-b-[7px] bg-black border-vega-pink dark:border-vega-yellow">
|
2022-06-24 03:16:01 +00:00
|
|
|
<Navbar />
|
|
|
|
<div className="flex items-center gap-4 ml-auto mr-8">
|
|
|
|
<VegaWalletConnectButton
|
|
|
|
setConnectDialog={(open) => {
|
|
|
|
store.setVegaWalletConnectDialog(open);
|
|
|
|
}}
|
|
|
|
setManageDialog={(open) => {
|
|
|
|
store.setVegaWalletManageDialog(open);
|
|
|
|
}}
|
|
|
|
/>
|
2022-07-29 16:50:32 +00:00
|
|
|
<ThemeSwitcher
|
|
|
|
onToggle={toggleTheme}
|
|
|
|
className="-my-4"
|
|
|
|
sunClassName="text-white"
|
|
|
|
/>
|
2022-06-24 03:16:01 +00:00
|
|
|
</div>
|
2022-06-17 17:26:45 +00:00
|
|
|
</div>
|
2022-07-18 21:11:53 +00:00
|
|
|
<main data-testid={pageProps.page} className="dark:bg-black">
|
2022-06-24 03:16:01 +00:00
|
|
|
{/* @ts-ignore conflict between @types/react and nextjs internal types */}
|
|
|
|
<Component {...pageProps} />
|
|
|
|
</main>
|
|
|
|
<VegaConnectDialog
|
|
|
|
connectors={Connectors}
|
|
|
|
dialogOpen={store.vegaWalletConnectDialog}
|
|
|
|
setDialogOpen={(open) => store.setVegaWalletConnectDialog(open)}
|
|
|
|
/>
|
|
|
|
<VegaManageDialog
|
|
|
|
dialogOpen={store.vegaWalletManageDialog}
|
|
|
|
setDialogOpen={(open) => store.setVegaWalletManageDialog(open)}
|
|
|
|
/>
|
2022-08-17 14:10:01 +00:00
|
|
|
<AssetDetailsDialog
|
|
|
|
assetSymbol={assetDetailsDialogSymbol}
|
|
|
|
open={isAssetDetailsDialogOpen}
|
|
|
|
onChange={(open) => setAssetDetailsDialogOpen(open)}
|
|
|
|
/>
|
2022-06-24 03:16:01 +00:00
|
|
|
</AppLoader>
|
|
|
|
</div>
|
|
|
|
</ThemeContext.Provider>
|
2022-06-10 09:15:38 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function VegaTradingApp(props: AppProps) {
|
2022-02-11 13:56:28 +00:00
|
|
|
return (
|
2022-06-01 00:30:02 +00:00
|
|
|
<EnvironmentProvider>
|
2022-06-24 03:16:01 +00:00
|
|
|
<VegaWalletProvider>
|
|
|
|
<Head>
|
|
|
|
<link
|
|
|
|
rel="preload"
|
|
|
|
href="https://static.vega.xyz/AlphaLyrae-Medium.woff2"
|
|
|
|
as="font"
|
|
|
|
type="font/woff2"
|
|
|
|
crossOrigin="anonymous"
|
|
|
|
/>
|
|
|
|
<title>{t('Welcome to Vega trading!')}</title>
|
|
|
|
<link
|
|
|
|
rel="icon"
|
|
|
|
type="image/x-icon"
|
|
|
|
href="https://static.vega.xyz/favicon.ico"
|
|
|
|
/>
|
|
|
|
<link rel="stylesheet" href="https://static.vega.xyz/fonts.css" />
|
|
|
|
{['1', 'true'].includes(process.env['NX_USE_ENV_OVERRIDES'] || '') ? (
|
|
|
|
/* eslint-disable-next-line @next/next/no-sync-scripts */
|
2022-07-25 08:48:29 +00:00
|
|
|
<script src="/assets/env-config.js" type="text/javascript" />
|
2022-06-24 03:16:01 +00:00
|
|
|
) : null}
|
|
|
|
</Head>
|
|
|
|
<AppBody {...props} />
|
|
|
|
</VegaWalletProvider>
|
2022-06-01 00:30:02 +00:00
|
|
|
</EnvironmentProvider>
|
2022-02-11 13:56:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-02-17 05:03:46 +00:00
|
|
|
export default VegaTradingApp;
|