@@ -193,8 +193,9 @@ export function updateEmulatorBanner(
193193 if (
194194 typeof window === 'undefined' ||
195195 typeof document === 'undefined' ||
196- ! isCloudWorkstation ( window . location . host ) ||
196+ // !isCloudWorkstation(window.location.host) ||
197197 emulatorStatus [ name ] === isRunningEmulator ||
198+ emulatorStatus [ name ] || // If already set to use emulator, can't go back to prod.
198199 previouslyDismissed
199200 ) {
200201 return ;
@@ -216,6 +217,38 @@ export function updateEmulatorBanner(
216217 }
217218 }
218219
220+ function setupBannerStyles ( bannerEl : HTMLElement ) {
221+ bannerEl . style . display = 'flex' ;
222+ bannerEl . style . background = '#7faaf0' ;
223+ bannerEl . style . position = 'absolute' ;
224+ bannerEl . style . bottom = '5px' ;
225+ bannerEl . style . left = '5px' ;
226+ bannerEl . style . padding = '.5em' ;
227+ bannerEl . style . borderRadius = '5px' ;
228+ bannerEl . style . alignContent = 'center' ;
229+ }
230+
231+ function setupIconStyles ( prependIcon : SVGElement , iconId : string ) {
232+ prependIcon . setAttribute ( 'width' , '24' ) ;
233+ prependIcon . setAttribute ( 'id' , iconId ) ;
234+ prependIcon . setAttribute ( 'height' , '24' ) ;
235+ prependIcon . setAttribute ( 'viewBox' , '0 0 24 24' ) ;
236+ prependIcon . setAttribute ( 'fill' , 'none' ) ;
237+ prependIcon . style . marginLeft = '-6px' ;
238+ }
239+
240+ function setupCloseBtn ( ) {
241+ const closeBtn = document . createElement ( 'span' ) ;
242+ closeBtn . style . cursor = 'pointer' ;
243+ closeBtn . style . paddingLeft = '5px' ;
244+ closeBtn . innerHTML = ' ×' ;
245+ closeBtn . onclick = ( ) => {
246+ previouslyDismissed = true ;
247+ tearDown ( ) ;
248+ } ;
249+ return closeBtn ;
250+ }
251+
219252 function setupDom ( ) : void {
220253 const banner = getOrCreateEl ( bannerId ) ;
221254 const firebaseTextId = prefixedId ( 'text' ) ;
@@ -226,40 +259,21 @@ export function updateEmulatorBanner(
226259 ( document . getElementById ( learnMoreId ) as HTMLAnchorElement ) ||
227260 document . createElement ( 'a' ) ;
228261 const prependIconId = prefixedId ( 'preprendIcon' ) ;
229- const prependIcon =
230- document . getElementById ( prependIconId ) ||
262+ const prependIcon : SVGElement =
263+ ( document . getElementById (
264+ prependIconId
265+ ) as HTMLOrSVGElement as SVGElement ) ||
231266 document . createElementNS ( 'http://www.w3.org/2000/svg' , 'svg' ) ;
232267 if ( banner . created ) {
233268 // update styles
234269 const bannerEl = banner . element ;
235- bannerEl . style . display = 'flex' ;
236- bannerEl . style . background = '#7faaf0' ;
237- bannerEl . style . position = 'absolute' ;
238- bannerEl . style . bottom = '5px' ;
239- bannerEl . style . left = '5px' ;
240- bannerEl . style . padding = '.5em' ;
241- bannerEl . style . borderRadius = '5px' ;
242- bannerEl . style . alignContent = 'center' ;
243- const closeBtn = document . createElement ( 'span' ) ;
244- closeBtn . style . cursor = 'pointer' ;
245- closeBtn . style . paddingLeft = '5px' ;
246- closeBtn . innerHTML = ' ×' ;
247- closeBtn . onclick = ( ) => {
248- previouslyDismissed = true ;
249- tearDown ( ) ;
250- } ;
270+ setupBannerStyles ( bannerEl ) ;
271+ const closeBtn = setupCloseBtn ( ) ;
251272 learnMoreLink . setAttribute ( 'id' , learnMoreId ) ;
252273 learnMoreLink . href =
253274 'http://firebase.google.com/docs/studio/deploy-app#emulator ' ;
254- bannerEl . appendChild ( prependIcon ) ;
255- bannerEl . appendChild ( firebaseText ) ;
256- bannerEl . appendChild ( learnMoreLink ) ;
257- bannerEl . appendChild ( closeBtn ) ;
258- prependIcon . setAttribute ( 'width' , '24' ) ;
259- prependIcon . setAttribute ( 'id' , prependIconId ) ;
260- prependIcon . setAttribute ( 'height' , '24' ) ;
261- prependIcon . setAttribute ( 'viewBox' , '0 0 24 24' ) ;
262- prependIcon . setAttribute ( 'fill' , 'none' ) ;
275+ setupIconStyles ( prependIcon , prependIconId ) ;
276+ bannerEl . append ( prependIcon , firebaseText , learnMoreLink , closeBtn ) ;
263277 document . body . appendChild ( bannerEl ) ;
264278 }
265279
@@ -283,8 +297,6 @@ export function updateEmulatorBanner(
283297</clipPath>
284298</defs>` ;
285299 firebaseText . innerText = 'Using emulated backend' ;
286- learnMoreLink . href =
287- 'https://firebase.google.com/docs/studio/solution-build-with-ai' ;
288300 }
289301 firebaseText . setAttribute ( 'id' , firebaseTextId ) ;
290302 }
0 commit comments