2020-04-10 18:57:50 +00:00
|
|
|
import {ReactComponentBase} from "tc-shared/ui/react-elements/ReactComponentBase";
|
|
|
|
import * as React from "react";
|
|
|
|
const cssStyle = require("./Button.scss");
|
|
|
|
|
|
|
|
export interface ButtonProperties {
|
|
|
|
color?: "green" | "blue" | "red" | "purple" | "brown" | "yellow" | "default";
|
|
|
|
type?: "normal" | "small" | "extra-small";
|
|
|
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
|
|
|
disabled?: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface ButtonState {
|
|
|
|
disabled?: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Button extends ReactComponentBase<ButtonProperties, ButtonState> {
|
2020-04-18 17:37:30 +00:00
|
|
|
protected defaultState(): ButtonState {
|
2020-04-10 18:57:50 +00:00
|
|
|
return {
|
|
|
|
disabled: undefined
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<button
|
|
|
|
className={this.classList(
|
|
|
|
cssStyle.button,
|
|
|
|
cssStyle["color-" + this.props.color] || cssStyle["color-default"],
|
|
|
|
cssStyle["type-" + this.props.type] || cssStyle["type-normal"]
|
|
|
|
)}
|
|
|
|
disabled={this.state.disabled || this.props.disabled}
|
|
|
|
onClick={this.props.onClick}
|
|
|
|
>
|
|
|
|
{this.props.children}
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|