commit 5342bf77764266182a8269b77b75a1e0085a985f
parent 9b5d4e4d006fb6f80d132f7c06f40db11fcb57ca
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Thu, 8 Aug 2024 18:45:32 -0700
Use options argument in ui.button()
Diffstat:
1 file changed, 15 insertions(+), 9 deletions(-)
diff --git a/files/lib/ui.js b/files/lib/ui.js
@@ -3,23 +3,29 @@ export function input(name, memo, attributes) {
throw new Error("No name provided")
}
- let input = document.createElement("input")
- input.name = name
- input.placeholder = name
+ let e = document.createElement("input")
+ e.name = name
+ e.placeholder = name
+ e.setAttribute("title", memo)
for (let i in attributes) {
- input.setAttribute(i, attributes[i])
+ console.log(i,attributes[i])
+ e.setAttribute(i, attributes[i])
}
- return input
+ return e
}
export function button(name, memo, icon, func, options) {
- let button = input(name, memo, {
+ let button_options = {
alt: name,
- title: memo,
type: "image",
class: "icon",
- src: "/icons/" + icon + "-outline.svg"
- })
+ src: "/icons/" + icon + "-outline.svg",
+ }
+ let button = input(name, memo, options)
+ for (let i in button_options) {
+ button.setAttribute(i, button_options[i])
+ }
+
if (func) {
button.addEventListener("click", func, false)
}