2022-03-30 09:49:48 +00:00
|
|
|
import type { AppProps } from 'next/app';
|
2022-09-02 14:53:38 +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';
|
2022-10-14 15:42:53 +00:00
|
|
|
import { VegaWalletProvider } from '@vegaprotocol/wallet';
|
2022-09-23 14:29:35 +00:00
|
|
|
import {
|
|
|
|
EnvironmentProvider,
|
|
|
|
envTriggerMapping,
|
2022-10-28 15:13:14 +00:00
|
|
|
Networks,
|
2022-09-23 14:29:35 +00:00
|
|
|
useEnvironment,
|
|
|
|
} from '@vegaprotocol/environment';
|
2022-03-11 00:28:48 +00:00
|
|
|
import { AppLoader } from '../components/app-loader';
|
2022-03-14 13:18:11 +00:00
|
|
|
import './styles.css';
|
2022-10-14 15:42:53 +00:00
|
|
|
import { usePageTitleStore } from '../stores';
|
2022-08-31 04:35:46 +00:00
|
|
|
import { Footer } from '../components/footer';
|
2022-09-23 14:29:35 +00:00
|
|
|
import { useMemo } from 'react';
|
2022-10-14 15:42:53 +00:00
|
|
|
import DialogsContainer from './dialogs-container';
|
2022-09-23 14:29:35 +00:00
|
|
|
|
|
|
|
const DEFAULT_TITLE = t('Welcome to Vega trading!');
|
2022-03-14 13:18:11 +00:00
|
|
|
|
2022-10-14 15:42:53 +00:00
|
|
|
const Title = () => {
|
|
|
|
const { pageTitle } = usePageTitleStore((store) => ({
|
2022-09-23 14:29:35 +00:00
|
|
|
pageTitle: store.pageTitle,
|
2022-09-05 14:25:33 +00:00
|
|
|
}));
|
2022-06-10 09:15:38 +00:00
|
|
|
|
2022-09-23 14:29:35 +00:00
|
|
|
const { VEGA_ENV } = useEnvironment();
|
|
|
|
const networkName = envTriggerMapping[VEGA_ENV];
|
|
|
|
|
|
|
|
const title = useMemo(() => {
|
|
|
|
if (!pageTitle) return DEFAULT_TITLE;
|
|
|
|
if (networkName) return `${pageTitle} [${networkName}]`;
|
|
|
|
return pageTitle;
|
|
|
|
}, [pageTitle, networkName]);
|
2022-10-14 15:42:53 +00:00
|
|
|
return (
|
|
|
|
<Head>
|
|
|
|
<title>{title}</title>
|
|
|
|
</Head>
|
|
|
|
);
|
|
|
|
};
|
2022-09-23 14:29:35 +00:00
|
|
|
|
2022-10-14 15:42:53 +00:00
|
|
|
function AppBody({ Component, pageProps }: AppProps) {
|
2022-10-28 15:13:14 +00:00
|
|
|
const { VEGA_ENV } = useEnvironment();
|
2022-10-14 15:42:53 +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-10-27 18:12:03 +00:00
|
|
|
<Head>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
</Head>
|
2022-10-14 15:42:53 +00:00
|
|
|
<Title />
|
2022-08-31 04:35:46 +00:00
|
|
|
<div className="h-full relative dark:bg-black dark:text-white z-0 grid grid-rows-[min-content,1fr,min-content]">
|
2022-06-24 03:16:01 +00:00
|
|
|
<AppLoader>
|
2022-10-28 15:13:14 +00:00
|
|
|
<Navbar
|
|
|
|
theme={theme}
|
|
|
|
toggleTheme={toggleTheme}
|
|
|
|
navbarTheme={VEGA_ENV === Networks.TESTNET ? 'yellow' : 'dark'}
|
|
|
|
/>
|
2022-08-31 04:35:46 +00:00
|
|
|
<main data-testid={pageProps.page}>
|
2022-06-24 03:16:01 +00:00
|
|
|
<Component {...pageProps} />
|
|
|
|
</main>
|
2022-08-31 04:35:46 +00:00
|
|
|
<Footer />
|
2022-10-14 15:42:53 +00:00
|
|
|
<DialogsContainer />
|
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>
|
|
|
|
<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;
|