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(() => {
setValues(props.ctx.currentValue)
}, [props.ctx.currentValue])
return
Threshold
handleChangeCommitted("threshold", value)}
onChange={(e, value) => handleOnChange("threshold", value)}
value={values.threshold}
orientation="vertical"
aria-label="Threshold"
valueLabelDisplay="auto"
step={0.1}
min={-100}
max={0}
disabled={props.disabled}
/>
{values.threshold} dB
Knee
handleChangeCommitted("knee", value)}
onChange={(e, value) => handleOnChange("knee", value)}
value={values.knee}
orientation="vertical"
aria-label="Knee"
valueLabelDisplay="auto"
step={0.1}
min={0}
max={40}
disabled={props.disabled}
/>
{values.knee} dB
Ratio
handleChangeCommitted("ratio", value)}
onChange={(e, value) => handleOnChange("ratio", value)}
value={values.ratio}
orientation="vertical"
aria-label="Ratio"
valueLabelDisplay="auto"
step={0.1}
min={1}
max={20}
disabled={props.disabled}
/>
{values.ratio} : 1
Attack
handleChangeCommitted("attack", value)}
onChange={(e, value) => handleOnChange("attack", value)}
value={values.attack}
orientation="vertical"
aria-label="Attack"
valueLabelDisplay="auto"
step={0.1}
min={0}
max={1}
disabled={props.disabled}
/>
{values.attack} s
Release
handleChangeCommitted("release", value)}
onChange={(e, value) => handleOnChange("release", value)}
value={values.release}
orientation="vertical"
aria-label="Release"
valueLabelDisplay="auto"
step={0.1}
min={0}
max={1}
disabled={props.disabled}
/>
{values.release} s
}