Skip to content

Commit 8810a49

Browse files
committed
Add loading indicator during installation
1 parent 5360092 commit 8810a49

File tree

3 files changed

+36
-19
lines changed

3 files changed

+36
-19
lines changed

css/style.css

+24-8
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,50 @@
7676
margin-bottom: 20px;
7777
}
7878

79+
.hidden {
80+
display: none;
81+
}
82+
7983
/* Status Bar */
8084
.status-bar {
85+
display: flex;
86+
justify-content: center;
87+
gap: var(--main-flexbox-gap);
8188
font-family: 'Roboto Mono', monospace;
8289
background-color: rgba(0, 0, 0, 0.75);
8390
color: white;
84-
padding: 0 10px; /* Set initial padding to 0 for smooth slide */
91+
padding: 0px 20px; /* Set initial padding to 0 for smooth slide */
8592
margin-top: 10px;
86-
text-align: center;
87-
height: 0;
93+
max-height: 0;
8894
opacity: 0;
8995
transition: max-height 0.5s ease, padding 0.5s ease, opacity 0.3s ease;
9096
}
9197

9298
.status-bar.visible {
93-
height: auto;
94-
padding: 10px;
99+
display: flex;
100+
max-height: 480px;
101+
padding: 10px 20px;
95102
opacity: 1;
96103
}
97104

98105
/* Loading Spinner */
99106
.loading-spinner {
100-
border: 6px solid #f3f3f3;
101-
border-top: 6px solid var(--main-control-color);
107+
border: 6px solid #eee;
108+
border-top-color: var(--secondary-text-color);
102109
border-radius: 50%;
103110
width: 40px;
104111
height: 40px;
105112
animation: spin 1s linear infinite;
106-
margin: 40px auto; /* Centers the spinner */
113+
}
114+
115+
.loading-spinner.primary {
116+
border-top-color: var(--main-control-color);
117+
}
118+
119+
.loading-spinner.small {
120+
width:24px;
121+
height: 24px;
122+
border-width: 4px;
107123
}
108124

109125
@keyframes spin {

index.html

+4-3
Original file line numberDiff line numberDiff line change
@@ -53,20 +53,21 @@ <h1>📦 MicroPython Package Installer</h1>
5353
</div>
5454
<div>
5555
<input type="checkbox" id="compile-files" checked />
56-
<label for="compile-files">Compile files before uploading</label>
56+
<label for="compile-files">Convert files to .mpy to optimize speed and size</label>
5757
</div>
5858
<div>
5959
<input type="checkbox" id="overwrite-existing" checked />
60-
<label for="overwrite-existing">Overwrite existing packages</label>
60+
<label for="overwrite-existing">Allow overwriting existing packages</label>
6161
</div>
6262
</div>
6363

6464
</div>
6565
</div>
6666

6767
<!-- Status Bar -->
68-
<div id="status-bar" class="status-bar" style="display: none;">
68+
<div id="status-bar" class="status-bar hidden">
6969
<span id="status-message"></span>
70+
<div class="loading-spinner small hidden"></div>
7071
</div>
7172

7273
<!-- Divider -->

renderer.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,22 @@ let customURLplaceholders = ['github:janedoe/button-mpy',
88
'https://example.com/recorder.py'
99
];
1010

11+
const statusBar = document.getElementById('status-bar');
12+
const statusMessage = document.getElementById('status-message');
1113
const deviceSelectionList = document.querySelector(".item-selection-list");
1214
const reloadDeviceListLink = document.getElementById("reload-link");
1315
const searchField = document.getElementById('search-field');
1416
const compileFilesCheckbox = document.getElementById('compile-files');
1517
const overwriteExistingCheckbox = document.getElementById('overwrite-existing');
1618
const githubUrlInput = document.getElementById('github-url');
19+
const statusBarLoadingSpinner = document.querySelector('#status-bar .loading-spinner');
1720

1821
async function fetchPackages(){
1922
const packageList = document.getElementById('package-list');
2023

2124
// Show loading spinner
22-
packageList.innerHTML = '<div class="loading-spinner"></div>';
25+
packageList.innerHTML = '<div class="loading-spinner primary" style="margin: 50px auto;"></div>';
2326
const result = await window.api.getPackages();
24-
2527
if(result.success){
2628
cachedPackages = result.data;
2729
renderPackageList(cachedPackages, ''); // Render the fetched packages
@@ -255,7 +257,7 @@ async function installPackage(package) {
255257
const packageDesignator = package.name || package.url;
256258
toggleUserInteraction(false);
257259
showOverlay();
258-
showStatus(`⌛️ Installing ${packageDesignator} on board at ${serialPort}...`);
260+
showStatus(`⌛️ Installing ${packageDesignator} on board at ${serialPort}...`, true);
259261

260262
const compileFiles = compileFilesCheckbox.checked;
261263
const overwriteExisting = overwriteExistingCheckbox.checked;
@@ -342,12 +344,10 @@ function animatePlaceholder(element, values, duration = 3500) {
342344
return interval;
343345
}
344346

345-
function showStatus(message, duration = null) {
346-
const statusBar = document.getElementById('status-bar');
347-
const statusMessage = document.getElementById('status-message');
348-
347+
function showStatus(message, displayLoader = false, duration = null) {
349348
statusMessage.textContent = message;
350-
statusBar.style.display = 'block';
349+
statusBar.classList.remove('hidden');
350+
statusBarLoadingSpinner.classList.toggle('hidden', !displayLoader);
351351

352352
// Add the visible class to trigger the slide down effect
353353
setTimeout(() => {

0 commit comments

Comments
 (0)