Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
import React from "react";
|
2022-06-03 05:07:02 +00:00
|
|
|
import BaseControl, { ControlData, ControlProps } from "./BaseControl";
|
2021-03-15 12:17:56 +00:00
|
|
|
import Switch from "components/ads/Switch";
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
|
|
|
|
|
class SwitchControl extends BaseControl<ControlProps> {
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
2021-03-15 12:17:56 +00:00
|
|
|
<Switch
|
2021-09-21 07:55:56 +00:00
|
|
|
checked={this.props.propertyValue}
|
|
|
|
|
className={this.props.propertyValue ? "checked" : "unchecked"}
|
2020-02-26 12:44:56 +00:00
|
|
|
defaultChecked={this.props.propertyValue}
|
|
|
|
|
large
|
2021-04-28 10:28:39 +00:00
|
|
|
onChange={this.onToggle}
|
2020-02-26 12:44:56 +00:00
|
|
|
/>
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onToggle = () => {
|
|
|
|
|
this.updateProperty(this.props.propertyName, !this.props.propertyValue);
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-14 05:35:16 +00:00
|
|
|
static getControlType() {
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
return "SWITCH";
|
|
|
|
|
}
|
2022-06-03 05:07:02 +00:00
|
|
|
|
|
|
|
|
static canDisplayValueInUI(config: ControlData, value: any): boolean {
|
|
|
|
|
return value === "true" || value === "false";
|
|
|
|
|
}
|
Property Pane Controls
- Fixes #121, #122, #123, #124, #90, #46, #65, #100, #101, #68, #102
2019-10-24 05:24:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type SwitchControlProps = ControlProps;
|
|
|
|
|
|
|
|
|
|
export default SwitchControl;
|