mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: experimental warning
This commit is contained in:
1 parent
6fd8b83d39
commit
24ca684db3
3 files changed
+61
-8
No files matched your search
+41
-8
@@ -1,12 +1,15 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { Flex, Theme } from '@radix-ui/themes';
|
import { AlertDialog, Button, Flex, Theme } from '@radix-ui/themes';
|
||||||
import '@radix-ui/themes/styles.css';
|
import '@radix-ui/themes/styles.css';
|
||||||
import { config } from 'dotenv';
|
import { config } from 'dotenv';
|
||||||
import { Roboto_Flex } from 'next/font/google';
|
import { Roboto_Flex } from 'next/font/google';
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { ReactNode } from 'react';
|
import { ReactNode, useEffect, useState } from 'react';
|
||||||
import Navbar from '../components/Navbar';
|
import Navbar from '../components/Navbar';
|
||||||
|
import isDev from '../core/blitzkrieg/isDev';
|
||||||
|
import { isLocalhost } from '../core/blitzkrieg/isLocalhost';
|
||||||
|
import { useApp } from '../stores/app';
|
||||||
|
|
||||||
config();
|
config();
|
||||||
|
|
||||||
@@ -22,6 +25,13 @@ const robotoFlex = Roboto_Flex({
|
|||||||
export default function RootLayout({ children }: RootLayoutProps) {
|
export default function RootLayout({ children }: RootLayoutProps) {
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const isEmbed = pathname.split('/')[1] === 'embeds';
|
const isEmbed = pathname.split('/')[1] === 'embeds';
|
||||||
|
const [showDevBuildAlert, setShowDevBuildAlert] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setShowDevBuildAlert(
|
||||||
|
isDev() && !isLocalhost() && !useApp.getState().bypassDevBuildAlert,
|
||||||
|
);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="en" className={robotoFlex.className}>
|
<html lang="en" className={robotoFlex.className}>
|
||||||
@@ -39,12 +49,6 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
|||||||
paddingTop: isEmbed ? 0 : '3.25rem',
|
paddingTop: isEmbed ? 0 : '3.25rem',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{/* <AlertDialog.Root open>
|
|
||||||
<AlertDialog.Content>
|
|
||||||
<AlertDialog.Title>Peepee</AlertDialog.Title>
|
|
||||||
</AlertDialog.Content>
|
|
||||||
</AlertDialog.Root> */}
|
|
||||||
|
|
||||||
<Theme
|
<Theme
|
||||||
appearance="dark"
|
appearance="dark"
|
||||||
panelBackground="translucent"
|
panelBackground="translucent"
|
||||||
@@ -54,6 +58,35 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
|||||||
>
|
>
|
||||||
{!isEmbed && <Navbar />}
|
{!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 version
|
||||||
|
</a>
|
||||||
|
.
|
||||||
|
</AlertDialog.Description>
|
||||||
|
|
||||||
|
<Flex justify="end">
|
||||||
|
<Button
|
||||||
|
variant="solid"
|
||||||
|
onClick={() => {
|
||||||
|
setShowDevBuildAlert(false);
|
||||||
|
useApp.setState({ bypassDevBuildAlert: true });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Continue
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
</AlertDialog.Content>
|
||||||
|
</AlertDialog.Root>
|
||||||
|
|
||||||
<Flex direction="column">{children}</Flex>
|
<Flex direction="column">{children}</Flex>
|
||||||
</Theme>
|
</Theme>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export function isLocalhost() {
|
||||||
|
return (
|
||||||
|
typeof window !== 'undefined' && window.location.hostname === 'localhost'
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
import { create } from 'zustand';
|
||||||
|
import { persist } from 'zustand/middleware';
|
||||||
|
|
||||||
|
export interface App {
|
||||||
|
bypassDevBuildAlert: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useApp = create<App>()(
|
||||||
|
persist(
|
||||||
|
(set) => ({
|
||||||
|
bypassDevBuildAlert: false,
|
||||||
|
}),
|
||||||
|
{ name: 'app' },
|
||||||
|
),
|
||||||
|
);
|
||||||
Reference in new issue
Block a user