// The controls for one lab, declared by the lab and laid out in a single row // above its figures. import type { Params, ParamValue } from '../engine/types.ts' import type { Control } from './types.ts' export default function Controls({ controls, params, onChange, }: { controls: Control[] params: Params onChange: (key: string, value: ParamValue) => void }) { if (controls.length === 0) return null return (
{controls.map((c) => { if (c.kind === 'select') { return ( ) } if (c.kind === 'toggle') { return ( ) } const value = Number(params[c.key]) const fmt = c.format ?? ((v: number) => String(v)) if (c.values) { const idx = Math.max( 0, c.values.findIndex((v) => v === value), ) return ( ) } return ( ) })}
) }