Fix build issue with types returned by the Slider component
This commit is contained in:
parent
6d35009593
commit
a6b678c6ae
@ -4,6 +4,13 @@ import { Slider } from 'primereact/slider';
|
|||||||
|
|
||||||
export default function AffinitySlider({ value, onChange }: { value: number, onChange: (value: number) => void }) {
|
export default function AffinitySlider({ value, onChange }: { value: number, onChange: (value: number) => void }) {
|
||||||
|
|
||||||
|
const toNumber = (value : number | [number, number]) => {
|
||||||
|
if(value instanceof Array) {
|
||||||
|
return value[0];
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
const label = (value: number) => {
|
const label = (value: number) => {
|
||||||
if (value < 0.2) {
|
if (value < 0.2) {
|
||||||
return 'Nemesis';
|
return 'Nemesis';
|
||||||
@ -24,7 +31,7 @@ export default function AffinitySlider({ value, onChange }: { value: number, onC
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Slider value={value} min={0} max={2} step={.1} onChange={(e) => onChange(e.value)} className='w-80 bg-gray-400' />
|
<Slider value={value} min={0} max={2} step={.1} onChange={(e) => onChange(toNumber(e.value))} className='w-80 bg-gray-400' />
|
||||||
<span className="px-4 w-1/5">
|
<span className="px-4 w-1/5">
|
||||||
{label(value)}
|
{label(value)}
|
||||||
</span>
|
</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user