summaryrefslogtreecommitdiff
path: root/StyleDropdown.js
diff options
context:
space:
mode:
authorsanine-a <sanine.not@pm.me>2021-04-13 13:03:55 -0500
committersanine-a <sanine.not@pm.me>2021-04-13 13:03:55 -0500
commit64c6fb119164afcfc654ccee3c2ad96426f17a0c (patch)
tree97cd91d4b741e71b9dd143f480322546cc79a6df /StyleDropdown.js
parent268b82d0efbc49ff48e1f2c4b7b6c620a099f6e3 (diff)
add StyleDropdown.js
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)
+ ]
+ );
+}