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 { getColorByLuminance } 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 = getColorByLuminance(
|
|
|
|
|
color,
|
|
|
|
|
context.themeManager.theme.primary,
|
|
|
|
|
context.themeManager.theme.primaryLight
|
|
|
|
|
);
|
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;
|