import { Slider, Label, Typography, Input } from "@heroui/react"; import { useEffect, type ChangeEvent, type Dispatch, type SetStateAction, } from "react"; import { AgentInfo, WeaponInfo } from "~/types/skin"; export function Float({ skin, setSkin, acceptInput = false, hasLabel = false, }: { skin: WeaponInfo; setSkin: Dispatch>; minFloat?: number; maxFloat?: number; acceptInput?: boolean; hasLabel?: boolean; }) { useEffect(() => { const newSkin = new WeaponInfo(skin); newSkin.float = Math.max( skin.min_float, Math.min(skin.max_float, skin.float), ); setSkin(newSkin); }, [skin.min_float, skin.max_float]); const handleChange = (newValue: number | number[]) => { const val = Array.isArray(newValue) ? newValue[0] : newValue; const newSkin = new WeaponInfo(skin); newSkin.float = Math.max(skin.min_float, Math.min(skin.max_float, val)); setSkin(newSkin); }; const handleInputChange = (event: ChangeEvent) => { const val = event.currentTarget.valueAsNumber; const newSkin = new WeaponInfo(skin); newSkin.float = Math.max(skin.min_float, Math.min(skin.max_float, val)); setSkin(newSkin); }; return ( <> {hasLabel && (
Float
)}
); }