2020-04-15 11:42:11 +00:00
|
|
|
import React from "react";
|
|
|
|
|
import BaseControl, { ControlProps } from "./BaseControl";
|
2021-03-15 12:17:56 +00:00
|
|
|
import StepComponent from "components/ads/StepComponent";
|
2020-04-15 11:42:11 +00:00
|
|
|
class StepControl extends BaseControl<StepControlProps> {
|
|
|
|
|
getStepTypeControls = () => {
|
|
|
|
|
const { stepType } = this.props;
|
|
|
|
|
if (stepType === "ZOOM_PERCENTAGE") {
|
|
|
|
|
return {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 100,
|
|
|
|
|
steps: 5,
|
|
|
|
|
displayFormat: (value: number): string => {
|
|
|
|
|
return `${value}%`;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
min: 0,
|
|
|
|
|
max: 100,
|
|
|
|
|
steps: 1,
|
|
|
|
|
displayFormat: (value: number): string => {
|
|
|
|
|
return `${value}`;
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { min, max, steps, displayFormat } = this.getStepTypeControls();
|
|
|
|
|
return (
|
|
|
|
|
<StepComponent
|
2021-04-28 10:28:39 +00:00
|
|
|
displayFormat={displayFormat}
|
2020-04-15 11:42:11 +00:00
|
|
|
max={max}
|
2021-04-28 10:28:39 +00:00
|
|
|
min={min}
|
2020-04-15 11:42:11 +00:00
|
|
|
onChange={(value: number) => {
|
|
|
|
|
this.updateProperty(this.props.propertyName, value);
|
|
|
|
|
}}
|
2021-04-28 10:28:39 +00:00
|
|
|
steps={steps}
|
|
|
|
|
value={this.props.propertyValue}
|
2020-04-15 11:42:11 +00:00
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static getControlType() {
|
|
|
|
|
return "STEP";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export type StepType = "ZOOM_PERCENTAGE";
|
|
|
|
|
|
|
|
|
|
export interface StepControlProps extends ControlProps {
|
|
|
|
|
stepType: StepType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default StepControl;
|