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 { LoadingBarsProps } from "$/types/LoadingTypes";
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
import { useId } from "react";
export default function CenterGrowingBars({
size,
width,
height,
className,
animationDuration = 0.6,
animationDuration = 600,
color,
stroke,
fill
}: LoadingBarsProps){
fill,
ariaLabel = "Loading"
}: Readonly<LoadingBarsProps>){
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/bars-scale-middle.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"
>
@@ -26,22 +36,22 @@ export default function CenterGrowingBars({
width="2.8"
height="12"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
begin={`rectangle3_${id}.begin+${animationDuration * 2 / 3}s`}
begin={`rectangle3_${id}.begin+${dur * 2 / 3}s`}
attributeName="y"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="6;1;6"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
<animate
begin={`rectangle3_${id}.begin+${animationDuration * 2 / 3}s`}
begin={`rectangle3_${id}.begin+${dur * 2 / 3}s`}
attributeName="height"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="12;22;12"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
@@ -52,22 +62,22 @@ export default function CenterGrowingBars({
width="2.8"
height="12"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
begin={`rectangle3_${id}.begin+${animationDuration / 3}s`}
begin={`rectangle3_${id}.begin+${dur / 3}s`}
attributeName="y"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="6;1;6"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
<animate
begin={`rectangle3_${id}.begin+${animationDuration / 3}s`}
begin={`rectangle3_${id}.begin+${dur / 3}s`}
attributeName="height"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="12;22;12"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
@@ -78,23 +88,23 @@ export default function CenterGrowingBars({
width="2.8"
height="12"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`rectangle3_${id}`}
begin={`0;rectangle5_${id}.end-${animationDuration / 6}s`}
begin={`0;rectangle5_${id}.end-${dur / 6}s`}
attributeName="y"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="6;1;6"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
<animate
begin={`0;rectangle5_${id}.end-${animationDuration / 6}s`}
begin={`0;rectangle5_${id}.end-${dur / 6}s`}
attributeName="height"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="12;22;12"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
@@ -105,22 +115,22 @@ export default function CenterGrowingBars({
width="2.8"
height="12"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
begin={`rectangle3_${id}.begin+${animationDuration / 3}s`}
begin={`rectangle3_${id}.begin+${dur / 3}s`}
attributeName="y"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="6;1;6"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
<animate
begin={`rectangle3_${id}.begin+${animationDuration / 3}s`}
begin={`rectangle3_${id}.begin+${dur / 3}s`}
attributeName="height"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="12;22;12"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
@@ -131,23 +141,23 @@ export default function CenterGrowingBars({
width="2.8"
height="12"
className={className}
stroke={stroke}
fill={fill}
stroke={color ?? stroke}
fill={color ?? fill}
>
<animate
id={`rectangle5_${id}`}
begin={`rectangle3_${id}.begin+${animationDuration * 2 / 3}s`}
begin={`rectangle3_${id}.begin+${dur * 2 / 3}s`}
attributeName="y"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="6;1;6"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>
<animate
begin={`rectangle3_${id}.begin+${animationDuration * 2 / 3}s`}
begin={`rectangle3_${id}.begin+${dur * 2 / 3}s`}
attributeName="height"
calcMode="spline"
dur={animationDuration}
dur={dur}
values="12;22;12"
keySplines=".14,.73,.34,1;.65,.26,.82,.45"
/>