mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Some checks failed
Auto release excalidraw next / Auto-release-excalidraw-next (push) Failing after 2m36s
Build Docker image / build-docker (push) Failing after 6s
Cancel previous runs / cancel (push) Failing after 1s
Publish Docker / publish-docker (push) Failing after 31s
New Sentry production release / sentry (push) Failing after 2m3s
44 lines
901 B
TypeScript
44 lines
901 B
TypeScript
import clsx from "clsx";
|
|
import { useState, useEffect } from "react";
|
|
|
|
import { THEME } from "@excalidraw/common";
|
|
|
|
import type { Theme } from "@excalidraw/element/types";
|
|
|
|
import { t } from "../i18n";
|
|
|
|
import Spinner from "./Spinner";
|
|
|
|
export const LoadingMessage: React.FC<{ delay?: number; theme?: Theme }> = ({
|
|
delay,
|
|
theme,
|
|
}) => {
|
|
const [isWaiting, setIsWaiting] = useState(!!delay);
|
|
|
|
useEffect(() => {
|
|
if (!delay) {
|
|
return;
|
|
}
|
|
const timer = setTimeout(() => {
|
|
setIsWaiting(false);
|
|
}, delay);
|
|
return () => clearTimeout(timer);
|
|
}, [delay]);
|
|
|
|
if (isWaiting) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div
|
|
className={clsx("LoadingMessage", {
|
|
"LoadingMessage--dark": theme === THEME.DARK,
|
|
})}
|
|
>
|
|
<div>
|
|
<Spinner />
|
|
</div>
|
|
<div className="LoadingMessage-text">{t("labels.loadingScene")}</div>
|
|
</div>
|
|
);
|
|
};
|