2023-06-05 18:58:59 +03:00
|
|
|
import { GiBrain } from "react-icons/gi";
|
2023-06-15 12:52:46 +03:00
|
|
|
|
2023-06-13 17:33:41 +03:00
|
|
|
import { UserStats } from "../../../lib/types/User";
|
2023-06-05 18:58:59 +03:00
|
|
|
|
|
|
|
export const BrainConsumption = (userStats: UserStats): JSX.Element => {
|
|
|
|
const { current_brain_size, max_brain_size } = userStats;
|
|
|
|
const brainFilling = current_brain_size / max_brain_size;
|
|
|
|
|
|
|
|
const backgroundIcon = (
|
|
|
|
<GiBrain
|
|
|
|
style={{
|
|
|
|
position: "absolute",
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
}}
|
2023-06-06 18:32:48 +03:00
|
|
|
className="fill-green-200 stroke-black stroke-1"
|
2023-06-05 18:58:59 +03:00
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
const fillingIcon = (
|
|
|
|
<GiBrain
|
|
|
|
style={{
|
|
|
|
position: "absolute",
|
|
|
|
width: "100%",
|
|
|
|
height: "100%",
|
|
|
|
clipPath: `inset(${(1 - brainFilling) * 100}% 0 0 0)`,
|
|
|
|
}}
|
2023-06-06 18:32:48 +03:00
|
|
|
className="fill-pink-300 stroke-black stoke-1"
|
2023-06-05 18:58:59 +03:00
|
|
|
/>
|
|
|
|
);
|
2023-06-15 12:52:46 +03:00
|
|
|
|
2023-06-05 18:58:59 +03:00
|
|
|
return (
|
2023-06-06 18:32:48 +03:00
|
|
|
<div className="flex flex-col items-center justify-center w-fit">
|
|
|
|
<div className="w-24 h-24 relative">
|
|
|
|
{backgroundIcon}
|
|
|
|
{fillingIcon}
|
|
|
|
</div>
|
|
|
|
<div className="flex flex-col items-center justify-center">
|
|
|
|
<span className="font-semibold">
|
|
|
|
{/* Percentage of brain space left */}
|
|
|
|
{(100 - brainFilling * 100).toFixed(2)}%{" "}
|
|
|
|
</span>
|
|
|
|
<span className="text-sm opacity-50">Empty</span>
|
|
|
|
</div>
|
2023-06-05 18:58:59 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|