import * as React from "react";
import { FunctionComponent } from "react";
import { Context } from "../context/context";
import { getColorByBrightness } from "../util/ColorUtil";

const Button: FunctionComponent<{
  context: Context;
  text: String;
  onClick: () => void;
  color: string;
}> = ({ context, text, color, onClick }) => {
  const textColor = getColorByBrightness(
    color,
    context.themeManager.theme.textColor,
    context.themeManager.theme.textLightColor
  );
  return (
    <button
      onClick={onClick}
      style={{
        background: color,
        color: textColor,
        margin: "5px",
        padding: "10px",
        border: "none",
        borderRadius: "4vw",
      }}
    >
      {text}
    </button>
  );
};

export default Button;
