mirror of
https://github.com/revoltchat/revite.git
synced 2024-12-27 07:52:11 -05:00
23 lines
615 B
TypeScript
23 lines
615 B
TypeScript
/* eslint-disable react-hooks/rules-of-hooks */
|
|
import { useState } from "preact/hooks";
|
|
|
|
const counts: { [key: string]: number } = {};
|
|
|
|
export default function PaintCounter({
|
|
small,
|
|
always,
|
|
}: {
|
|
small?: boolean;
|
|
always?: boolean;
|
|
}) {
|
|
if (import.meta.env.PROD && !always) return null;
|
|
|
|
const [uniqueId] = useState(`${Math.random()}`);
|
|
const count = counts[uniqueId] ?? 0;
|
|
counts[uniqueId] = count + 1;
|
|
return (
|
|
<div style={{ textAlign: "center", fontSize: "0.8em" }}>
|
|
{small ? <>P: {count + 1}</> : <>Painted {count + 1} time(s).</>}
|
|
</div>
|
|
);
|
|
}
|