Customized worlds (#387)

* Customized tool UI

* Working version of the customized generator

* Error reporting and only allow 1.20 for now
This commit is contained in:
Misode
2023-06-16 04:18:33 +02:00
committed by GitHub
parent 9e68e0495b
commit 64140aec92
21 changed files with 1123 additions and 14 deletions

View File

@@ -0,0 +1,22 @@
import type { NodeChildren } from '@mcschema/core'
import { NumberInput, RangeInput } from '../index.js'
import { CustomizedInput } from './CustomizedInput.jsx'
interface Props {
label: string,
value: number,
min: number,
max: number,
step?: number,
initial?: number,
error?: string,
onChange: (value: number) => void,
children?: NodeChildren,
}
export function CustomizedSlider(props: Props) {
const isInteger = (props.step ?? 1) >= 1
return <CustomizedInput {...props}>
<RangeInput value={props.value} min={props.min} max={props.max} step={props.step ?? 1} onChange={props.onChange} />
<NumberInput value={isInteger ? props.value : props.value.toFixed(3)} step={Math.max(1, props.step ?? 1)} onChange={props.onChange} />
</CustomizedInput>
}