mancala/src/components/Button.tsx

35 lines
764 B
TypeScript
Raw Normal View History

2022-06-04 14:49:34 +03:00
import * as React from "react";
import { FunctionComponent } from "react";
2022-06-04 17:16:32 +03:00
import { Context } from "../context";
import { getColorByBrightness } from "../util/ColorUtil";
2021-07-02 23:13:38 +03:00
2022-06-04 14:49:34 +03:00
const Button: FunctionComponent<{
2022-06-04 17:16:32 +03:00
context: Context;
2022-06-04 14:49:34 +03:00
text: String;
onClick: () => void;
color: string;
2022-06-04 17:16:32 +03:00
}> = ({ context, text, color, onClick }) => {
const textColor = getColorByBrightness(
2022-06-04 17:16:32 +03:00
color,
2022-07-13 15:21:30 +03:00
context.themeManager.theme.textColor,
context.themeManager.theme.textLightColor
2022-06-04 17:16:32 +03:00
);
2022-06-04 14:49:34 +03:00
return (
<button
onClick={onClick}
style={{
background: color,
2022-06-04 17:16:32 +03:00
color: textColor,
2022-06-04 14:49:34 +03:00
margin: "5px",
padding: "10px",
border: "none",
borderRadius: "4vw",
}}
>
{text}
</button>
);
};
2021-07-02 23:13:38 +03:00
2022-06-04 14:49:34 +03:00
export default Button;