LoadingSpinner.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { type FC } from "react";
  2. interface LoadingSpinnerProps {
  3. colorClassName?: string;
  4. size?: 16 | 20 | 24 | 28 | 32 | 36 | 40 | 48;
  5. className?: string;
  6. }
  7. export const LoadingSpinner: FC<LoadingSpinnerProps> = ({
  8. size = 24,
  9. className = "" ,
  10. colorClassName = "text-success"
  11. }) => {
  12. const sizeClasses = {
  13. 16: "h-4 w-4",
  14. 20: "h-5 w-5",
  15. 24: "h-6 w-6",
  16. 28: "h-7 w-7",
  17. 32: "h-8 w-8",
  18. 36: "w-9 h-9",
  19. 40: "w-10 h-10",
  20. 48: "h-12 w-12"
  21. };
  22. return (
  23. <div className={`flex items-center justify-center ${className}`}>
  24. <svg viewBox="0 0 32 32" fill="none" strokeWidth="3"
  25. className={`z-0 relative overflow-hidden ${colorClassName} animate-spinner-ease-spin ${sizeClasses[size]}`}
  26. >
  27. <circle cx="16" cy="16" r="13" role="presentation"
  28. strokeDasharray="81.68140899333463 81.68140899333463"
  29. strokeDashoffset="0" transform="rotate(-90 16 16)"
  30. strokeLinecap="round"
  31. className="h-full stroke-default-300/50"></circle>
  32. <circle cx="16" cy="16" r="13" role="presentation"
  33. strokeDasharray="81.68140899333463 81.68140899333463"
  34. strokeDashoffset="61.26105674500097" transform="rotate(-90 16 16)"
  35. strokeLinecap="round"
  36. className="h-full stroke-current transition-all !duration-500"></circle>
  37. </svg>
  38. </div>
  39. );
  40. };