Skip to content

Commit 4555be0

Browse files
authored
Merge pull request #560 from Mansi2007275/Add-loading-spinner
Added loading spinner in run code button
2 parents d904e21 + 2072c1f commit 4555be0

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

pages/editor.html

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,68 @@ <h2 class="h4 mb-1 text-code-heading">Code Editor</h2>
173173
}
174174
</code></pre>
175175

176-
<button class="btn btn-custom-blue mt-2 px-4 py-2 rounded shadow">
176+
<button id="runBtn" class="btn btn-custom-blue mt-2 px-4 py-2 rounded shadow">
177+
<span class="btn-text">Run Code</span>
178+
<span class="spinner hidden"></span>
179+
</button>
180+
181+
<div id="output" class="mt-4"></div>
182+
<style>
183+
.btn {
184+
position: relative;
185+
display: flex;
186+
align-items: center;
187+
justify-content: center;
188+
gap: 8px;
189+
}
190+
191+
/* Spinner Style <button class="btn btn-custom-blue mt-2 px-4 py-2 rounded shadow">
177192
Run Code
178-
</button>
193+
</button> */
194+
.spinner {
195+
width: 18px;
196+
height: 18px;
197+
border: 3px solid #ffffff;
198+
border-top: 3px solid transparent;
199+
border-radius: 50%;
200+
animation: spin 0.7s linear infinite;
201+
}
202+
203+
/* Hide by default */
204+
.hidden {
205+
display: none;
206+
}
207+
208+
@keyframes spin {
209+
to {
210+
transform: rotate(360deg);
211+
}
212+
}
213+
214+
</style>
215+
<script>
216+
const runBtn = document.getElementById("runBtn");
217+
const spinner = runBtn.querySelector(".spinner");
218+
const btnText = runBtn.querySelector(".btn-text");
219+
const output = document.getElementById("output");
220+
221+
runBtn.addEventListener("click", async () => {
222+
// Show spinner
223+
spinner.classList.remove("hidden");
224+
btnText.textContent = "Running...";
225+
226+
// Simulate code execution delay (replace with your real code execution logic)
227+
await new Promise((res) => setTimeout(res, 2000));
228+
229+
// Hide spinner and reset text
230+
spinner.classList.add("hidden");
231+
btnText.textContent = "Run Code";
232+
233+
// Show result
234+
output.innerHTML = "<p>✅ Code executed successfully!</p>";
235+
});
236+
237+
</script>
179238
</div>
180239

181240
<!-- Grabber between center and right panels -->

0 commit comments

Comments
 (0)