Skip to content

Commit ef34d78

Browse files
authored
feat(ui): add reset button for code editor (laike9m#31)
1 parent 795aa6a commit ef34d78

File tree

1 file changed

+25
-5
lines changed

1 file changed

+25
-5
lines changed

templates/challenge.html

+25-5
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,17 @@
8080
width: 50%;
8181
}
8282

83-
.codemirror-container #run-button {
83+
.editor-actions {
84+
display: flex;
85+
justify-content: flex-end;
8486
align-self: flex-end;
85-
width: 100px;
87+
gap: 8px;
88+
}
89+
90+
.editor-actions button {
8691
padding: 2px 4px;
8792
border-radius: 4px;
93+
width: 100px;
8894
}
8995

9096
.tests-result-container {
@@ -141,6 +147,10 @@
141147
.challenge-main .tests-result-container {
142148
width: 100%;
143149
}
150+
151+
.editor-actions {
152+
width: 100%;
153+
}
144154
}
145155

146156
.CodeMirror {
@@ -187,9 +197,14 @@
187197
<!-- Code Editor Area -->
188198
<div class="codemirror-container">
189199
<div id="editor"></div>
190-
<button id="run-button">
191-
▶️ Run
192-
</button>
200+
<div class="editor-actions">
201+
<button id="reset-button" class="secondary">
202+
Reset
203+
</button>
204+
<button id="run-button">
205+
▶️ Run
206+
</button>
207+
</div>
193208
</div>
194209
<!-- Test Cases and Result Area -->
195210
<div class="tests-result-container">
@@ -258,6 +273,11 @@
258273
});
259274
};
260275

276+
let resetButton = document.getElementById('reset-button')
277+
resetButton.onclick = function () {
278+
myCodeMirror.setValue(code_under_test);
279+
};
280+
261281
// If window size is > 800, expand the challenge list.
262282
function checkWidth() {
263283
let detailsElement = document.getElementById('challenge-list');

0 commit comments

Comments
 (0)