add Penalty Decay slider to Chat page

This commit is contained in:
josc146
2024-02-03 22:40:30 +08:00
parent 843840baa0
commit 932281db0a
8 changed files with 42 additions and 9 deletions

View File

@@ -8,8 +8,9 @@ export const NumberInput: FC<{
max: number,
step?: number,
onChange?: (ev: React.ChangeEvent<HTMLInputElement>, data: SliderOnChangeData) => void
style?: CSSProperties
}> = ({ value, min, max, step, onChange, style }) => {
style?: CSSProperties,
toFixed?: number
}> = ({ value, min, max, step, onChange, style, toFixed = 2 }) => {
return (
<Input type="number" style={style} value={value.toString()} min={min} max={max} step={step}
onChange={(e, data) => {
@@ -22,7 +23,7 @@ export const NumberInput: FC<{
value = Number(((
Math.round((value - offset) / step) * step)
+ offset)
.toFixed(2)); // avoid precision issues
.toFixed(toFixed)); // avoid precision issues
}
onChange(e, { value: Math.max(Math.min(value, max), min) });
}