What is the idiomatic way of having two input elements both showing the value of the same variable and controlling it? E.g. a number that can be set both on a range slider and on a numeric input field, while both are reflecting its value.
I tried so far:
viewof number = html`<input type="range">`
html`<input type="number" value="${number}"/>`
…but the number input only displays the value, does not control it.
Moreover, it would be great if there was a way to formulate this as a “component”, i.e. reusable in other contexts (maybe as a function?)
Combine the two inputs into a cell, and then use input event listeners to coordinate changes between them. The input events will bubble up so that viewof will respond to interaction on either input. You just need to set element.value on the element returned by the cell so that the desired value is exposed to other cells in the notebook.