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",
"action": "navigate",
"actionValue": "/powerplates",
"disabled": true,
"alt": {
"name": "byte",
"icon": "dice3_8x8.png",
"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));
}
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;
}
button:active {
filter: brightness(0.75);
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 {
width: calc(12px * var(--pxDensity));
height: calc(12px * var(--pxDensity));
+5 -3
View File
@@ -21,7 +21,8 @@ function onLoadNavBar() {
btn["action"] || "",
btn["actionValue"] || "",
btn["iconId"] || "",
btn["alt"] || ""
btn["alt"] || "",
btn["disabled"] || false
))
}
@@ -29,12 +30,13 @@ function onLoadNavBar() {
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"])) {
icon = alt["icon"] || ""
action = alt["action"] || ""
actionValue = alt["actionValue"] || ""
iconId = alt["iconId"] || ""
disabled = alt["disabled"] || false
}
let onClick
@@ -47,7 +49,7 @@ function createNavBarBtn(icon = "", action = "", actionValue = "", iconId = "",
let btn = document.createElement("li")
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="navBtnIcon" draggable="false" src="/assets/icons/${icon}" id="${iconId}">
</button>