import React from "react"
import Slider from "@mui/material/Slider"
import "./index.less"
export default (props) => {
const [values, setValues] = React.useState(props.ctx.currentValue ?? {})
const handleOnChange = (key, value) => {
setValues((prev) => {
return {
...prev,
[key]: value
}
})
}
const handleChangeCommitted = (key, value) => {
props.ctx.dispatchUpdate(values)
}
React.useEffect(() => {
if (props.ctx.currentValue) {
setValues(props.ctx.currentValue)
}
}, [props.ctx.currentValue])
return
Threshold
handleChangeCommitted("threshold", value)}
onChange={(e, value) => handleOnChange("threshold", value)}
value={values?.threshold ?? 0}
orientation="vertical"
aria-label="Threshold"
valueLabelDisplay="auto"
step={0.1}
min={-100}
max={0}
disabled={props.disabled}
/>
{values?.threshold ?? 0} dB
Knee
handleChangeCommitted("knee", value)}
onChange={(e, value) => handleOnChange("knee", value)}
value={values?.knee ?? 0}
orientation="vertical"
aria-label="Knee"
valueLabelDisplay="auto"
step={0.1}
min={0}
max={40}
disabled={props.disabled}
/>
{values?.knee ?? 0} dB
Ratio
handleChangeCommitted("ratio", value)}
onChange={(e, value) => handleOnChange("ratio", value)}
value={values?.ratio ?? 0}
orientation="vertical"
aria-label="Ratio"
valueLabelDisplay="auto"
step={0.1}
min={1}
max={20}
disabled={props.disabled}
/>
{values?.ratio ?? 0} : 1
Attack
handleChangeCommitted("attack", value)}
onChange={(e, value) => handleOnChange("attack", value)}
value={values?.attack ?? 0}
orientation="vertical"
aria-label="Attack"
valueLabelDisplay="auto"
step={0.1}
min={0}
max={1}
disabled={props.disabled}
/>
{values?.attack ?? 0} s
Release
handleChangeCommitted("release", value)}
onChange={(e, value) => handleOnChange("release", value)}
value={values?.release ?? 0}
orientation="vertical"
aria-label="Release"
valueLabelDisplay="auto"
step={0.1}
min={0}
max={1}
disabled={props.disabled}
/>
{values?.release ?? 0} s
}