2018-10-25 04:07:10 +02:00
|
|
|
const html = require('choo/html');
|
|
|
|
|
|
|
|
module.exports = function(selected, options, translate, changed) {
|
|
|
|
let x = selected;
|
|
|
|
|
|
|
|
return html`
|
2018-10-30 03:06:15 +01:00
|
|
|
<select class="appearance-none cursor-pointer border rounded-sm bg-blue-lightest hover:border-blue focus:border-blue p-1" onchange=${choose}>
|
2018-10-25 04:07:10 +02:00
|
|
|
${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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|