Skip to content

Commit 19f0ecd

Browse files
committed
feat: add button to close overlay
1 parent d01ecfb commit 19f0ecd

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

client-src/overlay.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,23 @@ function clear() {
116116

117117
// Compilation with errors (e.g. syntax error or missing modules).
118118
function showMessage(messages) {
119-
document.clearOverlay = clear;
120119
ensureOverlayDivExists((div) => {
121120
// Make it look similar to our terminal.
122121
const errorMessage = messages[0].message || messages[0];
123122
const text = ansiHTML(encode(errorMessage));
124-
125-
div.innerHTML = `<span style="color: #${colors.red}"><button onclick="document.clearOverlay()">clear</button>Failed to compile.</span><br><br>${text}`;
123+
const closeButton = document.createElement('button');
124+
closeButton.innerText = 'X';
125+
closeButton.style.background = 'transparent';
126+
closeButton.style.border = 'none';
127+
closeButton.style.fontSize = '20px';
128+
closeButton.style.fontWeight = 'bold';
129+
closeButton.style.color = 'white';
130+
closeButton.style.cursor = 'pointer';
131+
closeButton.addEventListener('click', () => {
132+
clear();
133+
});
134+
div.innerHTML = `<span style="color: #${colors.red}">Failed to compile.</span><br><br>${text}`;
135+
div.insertBefore(closeButton, div.firstChild);
126136
});
127137
}
128138

0 commit comments

Comments
 (0)