Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+5
-40
@@ -1,14 +1,13 @@
|
||||
import { Fragment, useEffect, useState } from "react";
|
||||
import { Fragment } from "react";
|
||||
import { useNavigation } from "react-router";
|
||||
import { useSpinDelay } from "spin-delay";
|
||||
import { Transition } from "@headlessui/react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
// Subframe migration (strangler shim): only the spinner glyph swaps to the Subframe
|
||||
// design-system Loader. The floating panel, spin-delay gating, navigation-state word
|
||||
// cycling, transitions and path display are all preserved unchanged.
|
||||
// design-system Loader. The floating panel, spin-delay gating, transitions and
|
||||
// path display are all preserved unchanged.
|
||||
import { Loader } from "~/ui/components/Loader";
|
||||
|
||||
let firstRender = false;
|
||||
import { HEADLESS_FLOATING_MOTION } from "~/ui/floating-motion";
|
||||
|
||||
interface Props {
|
||||
loading?: boolean;
|
||||
@@ -16,37 +15,11 @@ interface Props {
|
||||
export default function FloatingLoader({ loading }: Props) {
|
||||
const { t } = useTranslation();
|
||||
const navigation = useNavigation();
|
||||
const [, setWords] = useState<Array<string>>([]);
|
||||
const [pendingPath, setPendingPath] = useState("");
|
||||
const showLoader = useSpinDelay(Boolean(navigation.state !== "idle" || loading), {
|
||||
delay: 400,
|
||||
minDuration: 1000,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (navigation.location?.pathname === "/") return;
|
||||
if (navigation.state === "idle") return;
|
||||
if (navigation.state === "loading") setWords(LOADER_WORDS);
|
||||
if (navigation.state === "submitting") setWords(ACTION_WORDS);
|
||||
|
||||
const interval = setInterval(() => {
|
||||
setWords(([first, ...rest]) => [...rest, first] as Array<string>);
|
||||
}, 2000);
|
||||
|
||||
return () => clearInterval(interval);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [pendingPath, navigation.state]);
|
||||
|
||||
useEffect(() => {
|
||||
if (firstRender) return;
|
||||
if (navigation.state === "idle") return;
|
||||
setPendingPath(navigation.location.pathname);
|
||||
}, [navigation]);
|
||||
|
||||
useEffect(() => {
|
||||
firstRender = false;
|
||||
}, []);
|
||||
|
||||
const action = navigation.state === "loading" ? t("shared.loading") : t("shared.processing");
|
||||
|
||||
return (
|
||||
@@ -56,12 +29,7 @@ export default function FloatingLoader({ loading }: Props) {
|
||||
<Transition
|
||||
show={showLoader}
|
||||
as={Fragment}
|
||||
enter="transform ease-out duration-300 transition"
|
||||
enterFrom="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-4"
|
||||
enterTo="translate-y-0 opacity-100 sm:translate-x-0"
|
||||
leave="transition ease-in duration-100"
|
||||
leaveFrom="opacity-100"
|
||||
leaveTo="opacity-0"
|
||||
{...HEADLESS_FLOATING_MOTION}
|
||||
>
|
||||
<div className="bg-background ring-opacity-5 pointer-events-auto w-64 max-w-sm overflow-hidden rounded-lg p-2 shadow-lg ring-1 ring-black">
|
||||
<div className="space-y-2 pt-2 pb-2 text-center">
|
||||
@@ -83,6 +51,3 @@ export default function FloatingLoader({ loading }: Props) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const LOADER_WORDS = ["loading", "checking cdn", "checking cache", "fetching from db", "compiling mdx", "updating cache", "transfer"];
|
||||
const ACTION_WORDS = ["packaging", "zapping", "validating", "processing", "calculating", "computing", "computering"];
|
||||
Reference in new issue
Block a user