You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
877 B
TypeScript
41 lines
877 B
TypeScript
5 years ago
|
import { t } from "../i18n";
|
||
3 years ago
|
import { useState, useEffect } from "react";
|
||
|
import Spinner from "./Spinner";
|
||
2 years ago
|
import clsx from "clsx";
|
||
|
import { THEME } from "../constants";
|
||
|
import { Theme } from "../element/types";
|
||
3 years ago
|
|
||
2 years ago
|
export const LoadingMessage: React.FC<{ delay?: number; theme?: Theme }> = ({
|
||
|
delay,
|
||
|
theme,
|
||
|
}) => {
|
||
3 years ago
|
const [isWaiting, setIsWaiting] = useState(!!delay);
|
||
|
|
||
|
useEffect(() => {
|
||
|
if (!delay) {
|
||
|
return;
|
||
|
}
|
||
|
const timer = setTimeout(() => {
|
||
|
setIsWaiting(false);
|
||
|
}, delay);
|
||
|
return () => clearTimeout(timer);
|
||
|
}, [delay]);
|
||
|
|
||
|
if (isWaiting) {
|
||
|
return null;
|
||
|
}
|
||
5 years ago
|
|
||
|
return (
|
||
2 years ago
|
<div
|
||
|
className={clsx("LoadingMessage", {
|
||
|
"LoadingMessage--dark": theme === THEME.DARK,
|
||
|
})}
|
||
|
>
|
||
3 years ago
|
<div>
|
||
|
<Spinner />
|
||
|
</div>
|
||
|
<div className="LoadingMessage-text">{t("labels.loadingScene")}</div>
|
||
5 years ago
|
</div>
|
||
|
);
|
||
|
};
|