69 lines
1.5 KiB
TypeScript
69 lines
1.5 KiB
TypeScript
import type { LoadingPulseProps } from "$/types/LoadingTypes";
|
|
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
|
|
|
|
|
|
export default function WaveDrop({
|
|
size,
|
|
width,
|
|
height,
|
|
className,
|
|
animationDuration = 1200,
|
|
color,
|
|
stroke,
|
|
fill,
|
|
ariaLabel = "Loading"
|
|
}: Readonly<LoadingPulseProps>){
|
|
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/pulse-ring.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"
|
|
>
|
|
<path
|
|
d="M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,20a9,9,0,1,1,9-9A9,9,0,0,1,12,21Z"
|
|
transform="translate(12, 12) scale(0)"
|
|
className={className}
|
|
stroke={color ?? stroke}
|
|
fill={color ?? fill}
|
|
>
|
|
<animateTransform
|
|
attributeName="transform"
|
|
calcMode="spline"
|
|
type="translate"
|
|
dur={dur}
|
|
values="12 12;0 0"
|
|
keySplines=".52,.6,.25,.99"
|
|
repeatCount="indefinite"
|
|
/>
|
|
<animateTransform
|
|
attributeName="transform"
|
|
calcMode="spline"
|
|
additive="sum"
|
|
type="scale"
|
|
dur={dur}
|
|
values="0;1"
|
|
keySplines=".52,.6,.25,.99"
|
|
repeatCount="indefinite"
|
|
/>
|
|
<animate
|
|
attributeName="opacity"
|
|
calcMode="spline"
|
|
dur={dur}
|
|
values="1;0"
|
|
keySplines=".52,.6,.25,.99"
|
|
repeatCount="indefinite"
|
|
/>
|
|
</path>
|
|
</svg>
|
|
);
|
|
}
|