mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-23 15:17:09 +00:00
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:
22
src/app/components/customized/CustomizedSlider.tsx
Normal file
22
src/app/components/customized/CustomizedSlider.tsx
Normal 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>
|
||||
}
|
||||
Reference in New Issue
Block a user