68 lines
1.4 KiB
TypeScript
68 lines
1.4 KiB
TypeScript
import type { LoadingDotsProps } from "$/types/LoadingTypes";
|
|
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
|
|
|
|
export default function RotatingDots({
|
|
size,
|
|
width,
|
|
height,
|
|
className,
|
|
animationDuration = 1000,
|
|
color,
|
|
stroke,
|
|
fill,
|
|
ariaLabel = "Loading"
|
|
}: Readonly<LoadingDotsProps>){
|
|
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/3-dots-rotate.svg
|
|
const reducedMotion = usePrefersReducedMotion();
|
|
const dur = reducedMotion ? animationDuration / 100 : animationDuration / 1000;
|
|
|
|
|
|
return (
|
|
<svg
|
|
width={size ?? width}
|
|
height={size ?? height}
|
|
role="status"
|
|
aria-live="polite"
|
|
aria-label={ariaLabel}
|
|
viewBox="0 0 24 24"
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
>
|
|
<circle
|
|
cx="12"
|
|
cy="12"
|
|
r="3"
|
|
className={className}
|
|
stroke={color ?? stroke}
|
|
fill={color ?? fill}
|
|
/>
|
|
<g>
|
|
<circle
|
|
cx="4"
|
|
cy="12"
|
|
r="3"
|
|
className={className}
|
|
stroke={color ?? stroke}
|
|
fill={color ?? fill}
|
|
/>
|
|
<circle
|
|
cx="20"
|
|
cy="12"
|
|
r="3"
|
|
className={className}
|
|
stroke={color ?? stroke}
|
|
fill={color ?? fill}
|
|
/>
|
|
<animateTransform
|
|
attributeName="transform"
|
|
type="rotate"
|
|
calcMode="spline"
|
|
dur={dur}
|
|
keySplines=".36,.6,.31,1;.36,.6,.31,1"
|
|
values="0 12 12;180 12 12;360 12 12"
|
|
repeatCount="indefinite"
|
|
/>
|
|
</g>
|
|
</svg>
|
|
);
|
|
}
|