Skip to content

Commit 32433f3

Browse files
committed
Fixed button click
1 parent adb9c76 commit 32433f3

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

packages/util/src/emulator.ts

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,29 +184,23 @@ export function updateEmulatorBanner(name: string, isRunningEmulator: boolean) {
184184
return;
185185
}
186186
emulatorStatus[name] = isRunningEmulator;
187+
const bannerId = '__firebase__banner';
187188
if (!areRunningEmulator()) {
188189
tearDown();
189190
return;
190191
}
191192

192193
function tearDown() {
193-
const divId = `__firebase_status`;
194194
if (typeof document !== 'undefined') {
195-
const element = document.getElementById(divId);
195+
const element = document.getElementById(bannerId);
196196
if (element) {
197197
element.remove();
198198
}
199199
}
200200
}
201201

202202
function setupDom() {
203-
const parentDivId = `__firebase__status`;
204-
let { element: parentDiv, created } = getOrCreateEl(parentDivId);
205-
if (created) {
206-
parentDiv.classList.add('firebase-emulator-warning');
207-
document.body.appendChild(parentDiv);
208-
}
209-
const banner = getOrCreateEl('__firebase__banner');
203+
const banner = getOrCreateEl(bannerId);
210204
let firebaseText: HTMLSpanElement =
211205
document.getElementById('__firebase__text') ||
212206
document.createElement('span');
@@ -220,11 +214,19 @@ export function updateEmulatorBanner(name: string, isRunningEmulator: boolean) {
220214
bannerEl.style.left = '5px';
221215
bannerEl.style.padding = '.5em';
222216
bannerEl.style.borderRadius = '5px';
217+
bannerEl.style.alignContent = 'center';
218+
const closeBtn = document.createElement('span');
219+
closeBtn.style.cursor = 'pointer';
220+
closeBtn.style.paddingLeft = '5px';
221+
closeBtn.innerHTML = ' ×';
222+
closeBtn.onclick = () => {
223+
tearDown();
224+
};
223225
bannerEl.appendChild(firebaseText);
226+
bannerEl.appendChild(closeBtn);
224227
document.body.appendChild(banner.element);
225228
}
226229
firebaseText.setAttribute('id', '__firebase__text');
227-
firebaseText.setAttribute('style', 'align-content: center');
228230
firebaseText.innerText = 'Running in this workspace';
229231
}
230232
if (typeof window !== 'undefined' && typeof document !== 'undefined') {

0 commit comments

Comments
 (0)