PromucFlow_constructor/app/client/src/widgets/ButtonWidget.tsx

46 lines
1.1 KiB
TypeScript
Raw Normal View History

2019-09-09 09:08:54 +00:00
import * as React from "react";
import BaseWidget, { WidgetProps, WidgetState } from "./BaseWidget";
import { WidgetType } from "../constants/WidgetConstants";
2019-10-21 15:12:45 +00:00
import ButtonComponent from "../components/canvas/Button";
import { ActionPayload } from "../constants/ActionConstants";
2019-03-18 13:50:24 +00:00
2019-09-09 09:08:54 +00:00
class ButtonWidget extends BaseWidget<ButtonWidgetProps, WidgetState> {
onButtonClick() {
super.executeAction(this.props.onClick);
}
getPageView() {
2019-03-18 13:50:24 +00:00
return (
<ButtonComponent
2019-03-19 14:05:48 +00:00
style={this.getPositionStyle()}
2019-03-18 13:50:24 +00:00
widgetId={this.props.widgetId}
widgetName={this.props.widgetName}
2019-03-18 13:50:24 +00:00
key={this.props.widgetId}
text={this.props.text}
onClick={() => {
this.onButtonClick();
}}
2019-03-18 13:50:24 +00:00
/>
2019-09-09 09:08:54 +00:00
);
2019-03-18 13:50:24 +00:00
}
getWidgetType(): WidgetType {
2019-09-09 09:08:54 +00:00
return "BUTTON_WIDGET";
2019-03-18 13:50:24 +00:00
}
}
export type ButtonStyle =
| "PRIMARY_BUTTON"
| "SECONDARY_BUTTON"
| "SUCCESS_BUTTON"
| "DANGER_BUTTON";
2019-09-12 08:11:25 +00:00
2019-09-09 09:08:54 +00:00
export interface ButtonWidgetProps extends WidgetProps {
2019-08-29 11:22:09 +00:00
text?: string;
buttonStyle?: ButtonStyle;
onClick?: ActionPayload[];
isDisabled?: boolean;
2019-03-18 13:50:24 +00:00
}
2019-09-09 09:08:54 +00:00
export default ButtonWidget;