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,22 +1,32 @@
import type { LoadingDotsProps } from "$/types/LoadingTypes";
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
import { useId } from "react";
export default function SwellingDots({
size,
width,
height,
className,
animationDuration = 0.75,
animationDuration = 750,
color,
stroke,
fill
}: LoadingDotsProps){
fill,
ariaLabel = "Loading"
}: Readonly<LoadingDotsProps>){
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/3-dots-scale.svg
const id = crypto.randomUUID().replaceAll("-", "");
const id = useId();
const reducedMotion = usePrefersReducedMotion();
const dur = reducedMotion ? animationDuration / 100 : animationDuration / 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"
>
@@ -25,14 +35,14 @@ export default function SwellingDots({
cy="12"
r="3"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`firstDot_${id}`}
begin={`0;lastDot_${id}.end-${animationDuration / 3}s`}
begin={`0;lastDot_${id}.end-${dur / 3}s`}
attributeName="r"
dur={animationDuration}
dur={dur}
values="3;.2;3"
/>
</circle>
@@ -41,13 +51,13 @@ export default function SwellingDots({
cy="12"
r="3"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
begin={`firstDot_${id}.end-${animationDuration * 4 / 5}s`}
begin={`firstDot_${id}.end-${dur * 4 / 5}s`}
attributeName="r"
dur={animationDuration}
dur={dur}
values="3;.2;3"
/>
</circle>
@@ -56,14 +66,14 @@ export default function SwellingDots({
cy="12"
r="3"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`lastDot_${id}`}
begin={`firstDot_${id}.end-${animationDuration * 2 / 3}s`}
begin={`firstDot_${id}.end-${dur * 2 / 3}s`}
attributeName="r"
dur={animationDuration}
dur={dur}
values="3;.2;3"
/>
</circle>