From f2f3549ce87f82d73aaa586490ba577766765350 Mon Sep 17 00:00:00 2001 From: Michael Hall Date: Sun, 25 Jun 2023 00:04:09 -0400 Subject: [PATCH] initial loading screen --- components/LoadingScreen/LoadingScreen.tsx | 93 ++++++++++++++++++++++ ndk/NDKProvider.tsx | 3 +- 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 components/LoadingScreen/LoadingScreen.tsx diff --git a/components/LoadingScreen/LoadingScreen.tsx b/components/LoadingScreen/LoadingScreen.tsx new file mode 100644 index 00000000..161a6135 --- /dev/null +++ b/components/LoadingScreen/LoadingScreen.tsx @@ -0,0 +1,93 @@ +import { Box, Center, Group, Stack, Text } from "@mantine/core"; +import { motion } from "framer-motion"; +import { useEffect, useState } from "react"; + +export default function LoadingScreen() { + const iconSize = 180; + const barWidth = 8; + const maxBarHeight = 95; + const bars = [0.25, 0.2, 0.65, 1, 0.45]; + const borderWidth = 4; + + return ( +
({ + position: "absolute", + left: 0, + right: 0, + top: 0, + bottom: 0, + margin: "auto", + maxWidth: 600, + })} + > + +
+
+ + {bars.map((height, index) => ( + + + + + + + + ))} + +
+
+ + Stemstr + +
+
+ ); +} + +const Delay = ({ children, delay }: any) => { + const [done, setDone] = useState(false); + + useEffect(() => { + const showTimer = setTimeout(() => setDone(true), delay); + return () => clearTimeout(showTimer); + }, []); + + return done ? <>{children} : null; +}; diff --git a/ndk/NDKProvider.tsx b/ndk/NDKProvider.tsx index 7f73519d..b435db25 100644 --- a/ndk/NDKProvider.tsx +++ b/ndk/NDKProvider.tsx @@ -15,6 +15,7 @@ import { useDispatch, useSelector } from "react-redux"; import { isAuthState, selectAuthState, setAuthState } from "store/Auth"; import { getCachedAuth } from "cache/cache"; import inMemoryCacheAdapter from "./inMemoryCacheAdapter"; +import LoadingScreen from "components/LoadingScreen/LoadingScreen"; interface NDKContext { ndk?: NDK; @@ -101,7 +102,7 @@ const NDKProvider = ({ // Return the provider with the NDK instance return ( - {ndk ? children : "Loading..."} + {ndk ? children : } ); };