summaryrefslogtreecommitdiff
path: root/StyleDropdown.js
blob: f2f0f654153117ddea524b91edbe941f88f7a3a1 (plain)
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
function StyleDropdown({ options, index, onChoose, defaultText })
{
   const text = index < 0 ? defaultText : options[index];

   let optionLinks = [];
   for (let i=0; i<options.length; i++)
      optionLinks.push(
         h('a',
           {
              href: '#',
              onClick: () => onChoose(i)
           },
           options[i]
          )
      );

   return h(
      'div.StyleDropdownContainer', {}
      [
         h('button.StyleDropdownButton', {}, text),

         h('div.StyleDropdownContent', {}, optionLinks)
      ]
   );
}