Skip to content

Commit 99fa999

Browse files
committed
Add Bootstrap for improved styling and enhance mod installation UI with loading indicators
1 parent 323a0c7 commit 99fa999

File tree

4 files changed

+62
-3
lines changed

4 files changed

+62
-3
lines changed

package-lock.json

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"@iarna/toml": "^2.2.5",
1515
"adm-zip": "^0.5.16",
1616
"axios": "^1.9.0",
17+
"bootstrap": "^5.3.6",
1718
"cli-progress": "^3.12.0",
1819
"node-fetch": "^3.3.2",
1920
"tar": "^7.4.3",

ui/chrome/js/moddashboard.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ document.getElementById("search").addEventListener("click", async function() {
1818
<p>Downloads: ${project.downloads}</p>
1919
<p>Follows: ${project.follows}</p>
2020
<a href="https://modrinth.com/${project.project_type}/${project.slug}" target="_blank">View on Modrinth</a>
21-
<button class="install" onclick="installMod('${project.slug}')">Install</button>
21+
<button class="install btn btn-primary" onclick="installMod('${project.slug}')" ${mods.find(mod => new String(mod.metadata[0].id).includes(project.slug)) ? "disabled=1" : ""} id="${project.slug}">${mods.find(mod => mod.metadata[0].id == project.slug) ? "Installed" : "Install"}</button>
2222
`
2323
resultDiv.appendChild(projectDiv)
2424
}
@@ -27,14 +27,15 @@ document.getElementById("search").addEventListener("click", async function() {
2727
const modsDiv = document.getElementById("installedMods")
2828
for (var i = 0; i < mods.length; i++) {
2929
let mod = mods[i]
30+
console.log(mod)
3031
let modDiv = document.createElement("div")
3132
modDiv.className = "mod"
3233
modDiv.innerHTML = `
3334
<h3>${mod.metadata[0].name}</h3>
3435
<p>${mod.metadata[0].description}</p>
3536
<p>Version: ${mod.metadata[0].version}</p>
3637
<p>Path: ${mod.path}</p>
37-
<button class="uninstall" onclick="uninstallMod('${mod.path}')">Uninstall</button>
38+
<button class="uninstall btn btn-primary" onclick="uninstallMod('${mod.path}')"} id="${mod.path}">Uninstall</button>
3839
`
3940
modsDiv.appendChild(modDiv)
4041
}

ui/chrome/moddashboard/index.html

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>Mod Dashboard</title>
88
<link rel="stylesheet" href="../css/main.css">
9+
<link rel="stylesheet" href="../../../node_modules/bootstrap/dist/css/bootstrap.min.css">
910
<script>
1011
async function installMod(modId) {
1112
let depsdownloaded = []
@@ -32,12 +33,37 @@
3233
}
3334
}
3435
}
36+
document.getElementById(modId).innerHTML = ""
37+
const spinner = document.createElement("div")
38+
spinner.className = "spinner-border text-dark"
39+
spinner.role = "status"
40+
const span = document.createElement("span")
41+
span.className = "visually-hidden"
42+
span.innerText = "Loading..."
43+
spinner.appendChild(span)
44+
document.getElementById(modId).appendChild(spinner)
3545
const mainMod = await downloadMod(modId)
36-
loopThroughDependencies(mainMod)
46+
await loopThroughDependencies(mainMod)
47+
setTimeout(() => {
48+
location.reload()
49+
}, 3000)
3750
}
3851

3952
async function uninstallMod(path) {
53+
// add spinner
54+
const spinner = document.createElement("div")
55+
spinner.className = "spinner-border text-dark"
56+
spinner.role = "status"
57+
const span = document.createElement("span")
58+
span.className = "visually-hidden"
59+
span.innerText = "Loading..."
60+
spinner.appendChild(span)
61+
document.getElementById(path).innerHTML = ""
62+
document.getElementById(path).appendChild(spinner)
4063
window.mcAPI.deleteFromModsFolder(path)
64+
setTimeout(() => {
65+
location.reload()
66+
}, 3000)
4167
}
4268
</script>
4369
</head>

0 commit comments

Comments
 (0)