Files
blitzkit/src/app/layout.tsx
T

122 lines
3.8 KiB
TypeScript
Raw Normal View History

2023-09-30 22:12:48 -05:00
'use client';
2024-04-06 12:10:54 -05:00
import { AlertDialog, Button, Flex, ScrollArea, Theme } from '@radix-ui/themes';
2023-09-30 22:30:52 -05:00
import '@radix-ui/themes/styles.css';
2023-09-18 23:05:19 +00:00
import { config } from 'dotenv';
2023-09-12 02:38:50 +00:00
import { Roboto_Flex } from 'next/font/google';
2023-09-30 22:12:48 -05:00
import { usePathname } from 'next/navigation';
2024-04-06 11:14:07 -05:00
import { ReactNode, use, useEffect, useState } from 'react';
2024-03-18 10:02:09 -05:00
import { Analytics } from '../components/Analytics';
2024-04-06 12:10:54 -05:00
import { Footer } from '../components/Footer';
2023-09-07 01:13:03 +00:00
import Navbar from '../components/Navbar';
2024-04-06 11:14:07 -05:00
import { gameDefinitions } from '../core/blitzkrieg/gameDefinitions';
2024-02-20 22:10:59 -06:00
import isDev from '../core/blitzkrieg/isDev';
import { isLocalhost } from '../core/blitzkrieg/isLocalhost';
2024-04-02 10:21:51 -05:00
import { useFullScreen } from '../hooks/useFullScreen';
2024-02-20 22:10:59 -06:00
import { useApp } from '../stores/app';
2023-09-07 01:13:03 +00:00
2023-09-18 23:05:19 +00:00
config();
2024-02-22 21:58:03 -06:00
const DEV_BUILD_AGREEMENT_COOLDOWN = 8 * 24 * 60 * 60 * 1000;
2023-09-07 01:13:03 +00:00
interface RootLayoutProps {
children: ReactNode;
}
2023-09-12 02:38:50 +00:00
const robotoFlex = Roboto_Flex({
subsets: ['latin'],
display: 'swap',
});
2023-09-07 01:13:03 +00:00
export default function RootLayout({ children }: RootLayoutProps) {
2024-04-06 11:14:07 -05:00
const awaitedGameDefinitions = use(gameDefinitions);
2023-09-30 22:12:48 -05:00
const pathname = usePathname();
const isEmbed = pathname.split('/')[1] === 'embeds';
2024-02-20 22:10:59 -06:00
const [showDevBuildAlert, setShowDevBuildAlert] = useState(false);
2024-04-02 10:21:51 -05:00
const isFullScreen = useFullScreen();
2024-02-20 22:10:59 -06:00
useEffect(() => {
setShowDevBuildAlert(
2024-02-22 21:58:03 -06:00
isDev() &&
!isLocalhost() &&
Date.now() - useApp.getState().devBuildAgreementTime >=
DEV_BUILD_AGREEMENT_COOLDOWN,
2024-02-20 22:10:59 -06:00
);
}, []);
2023-09-30 22:12:48 -05:00
2023-09-07 01:13:03 +00:00
return (
2023-09-12 02:38:50 +00:00
<html lang="en" className={robotoFlex.className}>
2023-10-01 17:26:08 -05:00
<head>
<title>Blitzkrieg</title>
<meta
name="description"
content="🎉 Tools for everything World of Tanks Blitz"
/>
2024-03-18 10:09:46 -05:00
<Analytics />
2023-10-01 17:26:08 -05:00
</head>
2023-09-07 01:13:03 +00:00
<body
style={{
margin: 0,
2024-04-06 11:14:07 -05:00
// paddingTop: isEmbed ? 0 : '3.25rem',
2024-02-27 08:00:16 -06:00
backgroundColor: isEmbed ? 'transparent' : undefined,
2023-09-07 01:13:03 +00:00
}}
>
2023-12-03 19:45:43 -06:00
<Theme
appearance="dark"
2024-04-05 17:44:31 -05:00
panelBackground="solid"
2023-12-03 19:45:43 -06:00
radius="full"
suppressHydrationWarning
suppressContentEditableWarning
>
2024-04-06 11:14:07 -05:00
<ScrollArea
style={{
height: '100vh',
}}
>
<Flex direction="column" style={{ height: '100%' }}>
{!isEmbed && <Navbar />}
<AlertDialog.Root open={showDevBuildAlert}>
<AlertDialog.Content>
<AlertDialog.Title>Experimental version!</AlertDialog.Title>
<AlertDialog.Description>
This version may have a lot of issues. Report issues to{' '}
<a href="https://discord.gg/nDt7AjGJQH" target="_blank">
the official Discord server
</a>
. Also consider using{' '}
<a href="https://blitz-krieg.vercel.app/">
the more stable release version
</a>
. You will be asked again in 8 days.
</AlertDialog.Description>
2024-02-20 22:10:59 -06:00
2024-04-06 11:14:07 -05:00
<Flex justify="end">
<Button
variant="solid"
onClick={() => {
setShowDevBuildAlert(false);
useApp.setState({ devBuildAgreementTime: Date.now() });
}}
>
Continue
</Button>
2024-02-24 19:34:02 -06:00
</Flex>
2024-04-06 11:14:07 -05:00
</AlertDialog.Content>
</AlertDialog.Root>
2024-02-24 19:34:02 -06:00
2024-04-06 11:14:07 -05:00
<Flex direction="column">{children}</Flex>
2024-02-27 09:31:22 -06:00
2024-04-06 11:14:07 -05:00
{!isEmbed && !isFullScreen && (
<>
<div style={{ flex: 1 }} />
2024-04-06 12:10:54 -05:00
<Footer />
2024-04-06 11:14:07 -05:00
</>
)}
</Flex>
</ScrollArea>
2023-09-30 22:30:52 -05:00
</Theme>
2023-09-07 01:13:03 +00:00
</body>
</html>
);
}