From: Scott Worley Date: Thu, 27 Jan 2022 21:34:30 +0000 (-0800) Subject: Keep tags sorted X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/360beccbbfadcc25606af08d13d64fd878469ecc?ds=inline;hp=c70b3eedcfa3521a21239d7f0a6d2168e063dea2 Keep tags sorted --- diff --git a/vopamoi.ts b/vopamoi.ts index 135fe0a..31a4cdc 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -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; },