Update loading components

This commit is contained in:
2026-02-24 22:16:46 -05:00
parent a61e7ce19a
commit 637b3a0c34
43 changed files with 1363 additions and 930 deletions

View File

@@ -1,23 +1,34 @@
import type { CirclePulsingDotsProps } from "$/types/LoadingTypes";
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
import { useId } from "react";
export default function CirclePulsingDots({
size,
width,
height,
className,
rotationAnimationDuration = 6,
growingAnimationDuration = 0.6,
rotationAnimationDuration = 6000,
growingAnimationDuration = 600,
color,
stroke,
fill
}: CirclePulsingDotsProps){
fill,
ariaLabel = "Loading"
}: Readonly<CirclePulsingDotsProps>){
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/12-dots-scale-rotate.svg
const id = crypto.randomUUID().replaceAll("-", "");
const id = useId();
const reducedMotion = usePrefersReducedMotion();
const rotationAnimationDur = reducedMotion ? rotationAnimationDuration / 100 : rotationAnimationDuration / 1000;
const growingAnimationDur = reducedMotion ? growingAnimationDuration / 100 : growingAnimationDuration / 1000;
return (
<svg
width={width}
height={height}
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"
>
@@ -27,15 +38,15 @@ export default function CirclePulsingDots({
cy="3"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle1_${id}`}
begin={`0;circle3_${id}.end-${growingAnimationDuration * 5 / 6}s`}
begin={`0;circle3_${id}.end-${growingAnimationDur * 5 / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -45,15 +56,15 @@ export default function CirclePulsingDots({
cy="4.21"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle2_${id}`}
begin={`circle1_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle1_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -63,15 +74,15 @@ export default function CirclePulsingDots({
cy="4.21"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle3_${id}`}
begin={`circle5_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle5_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -81,15 +92,15 @@ export default function CirclePulsingDots({
cy="7.50"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle4_${id}`}
begin={`circle2_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle2_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -99,15 +110,15 @@ export default function CirclePulsingDots({
cy="7.50"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle5_${id}`}
begin={`circle7_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle7_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -117,15 +128,15 @@ export default function CirclePulsingDots({
cy="12.00"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle6_${id}`}
begin={`circle4_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle4_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -135,15 +146,15 @@ export default function CirclePulsingDots({
cy="12.00"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle7_${id}`}
begin={`circle9_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle9_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -153,15 +164,15 @@ export default function CirclePulsingDots({
cy="16.50"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle8_${id}`}
begin={`circle6_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle6_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -171,15 +182,15 @@ export default function CirclePulsingDots({
cy="16.50"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle9_${id}`}
begin={`circle11_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle11_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -189,15 +200,15 @@ export default function CirclePulsingDots({
cy="19.79"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle10_${id}`}
begin={`circle8_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle8_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -207,15 +218,15 @@ export default function CirclePulsingDots({
cy="19.79"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle11_${id}`}
begin={`circle12_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle12_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -225,15 +236,15 @@ export default function CirclePulsingDots({
cy="21"
r="1"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`circle12_${id}`}
begin={`circle10_${id}.begin+${growingAnimationDuration / 6}s`}
begin={`circle10_${id}.begin+${growingAnimationDur / 6}s`}
attributeName="r"
calcMode="spline"
dur={growingAnimationDuration}
dur={growingAnimationDur}
values="1;2;1"
keySplines=".27,.42,.37,.99;.53,0,.61,.73"
/>
@@ -241,7 +252,7 @@ export default function CirclePulsingDots({
<animateTransform
attributeName="transform"
type="rotate"
dur={rotationAnimationDuration}
dur={rotationAnimationDur}
values="360 12 12;0 12 12"
repeatCount="indefinite"
/>