| 123456789101112131415161718192021222324252627282930313233 |
- import { useEffect, useState } from "preact/hooks";
- interface LoadingGlobalHook {
- show: () => void;
- hide: () => void;
- }
- declare global {
- var $loading: LoadingGlobalHook | undefined;
- }
- export default function Loading() {
- const [visible, setVisible] = useState(false);
- useEffect(() => {
- globalThis.$loading = {
- show: () => setVisible(true),
- hide: () => setVisible(false),
- };
- return () => {
- delete globalThis.$loading;
- };
- }, []);
- return (
- <div className={`fixed inset-0 bg-black/60 z-[9] flex items-center justify-center ${visible ? "" : "hidden"}`}>
- <div className="inline-block transform translate-z-[1px]">
- <div className="inline-block w-16 h-16 m-2 rounded-full bg-white animate-[pd-loading-spin_5s_cubic-bezier(0,0.2,0.8,1)_infinite]" />
- </div>
- </div>
- );
- }
|