]> git.scottworley.com Git - vopamoi/commitdiff
Keep tags sorted
authorScott Worley <scottworley@scottworley.com>
Thu, 27 Jan 2022 21:34:30 +0000 (13:34 -0800)
committerScott Worley <scottworley@scottworley.com>
Thu, 27 Jan 2022 21:34:30 +0000 (13:34 -0800)
vopamoi.ts

index 135fe0afe417539547816bdab6f807ed58eef10e..31a4cdcd858a56b7f72fe75dd1ccecbe756cb881 100644 (file)
@@ -60,6 +60,12 @@ const Model = {
     tag.classList.add("tag");
     tag.setAttribute("tabindex", "0");
     hashHue(tagName).then((hue) => (tag.style.backgroundColor = `hsl(${hue},90%,45%)`));
+    for (const child of task.getElementsByClassName("tag")) {
+      if (tagName > child.textContent!) {
+        task.insertBefore(tag, child);
+        return tag;
+      }
+    }
     task.appendChild(tag);
     return tag;
   },