summaryrefslogtreecommitdiff
path: root/StyleDropdown.js
blob: cbc6e4fcc42167b420e4b6415cb7e2a2fe40291c (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)
      ]
   );
}