Files
MattrixwvReactComponents/lib/component/loading/dot/PulsingDots.tsx

79 lines
1.5 KiB
TypeScript

import type { LoadingDotsProps } from "$/types/LoadingTypes";
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
export default function PulsingDots({
size,
width,
height,
className,
animationDuration = 750,
color,
stroke,
fill,
ariaLabel = "Loading"
}: Readonly<LoadingDotsProps>){
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/3-dots-scale-middle.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="4"
cy="12"
r="1.5"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
attributeName="r"
dur={dur}
values="1.5;3;1.5"
repeatCount="indefinite"
/>
</circle>
<circle
cx="12"
cy="12"
r="3"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
attributeName="r"
dur={dur}
values="3;1.5;3"
repeatCount="indefinite"
/>
</circle>
<circle
cx="20"
cy="12"
r="1.5"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
attributeName="r"
dur={dur}
values="1.5;3;1.5"
repeatCount="indefinite"
/>
</circle>
</svg>
);
}