added disabled buttons to navBar

This commit is contained in:
2025-01-26 10:24:38 +01:00
parent 37ebd63e3b
commit 12c1bff421
3 changed files with 22 additions and 5 deletions
+3 -1
View File
@@ -18,11 +18,13 @@
"icon": "powerplates_8x8.png", "icon": "powerplates_8x8.png",
"action": "navigate", "action": "navigate",
"actionValue": "/powerplates", "actionValue": "/powerplates",
"disabled": true,
"alt": { "alt": {
"name": "byte", "name": "byte",
"icon": "dice3_8x8.png", "icon": "dice3_8x8.png",
"action": "navigate", "action": "navigate",
"actionValue": "/" "actionValue": "/",
"disabled": false
} }
}, },
{ {
+14 -1
View File
@@ -22,13 +22,26 @@ li {
filter: drop-shadow(0px calc(1px * var(--pxDensity)) rgba(0, 0, 0, 0.5)); filter: drop-shadow(0px calc(1px * var(--pxDensity)) rgba(0, 0, 0, 0.5));
} }
button:hover { button:hover {
filter: brightness(1.35) drop-shadow(0px calc(1px * var(--pxDensity)) rgba(0, 0, 0, 0.5)); filter: brightness(1.35) drop-shadow(0px calc(1px * var(--pxDensity)) rgba(0, 0, 0, 0.5));
cursor: pointer; cursor: pointer;
} }
button:active { button:active {
filter: brightness(0.75); filter: brightness(0.75);
transform: translateY(calc(1px * var(--pxDensity))); transform: translateY(calc(1px * var(--pxDensity)));
} }
.button:disabled, button[disabled] {
filter: brightness(0.75) drop-shadow(0px calc(1px * var(--pxDensity)) rgba(0, 0, 0, 0.5));
cursor: not-allowed;
}
.button:disabled:hover, button[disabled]:hover {
filter: brightness(0.75) drop-shadow(0px calc(1px * var(--pxDensity)) rgba(0, 0, 0, 0.5));
cursor: not-allowed;
}
.button:disabled:active, button[disabled]:active {
filter: brightness(0.75) drop-shadow(0px calc(1px * var(--pxDensity)) rgba(0, 0, 0, 0.5));
cursor: not-allowed;
transform: none;
}
.navBtnImg { .navBtnImg {
width: calc(12px * var(--pxDensity)); width: calc(12px * var(--pxDensity));
height: calc(12px * var(--pxDensity)); height: calc(12px * var(--pxDensity));
+5 -3
View File
@@ -21,7 +21,8 @@ function onLoadNavBar() {
btn["action"] || "", btn["action"] || "",
btn["actionValue"] || "", btn["actionValue"] || "",
btn["iconId"] || "", btn["iconId"] || "",
btn["alt"] || "" btn["alt"] || "",
btn["disabled"] || false
)) ))
} }
@@ -29,12 +30,13 @@ function onLoadNavBar() {
container.appendChild(navBarAligner) container.appendChild(navBarAligner)
} }
function createNavBarBtn(icon = "", action = "", actionValue = "", iconId = "", alt = "", hidden = "") { function createNavBarBtn(icon = "", action = "", actionValue = "", iconId = "", alt = "", disabled = false) {
if (alts.includes(alt["name"])) { if (alts.includes(alt["name"])) {
icon = alt["icon"] || "" icon = alt["icon"] || ""
action = alt["action"] || "" action = alt["action"] || ""
actionValue = alt["actionValue"] || "" actionValue = alt["actionValue"] || ""
iconId = alt["iconId"] || "" iconId = alt["iconId"] || ""
disabled = alt["disabled"] || false
} }
let onClick let onClick
@@ -47,7 +49,7 @@ function createNavBarBtn(icon = "", action = "", actionValue = "", iconId = "",
let btn = document.createElement("li") let btn = document.createElement("li")
btn.innerHTML = ` btn.innerHTML = `
<button onclick="${onClick}" class="navBtn"> <button onclick="${onClick}" class="navBtn" ${disabled == true ? "disabled" : ""}>
<img class="navBtnImg" draggable="false" src="/assets/navBarBtn.png"> <img class="navBtnImg" draggable="false" src="/assets/navBarBtn.png">
<img class="navBtnIcon" draggable="false" src="/assets/icons/${icon}" id="${iconId}"> <img class="navBtnIcon" draggable="false" src="/assets/icons/${icon}" id="${iconId}">
</button> </button>