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

106 lines
2.1 KiB
TypeScript

import type { LoadingDotsProps } from "$/types/LoadingTypes";
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
export default function CircleFadingDots({
size,
width,
height,
className,
animationDuration = 750,
color,
stroke,
fill,
ariaLabel = "Loading"
}: Readonly<LoadingDotsProps>){
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/6-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"
>
<g>
<circle
cx="12"
cy="2.5"
r="1.5"
opacity=".14"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
/>
<circle
cx="16.75"
cy="3.77"
r="1.5"
opacity=".29"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
/>
<circle
cx="20.23"
cy="7.25"
r="1.5"
opacity=".43"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
/>
<circle
cx="21.50"
cy="12.00"
r="1.5"
opacity=".57"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
/>
<circle
cx="20.23"
cy="16.75"
r="1.5"
opacity=".71"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
/>
<circle
cx="16.75"
cy="20.23"
r="1.5"
opacity=".86"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
/>
<circle
cx="12"
cy="21.5"
r="1.5"
className={className}
stroke={color ?? stroke}
fill={color ?? fill}
/>
<animateTransform
attributeName="transform"
type="rotate"
calcMode="discrete"
dur={dur}
values="0 12 12;30 12 12;60 12 12;90 12 12;120 12 12;150 12 12;180 12 12;210 12 12;240 12 12;270 12 12;300 12 12;330 12 12;360 12 12"
repeatCount="indefinite"
/>
</g>
</svg>
);
}