From 24ca684db3eba87538b41634c497b4b27aa35ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 20 Feb 2024 22:10:59 -0600 Subject: [PATCH] feat: experimental warning --- src/app/layout.tsx | 49 +++++++++++++++++++++++++----- src/core/blitzkrieg/isLocalhost.ts | 5 +++ src/stores/app.ts | 15 +++++++++ 3 files changed, 61 insertions(+), 8 deletions(-) create mode 100644 src/core/blitzkrieg/isLocalhost.ts create mode 100644 src/stores/app.ts diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f2ec4c0f9..6082bdf9e 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -1,12 +1,15 @@ '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 { config } from 'dotenv'; import { Roboto_Flex } from 'next/font/google'; import { usePathname } from 'next/navigation'; -import { ReactNode } from 'react'; +import { ReactNode, useEffect, useState } from 'react'; import Navbar from '../components/Navbar'; +import isDev from '../core/blitzkrieg/isDev'; +import { isLocalhost } from '../core/blitzkrieg/isLocalhost'; +import { useApp } from '../stores/app'; config(); @@ -22,6 +25,13 @@ const robotoFlex = Roboto_Flex({ export default function RootLayout({ children }: RootLayoutProps) { const pathname = usePathname(); const isEmbed = pathname.split('/')[1] === 'embeds'; + const [showDevBuildAlert, setShowDevBuildAlert] = useState(false); + + useEffect(() => { + setShowDevBuildAlert( + isDev() && !isLocalhost() && !useApp.getState().bypassDevBuildAlert, + ); + }, []); return ( @@ -39,12 +49,6 @@ export default function RootLayout({ children }: RootLayoutProps) { paddingTop: isEmbed ? 0 : '3.25rem', }} > - {/* - - Peepee - - */} - {!isEmbed && } + + + Experimental version! + + This version may have a lot of issues. Report issues to{' '} + + the official Discord server + + . Also consider using{' '} + + the more stable version + + . + + + + + + + + {children} diff --git a/src/core/blitzkrieg/isLocalhost.ts b/src/core/blitzkrieg/isLocalhost.ts new file mode 100644 index 000000000..0042dcfd9 --- /dev/null +++ b/src/core/blitzkrieg/isLocalhost.ts @@ -0,0 +1,5 @@ +export function isLocalhost() { + return ( + typeof window !== 'undefined' && window.location.hostname === 'localhost' + ); +} diff --git a/src/stores/app.ts b/src/stores/app.ts new file mode 100644 index 000000000..9f2bf263c --- /dev/null +++ b/src/stores/app.ts @@ -0,0 +1,15 @@ +import { create } from 'zustand'; +import { persist } from 'zustand/middleware'; + +export interface App { + bypassDevBuildAlert: boolean; +} + +export const useApp = create()( + persist( + (set) => ({ + bypassDevBuildAlert: false, + }), + { name: 'app' }, + ), +);