PromucFlow_constructor/app/client/src/components/propertyControls/SwitchControl.tsx

32 lines
808 B
TypeScript
Raw Normal View History

import React from "react";
import BaseControl, { ControlProps } from "./BaseControl";
import { ControlWrapper, StyledSwitch } from "./StyledControls";
2019-11-25 05:07:27 +00:00
import { ControlType } from "constants/PropertyControlConstants";
class SwitchControl extends BaseControl<ControlProps> {
render() {
return (
2019-11-06 12:12:41 +00:00
<ControlWrapper orientation={"HORIZONTAL"}>
<label>{this.props.label}</label>
<StyledSwitch
onChange={this.onToggle}
defaultChecked={this.props.propertyValue}
large
/>
</ControlWrapper>
);
}
onToggle = () => {
this.updateProperty(this.props.propertyName, !this.props.propertyValue);
};
getControlType(): ControlType {
return "SWITCH";
}
}
export type SwitchControlProps = ControlProps;
export default SwitchControl;