1
0
mirror of https://gitlab.com/timvisee/send.git synced 2024-11-14 23:22:36 +01:00
send/app/ui/selectbox.js
2018-11-16 12:39:36 -08:00

34 lines
731 B
JavaScript

const html = require('choo/html');
module.exports = function(selected, options, translate, changed) {
let x = selected;
return html`
<select
class="appearance-none cursor-pointer border rounded-sm bg-blue-lightest hover:border-blue focus:border-blue px-2 py-1 my-2 h-8"
onchange="${choose}"
>
${
options.map(
i =>
html`
<option value="${i}" ${i === selected ? 'selected' : ''}
>${translate(i)}</option
>
`
)
}
</select>
`;
function choose(event) {
const target = event.target;
const value = +target.value;
if (x !== value) {
x = value;
changed(value);
}
}
};