From 48fa8115c9f53fc78d031c4d01a9825ccb7f54bd Mon Sep 17 00:00:00 2001 From: wil Date: Tue, 3 Sep 2024 23:19:17 -0400 Subject: [PATCH] loading bar and spinner --- src/app/router.tsx | 5 ++ src/components/ui/LoadingBar.tsx | 67 +++++++++++++++++++ .../ui/{Loader.tsx => LoadingSpinner.tsx} | 2 +- src/components/ui/index.ts | 3 +- src/pages/login.tsx | 7 +- src/pages/sandbox.tsx | 10 +++ 6 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 src/components/ui/LoadingBar.tsx rename src/components/ui/{Loader.tsx => LoadingSpinner.tsx} (96%) create mode 100644 src/pages/sandbox.tsx diff --git a/src/app/router.tsx b/src/app/router.tsx index 8e689d7e62..be3d936984 100644 --- a/src/app/router.tsx +++ b/src/app/router.tsx @@ -1,6 +1,7 @@ import { createBrowserRouter } from "react-router-dom"; import { Login } from "~/pages/login"; import { Main } from "~/pages/main"; +import { Sandbox } from "~/pages/sandbox"; export const router = createBrowserRouter([ { @@ -11,4 +12,8 @@ export const router = createBrowserRouter([ path: "/login", element: , }, + { + path: "/sandbox", + element: , + }, ]); diff --git a/src/components/ui/LoadingBar.tsx b/src/components/ui/LoadingBar.tsx new file mode 100644 index 0000000000..3d38797838 --- /dev/null +++ b/src/components/ui/LoadingBar.tsx @@ -0,0 +1,67 @@ +import { Transition } from "@headlessui/react"; +import { twMerge } from "tailwind-merge"; + +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faCheck, faArrowRotateLeft } from "@fortawesome/pro-thin-svg-icons"; + +import { Spinner } from "./Spinner"; + +export enum LoadingBarStatus { + LOADING = "loading", + SUCCESS = "success", + ERROR = "error", +} + +export const LoadingBar = ({ + progress = 0, + status = LoadingBarStatus.SUCCESS, + onRetry, + isShowing, + message, +}: { + progress: number; + status: LoadingBarStatus; + isShowing: boolean; + message?: string; + onRetry?: () => void; +}) => { + return ( + +
+
+
+
+
+ {status === LoadingBarStatus.LOADING && ( + + )} + {status === LoadingBarStatus.SUCCESS && ( + + )} + {status === LoadingBarStatus.ERROR && ( + + )} +
+ {message && } +
+ + ); +}; diff --git a/src/components/ui/Loader.tsx b/src/components/ui/LoadingSpinner.tsx similarity index 96% rename from src/components/ui/Loader.tsx rename to src/components/ui/LoadingSpinner.tsx index beca483256..5d3d29964b 100644 --- a/src/components/ui/Loader.tsx +++ b/src/components/ui/LoadingSpinner.tsx @@ -2,7 +2,7 @@ import { Transition } from "@headlessui/react"; import { twMerge } from "tailwind-merge"; import { Spinner } from "./Spinner"; -export const Loader = ({ +export const LoadingSpinner = ({ isShowing, message, }: { diff --git a/src/components/ui/index.ts b/src/components/ui/index.ts index f30f5335a9..540a31bc9c 100644 --- a/src/components/ui/index.ts +++ b/src/components/ui/index.ts @@ -1,6 +1,7 @@ export * from "./Button"; export * from "./Input"; -export * from "./Loader"; +export * from "./LoadingBar"; +export * from "./LoadingSpinner"; export * from "./PanelBottom"; export * from "./PanelRight"; export * from "./Spinner"; diff --git a/src/pages/login.tsx b/src/pages/login.tsx index 3adc3a27b8..5586e6aa3d 100644 --- a/src/pages/login.tsx +++ b/src/pages/login.tsx @@ -4,7 +4,7 @@ import { useNavigate, useSearchParams, Link } from "react-router-dom"; import { useSignalEffect } from "@preact/signals-react/runtime"; import { faKey, faUser } from "@fortawesome/pro-thin-svg-icons"; -import { Button, Input, Loader } from "~/components/ui"; +import { Button, Input, LoadingSpinner } from "~/components/ui"; import { authentication } from "~/signals"; export const Login = () => { @@ -109,7 +109,10 @@ export const Login = () => { - + {/* { + return ( +
+

Sandbox

+ +
+ ); +};