Uecko_ERP/packages/rdx-ui/src/components/loading-overlay/loading-overlay.tsx

40 lines
1.3 KiB
TypeScript
Raw Normal View History

2025-05-17 19:12:01 +00:00
import { JSX } from "react";
import { useTranslation } from "react-i18next";
import { LoadingIndicator } from "./loading-indicator.tsx";
2025-05-05 17:11:44 +00:00
export type LoadingOverlayProps = {
title?: string;
subtitle?: string;
};
2025-05-17 19:12:01 +00:00
/**
* LoadingOverlay component
* @param {string} title - The title to display in the loading overlay.
* @param {string} subtitle - The subtitle to display in the loading overlay.
* @param {React.HTMLAttributes<HTMLDivElement>} props - Additional props to pass to the overlay.
* @returns {JSX.Element} The LoadingOverlay component.
*/
export const LoadingOverlay = ({ title, subtitle, ...props }: LoadingOverlayProps): JSX.Element => {
const { t } = useTranslation();
const { title: defaultTitle, subtitle: defaultSubtitle } = t("components.loading_overlay", {
returnObjects: true,
}) as { title: string; subtitle: string };
const loadingTitle = title || defaultTitle;
const loadingSubtitle = subtitle || defaultSubtitle;
2025-05-05 17:11:44 +00:00
return (
<div
className={
"fixed top-0 bottom-0 left-0 right-0 z-50 w-full h-screen overflow-hidden flex justify-center bg-background/85"
}
{...props}
>
2025-05-17 19:12:01 +00:00
<LoadingIndicator look='dark' title={loadingTitle} subtitle={loadingSubtitle} />
2025-05-05 17:11:44 +00:00
</div>
);
};
LoadingOverlay.displayName = "LoadingOverlay";