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, transitions and // path display are all preserved unchanged. import { Loader } from "~/ui/components/Loader"; import { HEADLESS_FLOATING_MOTION } from "~/ui/floating-motion"; interface Props { loading?: boolean; } export default function FloatingLoader({ loading }: Props) { const { t } = useTranslation(); const navigation = useNavigation(); const showLoader = useSpinDelay(Boolean(navigation.state !== "idle" || loading), { delay: 400, minDuration: 1000, }); const action = navigation.state === "loading" ? t("shared.loading") : t("shared.processing"); return (
{/* Notification panel, dynamically insert this into the live region when it needs to be displayed */}
{action}...
{navigation.location?.pathname && (
{t("shared.path")}: {navigation.location?.pathname}
)}
); }