-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathselect.js
31 lines (28 loc) · 863 Bytes
/
select.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { html } from "./html.js";
import { targetValue } from "./web_modules/@hyperapp/events.js";
import { sortedCountryNames } from "./countriesMap.js";
import { AddCountry } from "./country.js";
const AddSelectedCountry = (state, currentCountry) =>
AddCountry(currentCountry)(state);
const selectedOption = (selected, name) =>
selected === name
? html`
<option selected value="${name}">${name}</option>
`
: html`
<option value="${name}">${name}</option>
`;
export const select = state => html`
<div class="m-2 p-2">
<div class=" form-group input-group">
<select
oninput=${[AddSelectedCountry, targetValue]}
class="countries form-select"
>
${sortedCountryNames.map(name =>
selectedOption(state.currentCountry, name)
)}
</select>
</div>
</div>
`;