client: add navigation item for dashboard

This commit is contained in:
Starbeamrainbowlabs 2022-03-11 01:29:47 +00:00
parent 43e8c2583d
commit b885ea5e3f
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
3 changed files with 10 additions and 5 deletions

View file

@ -12,7 +12,10 @@
<nav>
<ul class="nav-items">
<li class="static dynamic-afterme"><a href="#">
<span class="fa fa-compass fa-fw" aria-hidden="true"></span>
<span>Dashboard</span>
</a></li>
<!-- Any items specified here *must* have the "static" class, otherwise they'll be mistaken for a rogue dynamic item and stripped -->
<li class="static"><a href="#settings">
<span class="fa fa-cog fa-fw" aria-hidden="true"></span>

View file

@ -23,6 +23,7 @@ class GlobalUI {
// 2: Update navigation bar
const el_navitems = document.querySelector(".nav-items"); // <ul>
const el_afterme = el_navitems.querySelector(".dynamic-afterme");
// Strip all non-static navigation items
for(let item of el_navitems.children) {
@ -48,7 +49,8 @@ class GlobalUI {
}));
}
el_navitems.prepend(result);
el_afterme.after(result);
}
}

View file

@ -1,10 +1,10 @@
"use strict";
export default function(def, fixed_width=true) {
export default function(def, fixed_width=true, aria_hidden=true) {
if(typeof def === "string")
return `span[class="fa fa-${def}${fixed_width?` fa-fw`:``}"]`;
return `span[class="fa fa-${def}${fixed_width?` fa-fw`:``}"${aria_hidden?` aria-hidden="true"`:""}]`;
if(def instanceof Array)
return `(span[class="fa-stack${fixed_width?` fa-fw`:``}"]>${def.map((el, i) => `span[class="fa fa-${el} fa-stack-${def.length-i}x${fixed_width?` fa-fw`:``}"]`).join(`+`)})`;
return `(span[class="fa-stack${fixed_width?` fa-fw`:``}"${aria_hidden?` aria-hidden="true"`:""}]>${def.map((el, i) => `span[class="fa fa-${el} fa-stack-${def.length-i}x${fixed_width?` fa-fw`:``}"]`).join(`+`)})`;
throw new Error(`Error: Expected def of type string or Array, but got variable of type ${typeof def}`);
}