blob: b591d8abb921378907a997eefdf189f4921a3cd1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import React from "react";
import classnames from "classnames";
import { PaletteColorType } from "@/palette";
import "./Spinner.css";
export interface SpinnerProps {
size?: "sm" | "md" | "lg" | number | string;
color?: PaletteColorType;
}
export default function Spinner(
props: SpinnerProps
): React.ReactElement | null {
const { size, color } = props;
const calculatedSize =
size === "sm"
? "18px"
: size === "md"
? "30px"
: size === "lg"
? "42px"
: typeof size === "number"
? size
: size == null
? "20px"
: size;
const calculatedColor = color ?? "primary";
return (
<span
className={classnames("cru-spinner", `cru-color-${calculatedColor}`)}
style={{ width: calculatedSize, height: calculatedSize }}
/>
);
}
|