import state, { useSelector } from "state" import styled from "styles" import { ControlType, NumberCodeControl, SelectCodeControl, TextCodeControl, VectorCodeControl, } from "types" export default function Control({ id }: { id: string }) { const control = useSelector((s) => s.data.codeControls[id]) if (!control) return null return ( <> {control.type === ControlType.Number ? ( ) : control.type === ControlType.Vector ? ( ) : control.type === ControlType.Text ? ( ) : control.type === ControlType.Select ? ( ) : null} ) } function NumberControl({ id, min, max, step, value }: NumberCodeControl) { return ( state.send("CHANGED_CODE_CONTROL", { [id]: Number(e.currentTarget.value), }) } /> state.send("CHANGED_CODE_CONTROL", { [id]: Number(e.currentTarget.value), }) } /> ) } function VectorControl({ id, value, isNormalized }: VectorCodeControl) { return ( state.send("CHANGED_CODE_CONTROL", { [id]: [Number(e.currentTarget.value), value[1]], }) } /> state.send("CHANGED_CODE_CONTROL", { [id]: [Number(e.currentTarget.value), value[1]], }) } /> state.send("CHANGED_CODE_CONTROL", { [id]: [value[0], Number(e.currentTarget.value)], }) } /> state.send("CHANGED_CODE_CONTROL", { [id]: [value[0], Number(e.currentTarget.value)], }) } /> ) } function TextControl({}: TextCodeControl) { return <> } function SelectControl({}: SelectCodeControl) { return <> } const Inputs = styled("div", { display: "flex", gap: "8px", height: "100%", "& input": { font: "$ui", width: "64px", fontSize: "$1", border: "1px solid $inputBorder", backgroundColor: "$input", color: "$text", height: "100%", padding: "0px 6px", }, "& input[type='range']": { padding: 0, flexGrow: 2, }, })