summaryrefslogtreecommitdiff
path: root/StyleDropdown.js
diff options
context:
space:
mode:
Diffstat (limited to 'StyleDropdown.js')
-rw-r--r--StyleDropdown.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/StyleDropdown.js b/StyleDropdown.js
new file mode 100644
index 0000000..f2f0f65
--- /dev/null
+++ b/StyleDropdown.js
@@ -0,0 +1,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)
+ ]
+ );
+}