diff --git a/app/components/PageLoadingIndicator.tsx b/app/components/PageLoadingIndicator.tsx new file mode 100644 index 0000000..9f4735d --- /dev/null +++ b/app/components/PageLoadingIndicator.tsx @@ -0,0 +1,14 @@ +import { useNavigation } from "@remix-run/react"; +import SpinnerSVG from "./SpinnerSVG"; + +export default function PageLoadingIndicator() { + const navigation = useNavigation(); + if (navigation.state !== "loading") return null; + return ( +
+
+ +
+
+ ); +} diff --git a/app/root.tsx b/app/root.tsx index 5edaf81..b8e11f5 100644 --- a/app/root.tsx +++ b/app/root.tsx @@ -10,9 +10,10 @@ import { Scripts, useLoaderData, useLocation, + useNavigation, useRevalidator, } from "@remix-run/react"; -import { useState, useEffect, useMemo, useCallback } from "react"; +import { useState, useEffect } from "react"; import { createBrowserClient } from "@supabase/ssr"; import stylesheet from "~/tailwind.css"; @@ -30,6 +31,7 @@ import { RawCartItem } from "./utils/types/ContextProps.type"; import PopupNotificationsList from "./components/PopupNotificationsList"; import Footer from "./components/Footer"; import { useNotification } from "./components/useNotification"; +import PageLoadingIndicator from "./components/PageLoadingIndicator"; export const links: LinksFunction = () => [ { rel: "stylesheet", href: stylesheet }, @@ -200,6 +202,7 @@ function App() { +