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

51 lines
1.4 KiB
TypeScript
Raw Normal View History

2025-05-09 10:45:32 +00:00
import { cn } from "@repo/shadcn-ui/lib/utils";
2025-08-23 11:57:48 +00:00
import { useTranslation } from "../../locales/i18n.ts";
2025-05-17 19:12:01 +00:00
import { LoadingSpinIcon } from "./loading-spin-icon.tsx";
2025-05-05 17:11:44 +00:00
export type LoadingIndicatorProps = {
look?: "dark" | string;
size?: number;
active?: boolean;
title?: string;
subtitle?: string;
};
export const LoadingIndicator = ({
active = true,
look = "dark",
2025-08-23 11:57:48 +00:00
title,
2025-05-05 17:11:44 +00:00
subtitle = "",
}: LoadingIndicatorProps) => {
2025-08-23 11:57:48 +00:00
const { t } = useTranslation();
2025-05-05 17:11:44 +00:00
const isDark = look === "dark";
const loadingSpinClassName = isDark ? "text-brand" : "text-white";
if (!active) {
return;
}
return (
2025-08-23 11:57:48 +00:00
<div className={"flex flex-col items-center max-w-xs justify-center w-full h-full mx-auto"}>
2025-05-05 17:11:44 +00:00
<LoadingSpinIcon size={12} className={loadingSpinClassName} />
{/*<Spinner {...spinnerProps} />*/}
{title ? (
<h2
className={cn(
2025-05-09 10:45:32 +00:00
"mt-6 text-xl font-semibold text-center text-white",
isDark ? "text-slate-600" : "text-white"
2025-05-05 17:11:44 +00:00
)}
>
2025-08-23 11:57:48 +00:00
{title || t("components.loading_indicator.title")}
2025-05-05 17:11:44 +00:00
</h2>
) : null}
{subtitle ? (
2025-05-09 10:45:32 +00:00
<p className={cn("text-center text-white", isDark ? "text-slate-600" : "text-white")}>
2025-08-23 11:57:48 +00:00
{subtitle || t("components.loading_indicator.subtitle")}
2025-05-05 17:11:44 +00:00
</p>
) : null}
</div>
);
};
LoadingIndicator.displayName = "LoadingIndicator";