mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-18 21:20:55 -05:00
34 lines
653 B
TypeScript
34 lines
653 B
TypeScript
import { CircularProgress, CircularProgressProps } from "@chakra-ui/react";
|
|
|
|
interface Props {
|
|
currentLength: number;
|
|
maxLength: number;
|
|
}
|
|
|
|
const getColor = (value: number) => {
|
|
if (value >= 100) return "red.500";
|
|
|
|
if (value >= 75) return "yellow.500";
|
|
|
|
return "theme.500";
|
|
};
|
|
|
|
const LimitProgress: React.FC<Props & CircularProgressProps> = ({
|
|
currentLength,
|
|
maxLength,
|
|
...props
|
|
}) => {
|
|
const value = Math.floor((currentLength / maxLength) * 100);
|
|
return (
|
|
<CircularProgress
|
|
size="20px"
|
|
value={value}
|
|
thickness="16px"
|
|
color={getColor(value)}
|
|
{...props}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default LimitProgress;
|