loaderComponent.tsx 949 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { cn } from "@/lib/utils";
  2. import { usePromiseTracker } from "react-promise-tracker";
  3. export interface ISVGProps extends React.SVGProps<SVGSVGElement> {
  4. size?: number;
  5. className?: string;
  6. }
  7. export const LoadingSpinner = ({
  8. size = 48,
  9. className,
  10. ...props
  11. }: ISVGProps) => {
  12. const { promiseInProgress } = usePromiseTracker();
  13. if (!promiseInProgress) {
  14. return null;
  15. }
  16. return (
  17. <div className="bg-background/50 fixed inset-0 z-[100] flex items-center justify-center backdrop-blur-sm">
  18. <svg
  19. xmlns="http://www.w3.org/2000/svg"
  20. width={size}
  21. height={size}
  22. {...props}
  23. viewBox="0 0 24 24"
  24. fill="none"
  25. stroke="currentColor"
  26. strokeWidth="2"
  27. strokeLinecap="round"
  28. strokeLinejoin="round"
  29. className={cn("text-primary animate-spin", className)}
  30. >
  31. <path d="M21 12a9 9 0 1 1-6.219-8.56" />
  32. </svg>
  33. </div>
  34. );
  35. };