otterscan/src/components/PercentageGauge.tsx

35 lines
861 B
TypeScript
Raw Normal View History

2021-07-29 00:28:02 +00:00
import React from "react";
type PercentageGaugeProps = {
perc: number;
2021-08-08 05:36:26 +00:00
bgColor: string;
bgColorPerc: string;
textColor: string;
2021-07-29 00:28:02 +00:00
};
const PercentageGauge: React.FC<PercentageGaugeProps> = ({
perc,
2021-08-08 05:36:26 +00:00
bgColor,
bgColorPerc,
textColor,
2021-07-29 00:28:02 +00:00
}) => (
<div className="w-60 h-6 border-l-2 border-gray-400 relative">
<div className="flex absolute w-full h-full">
2021-08-08 05:36:26 +00:00
<div className={`my-auto h-5 rounded-r-lg w-full ${bgColor}`}></div>
2021-07-29 00:28:02 +00:00
</div>
<div className="flex absolute w-full h-full">
<div
2021-08-08 05:36:26 +00:00
className={`my-auto h-5 rounded-r-lg ${bgColorPerc}`}
2021-07-29 00:28:02 +00:00
style={{ width: `${perc}%` }}
></div>
</div>
<div
2021-08-08 05:36:26 +00:00
className={`flex absolute w-full h-full mix-blend-multiply text-sans ${textColor}`}
2021-07-29 00:28:02 +00:00
>
<span className="m-auto">{perc}%</span>
</div>
</div>
);
export default React.memo(PercentageGauge);