Skip to content

Commit 1062363

Browse files
committed
feat: spinner for the showWorking() overlay in puter.js
1 parent 1811545 commit 1062363

File tree

1 file changed

+54
-5
lines changed
  • src/puter-js/src/modules

1 file changed

+54
-5
lines changed

src/puter-js/src/modules/UI.js

+54-5
Original file line numberDiff line numberDiff line change
@@ -1284,10 +1284,48 @@ class UI extends EventListener {
12841284

12851285
showWorking() {
12861286
if (this.#overlayActive) return;
1287-
1287+
1288+
// Create and add stylesheet for spinner if it doesn't exist
1289+
if (!document.getElementById('puter-spinner-styles')) {
1290+
const styleSheet = document.createElement('style');
1291+
styleSheet.id = 'puter-spinner-styles';
1292+
styleSheet.textContent = `
1293+
.puter-loading-spinner {
1294+
width: 50px;
1295+
height: 50px;
1296+
border: 5px solid #f3f3f3;
1297+
border-top: 5px solid #3498db;
1298+
border-radius: 50%;
1299+
animation: spin 1s linear infinite;
1300+
margin-bottom: 10px;
1301+
}
1302+
1303+
.puter-loading-text {
1304+
color: white;
1305+
font-family: Arial, sans-serif;
1306+
font-size: 16px;
1307+
margin-top: 10px;
1308+
text-align: center;
1309+
}
1310+
1311+
@keyframes spin {
1312+
0% { transform: rotate(0deg); }
1313+
100% { transform: rotate(360deg); }
1314+
}
1315+
1316+
.puter-loading-container {
1317+
display: flex;
1318+
flex-direction: column;
1319+
align-items: center;
1320+
justify-content: center;
1321+
}
1322+
`;
1323+
document.head.appendChild(styleSheet);
1324+
}
1325+
12881326
const overlay = document.createElement('div');
12891327
overlay.classList.add('puter-loading-overlay');
1290-
1328+
12911329
const styles = {
12921330
position: 'fixed',
12931331
top: '0',
@@ -1301,11 +1339,22 @@ class UI extends EventListener {
13011339
alignItems: 'center',
13021340
pointerEvents: 'all'
13031341
};
1304-
1342+
13051343
Object.assign(overlay.style, styles);
1306-
overlay.innerHTML = '<div class="puter-loading-spinner">Working...</div>';
1344+
1345+
// Create container for spinner and text
1346+
const container = document.createElement('div');
1347+
container.classList.add('puter-loading-container');
1348+
1349+
// Add spinner and text
1350+
container.innerHTML = `
1351+
<div class="puter-loading-spinner"></div>
1352+
<div class="puter-loading-text">Working...</div>
1353+
`;
1354+
1355+
overlay.appendChild(container);
13071356
document.body.appendChild(overlay);
1308-
1357+
13091358
this.#overlayActive = true;
13101359
this.#overlayTimer = setTimeout(() => {
13111360
this.#overlayTimer = null;

0 commit comments

Comments
 (0)