2021-10-21 22:05:48 +02:00
|
|
|
import React from "react";
|
|
|
|
|
|
|
|
import "./Spinner.scss";
|
|
|
|
|
|
|
|
const Spinner = ({
|
|
|
|
size = "1em",
|
|
|
|
circleWidth = 8,
|
2023-05-24 16:40:20 +02:00
|
|
|
synchronized = false,
|
2021-10-21 22:05:48 +02:00
|
|
|
}: {
|
|
|
|
size?: string | number;
|
|
|
|
circleWidth?: number;
|
2023-05-24 16:40:20 +02:00
|
|
|
synchronized?: boolean;
|
2021-10-21 22:05:48 +02:00
|
|
|
}) => {
|
2023-05-24 16:40:20 +02:00
|
|
|
const mountTime = React.useRef(Date.now());
|
|
|
|
const mountDelay = -(mountTime.current % 1600);
|
|
|
|
|
2021-10-21 22:05:48 +02:00
|
|
|
return (
|
|
|
|
<div className="Spinner">
|
2023-05-24 16:40:20 +02:00
|
|
|
<svg
|
|
|
|
viewBox="0 0 100 100"
|
|
|
|
style={{
|
|
|
|
width: size,
|
|
|
|
height: size,
|
|
|
|
// fix for remounting causing spinner flicker
|
|
|
|
["--spinner-delay" as any]: synchronized ? `${mountDelay}ms` : 0,
|
|
|
|
}}
|
|
|
|
>
|
2021-10-21 22:05:48 +02:00
|
|
|
<circle
|
|
|
|
cx="50"
|
|
|
|
cy="50"
|
|
|
|
r={50 - circleWidth / 2}
|
|
|
|
strokeWidth={circleWidth}
|
|
|
|
fill="none"
|
|
|
|
strokeMiterlimit="10"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Spinner;
|