quivr/frontend/app/user/components/BrainConsumption.tsx
Zineb El Bachiri 1d7bc8a5bc
Devx/add linter rules (#331)
* remove duplicate import

* 🚧 add new linter configuration

* 🧑‍💻  add and run prettier

* 🐛 add babel parser for linter

* 🧑‍💻 add lint-fix command

* 🚨 use lint-fix

* 🚨 remove 'FC' as a type. Use const and JSX.Element

* 🚨 enforce arrow function rule from linter

* 🔥 delete unused file

* 🚨 adding /* eslint-disable */ in failing files

* 💩 add ts-expect-error to Victory components
2023-06-15 11:52:46 +02:00

48 lines
1.2 KiB
TypeScript

import { GiBrain } from "react-icons/gi";
import { UserStats } from "../../../lib/types/User";
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%",
}}
className="fill-green-200 stroke-black stroke-1"
/>
);
const fillingIcon = (
<GiBrain
style={{
position: "absolute",
width: "100%",
height: "100%",
clipPath: `inset(${(1 - brainFilling) * 100}% 0 0 0)`,
}}
className="fill-pink-300 stroke-black stoke-1"
/>
);
return (
<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>
</div>
);
};