Update loading components
This commit is contained in:
@@ -1,22 +1,32 @@
|
||||
import type { LoadingBarsProps } from "$/types/LoadingTypes";
|
||||
import { usePrefersReducedMotion } from "$/util/AccessibilityUtil";
|
||||
import { useId } from "react";
|
||||
|
||||
|
||||
export default function FadingBars({
|
||||
size,
|
||||
width,
|
||||
height,
|
||||
className,
|
||||
animationDuration = 0.75,
|
||||
animationDuration = 750,
|
||||
color,
|
||||
stroke,
|
||||
fill
|
||||
}: LoadingBarsProps){
|
||||
fill,
|
||||
ariaLabel = "Loading"
|
||||
}: Readonly<LoadingBarsProps>){
|
||||
//https://github.com/n3r4zzurr0/svg-spinners/blob/main/svg-smil/bars-fade.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"
|
||||
>
|
||||
@@ -27,14 +37,14 @@ export default function FadingBars({
|
||||
height="14"
|
||||
opacity="1"
|
||||
className={className}
|
||||
stroke={stroke}
|
||||
fill={fill}
|
||||
stroke={color ?? stroke}
|
||||
fill={color ?? fill}
|
||||
>
|
||||
<animate
|
||||
id={`rectangle1_${id}`}
|
||||
begin={`0;rectangle3_${id}.end-${animationDuration / 3}s`}
|
||||
begin={`0;rectangle3_${id}.end-${dur / 3}s`}
|
||||
attributeName="opacity"
|
||||
dur={animationDuration}
|
||||
dur={dur}
|
||||
values="1;.2"
|
||||
fill="freeze"
|
||||
/>
|
||||
@@ -46,13 +56,13 @@ export default function FadingBars({
|
||||
height="14"
|
||||
opacity=".4"
|
||||
className={className}
|
||||
stroke={stroke}
|
||||
fill={fill}
|
||||
stroke={color ?? stroke}
|
||||
fill={color ?? fill}
|
||||
>
|
||||
<animate
|
||||
begin={`rectangle1_${id}.begin+${animationDuration / 5}s`}
|
||||
begin={`rectangle1_${id}.begin+${dur / 5}s`}
|
||||
attributeName="opacity"
|
||||
dur={animationDuration}
|
||||
dur={dur}
|
||||
values="1;.2"
|
||||
fill="freeze"
|
||||
/>
|
||||
@@ -64,14 +74,14 @@ export default function FadingBars({
|
||||
height="14"
|
||||
opacity=".3"
|
||||
className={className}
|
||||
stroke={stroke}
|
||||
fill={fill}
|
||||
stroke={color ?? stroke}
|
||||
fill={color ?? fill}
|
||||
>
|
||||
<animate
|
||||
id={`rectangle3_${id}`}
|
||||
begin={`rectangle1_${id}.begin+${animationDuration * 2 / 5}s`}
|
||||
begin={`rectangle1_${id}.begin+${dur * 2 / 5}s`}
|
||||
attributeName="opacity"
|
||||
dur={animationDuration}
|
||||
dur={dur}
|
||||
values="1;.2"
|
||||
fill="freeze"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user