Files
blitzkit/src/app/layout.tsx
T

163 lines
4.9 KiB
TypeScript
Raw Normal View History

2023-09-30 22:12:48 -05:00
'use client';
2024-02-24 19:34:02 -06:00
import { CaretRightIcon } from '@radix-ui/react-icons';
import { AlertDialog, Button, Flex, Text, 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-02-20 22:10:59 -06:00
import { ReactNode, useEffect, useState } from 'react';
2024-02-24 19:34:02 -06:00
import { SkyLine } from '../assets/art/SkyLine';
2024-03-18 10:02:09 -05:00
import { Analytics } from '../components/Analytics';
2023-09-07 01:13:03 +00:00
import Navbar from '../components/Navbar';
2024-02-24 19:34:02 -06:00
import PageWrapper from '../components/PageWrapper';
2024-02-20 22:10:59 -06:00
import isDev from '../core/blitzkrieg/isDev';
import { isLocalhost } from '../core/blitzkrieg/isLocalhost';
import { useApp } from '../stores/app';
2024-02-24 19:34:02 -06:00
import { mintTheme } from '../themes/mint';
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) {
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);
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"
/>
</head>
2024-03-18 10:02:09 -05:00
<Analytics />
2023-09-07 01:13:03 +00:00
<body
style={{
margin: 0,
2023-12-06 11:33:23 -06: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"
panelBackground="translucent"
radius="full"
suppressHydrationWarning
suppressContentEditableWarning
>
2023-09-30 22:30:52 -05:00
{!isEmbed && <Navbar />}
2024-02-20 22:10:59 -06:00
<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/">
2024-02-22 21:58:03 -06:00
the more stable release version
2024-02-20 22:10:59 -06:00
</a>
2024-02-22 21:58:03 -06:00
. You will be asked again in 8 days.
2024-02-20 22:10:59 -06:00
</AlertDialog.Description>
<Flex justify="end">
<Button
variant="solid"
onClick={() => {
setShowDevBuildAlert(false);
2024-02-22 21:58:03 -06:00
useApp.setState({ devBuildAgreementTime: Date.now() });
2024-02-20 22:10:59 -06:00
}}
>
Continue
</Button>
</Flex>
</AlertDialog.Content>
</AlertDialog.Root>
2023-10-01 11:35:44 -05:00
<Flex direction="column">{children}</Flex>
2024-02-24 19:34:02 -06:00
2024-02-27 09:31:22 -06:00
{!isEmbed && (
<PageWrapper>
<a
target="_blank"
href="https://ko-fi.com/tresabhi"
style={{ textDecoration: 'none' }}
2024-02-24 19:34:02 -06:00
>
<Flex
2024-02-27 09:31:22 -06:00
align="center"
2024-02-24 19:34:02 -06:00
style={{
2024-02-27 09:31:22 -06:00
padding: 16,
borderRadius: 8,
backgroundColor: mintTheme.colors.componentInteractive,
position: 'relative',
overflow: 'hidden',
2024-02-24 19:34:02 -06:00
}}
>
2024-02-27 09:31:22 -06:00
<Flex
direction="column"
gap="1"
style={{
flex: 1,
zIndex: 1,
}}
>
<Text size="4" color="mint">
Blitzkrieg. Free forever. For everyone.
</Text>
<Text color="mint">
<b>Consider supporting today 🍀</b>
</Text>
2024-02-24 19:34:02 -06:00
</Flex>
2024-02-27 09:31:22 -06:00
<Text
color="mint"
style={{
zIndex: 1,
}}
>
<Flex>
<CaretRightIcon width={32} height={32} />
</Flex>
</Text>
<SkyLine
style={{
position: 'absolute',
right: 'min(8vw, 15%)',
top: '5%',
}}
/>
</Flex>
</a>
</PageWrapper>
)}
2023-09-30 22:30:52 -05:00
</Theme>
2023-09-07 01:13:03 +00:00
</body>
</html>
);
}