frontpage/components/Spinner.tsx

19 lines
928 B
TypeScript
Raw Permalink Normal View History

2022-06-15 00:35:49 +02:00
import type { NextPage } from "next";
import styles from "../styles/Spinner.module.scss";
2022-09-30 19:23:14 +02:00
const Spinner: NextPage<{size: number, color?: string}> = ({ size, color }) => {
2022-06-15 00:35:49 +02:00
const diameterY = 300;
const padding = 25;
const rad = (angle: number) => angle * (Math.PI / 180);
const side = (diameterY / 2) / Math.sin(rad(60));
const x0 = side * Math.sin(rad(30));
const vbSizeX = (2 * x0) + side + (2 * padding);
const vbSizeY = diameterY + (2 * padding);
2022-10-29 21:13:28 +02:00
return <div style={{height: size, width: size}} className={styles.spinnerContainer}><svg height="100%" width="100%" viewBox={`-${padding} -${padding} ${vbSizeX} ${vbSizeY}`} className={styles.spinner}>
2022-10-03 01:19:28 +02:00
<polygon points={`${x0},${diameterY} 0,${diameterY/2} ${x0},0 ${x0+side},0 ${2*x0 + side},${diameterY/2} ${x0+side},${diameterY}`} className={styles.spinnerPath} style={{stroke: color}} />
2022-06-15 00:35:49 +02:00
</svg></div>;
};
export default Spinner;