import styles from "./InfoBlock.module.css";
import { getContrastingTextColor } from "@/utils/getContrastingTextColor";

type InfoBlockProps = {
  stat: string;
  content: string;
  colour?: string | null;
};

const InfoBlock = (props: InfoBlockProps) => (
  <div
    className={styles.info}
    style={
      props.colour
        ? {
            backgroundColor: props.colour,
            color: getContrastingTextColor(props.colour),
          }
        : undefined
    }
  >
    <h4 className="h1">{props.stat}</h4>
    <h5 className="m-none">{props.content}</h5>
  </div>
);

export default InfoBlock;
