PromucFlow_constructor/app/client/src/components/propertyControls/StepControl.tsx
ram-primathon 3b0fb539d5
Property Pane re design (#3057)
Co-authored-by: devrk96 <rohit.kumawat@primathon.in>
Co-authored-by: hetunandu <hetu@appsmith.com>
Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
Co-authored-by: Vicky Bansal <67091118+vicky-primathon@users.noreply.github.com>
Co-authored-by: nandan.anantharamu <nandan.anantharamu@thoughtspot.com>
2021-03-15 17:47:56 +05:30

55 lines
1.2 KiB
TypeScript

import React from "react";
import BaseControl, { ControlProps } from "./BaseControl";
import StepComponent from "components/ads/StepComponent";
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
min={min}
max={max}
steps={steps}
value={this.props.propertyValue}
onChange={(value: number) => {
this.updateProperty(this.props.propertyName, value);
}}
displayFormat={displayFormat}
/>
);
}
static getControlType() {
return "STEP";
}
}
export type StepType = "ZOOM_PERCENTAGE";
export interface StepControlProps extends ControlProps {
stepType: StepType;
}
export default StepControl;