mancala/src/components/Button.tsx

41 lines
924 B
TypeScript
Raw Normal View History

2022-06-04 14:49:34 +03:00
import * as React from "react";
import { FunctionComponent } from "react";
2022-07-14 13:38:00 +03:00
import { Context } from "../context/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={{
2022-09-03 22:19:28 +03:00
backgroundColor: color,
2022-06-04 17:16:32 +03:00
color: textColor,
2022-06-04 14:49:34 +03:00
}}
>
2022-07-14 17:27:32 +03:00
<style jsx>{`
button {
margin: 5px;
padding: 10px;
border: none;
2022-07-23 00:25:10 +03:00
border-radius: 30px;
2022-09-03 22:19:28 +03:00
transition: color 0.5s;
transition: background-color 0.5s;
2022-07-14 17:27:32 +03:00
}
`}</style>
2022-06-04 14:49:34 +03:00
{text}
</button>
);
};
2021-07-02 23:13:38 +03:00
2022-06-04 14:49:34 +03:00
export default Button;