11import { LitElement , html } from 'lit'
2+ import { unsafeHTML } from 'lit/directives/unsafe-html.js'
23import { defineCustomElement } from '@components/scripts/utils'
34import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
4- import { queryConnectionStatusIndicator } from './selectors'
5+ import { queryConnectionStatusIndicator , queryNetworkStatusIconMarkup } from './selectors'
56
67type ToastType = 'success' | 'error'
78
89const TOAST_HIDE_TIMEOUT = 3000
10+ const ICON_BANK_ID = 'network-status-toast-icon-bank'
911
1012export class NetworkStatusToastElement extends LitElement {
1113 static registeredName = 'network-status-toast'
@@ -118,6 +120,22 @@ export class NetworkStatusToastElement extends LitElement {
118120 }
119121
120122 protected override render ( ) {
123+ const canUseDocument = typeof document !== 'undefined'
124+ const successIconMarkup = canUseDocument
125+ ? queryNetworkStatusIconMarkup ( {
126+ iconBankId : ICON_BANK_ID ,
127+ iconName : 'success' ,
128+ root : document ,
129+ } )
130+ : null
131+ const errorIconMarkup = canUseDocument
132+ ? queryNetworkStatusIconMarkup ( {
133+ iconBankId : ICON_BANK_ID ,
134+ iconName : 'error' ,
135+ root : document ,
136+ } )
137+ : null
138+
121139 return html `
122140 < div
123141 data-network-status-toast
@@ -128,36 +146,8 @@ export class NetworkStatusToastElement extends LitElement {
128146 aria-atomic ="true "
129147 >
130148 < div class ="flex items-center space-x-2 ">
131- < svg
132- class ="w-5 h-5 success-icon "
133- fill ="none "
134- stroke ="currentColor "
135- viewBox ="0 0 24 24 "
136- aria-hidden ="true "
137- focusable ="false "
138- >
139- < path
140- stroke-linecap ="round "
141- stroke-linejoin ="round "
142- stroke-width ="2 "
143- d ="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z "
144- > </ path >
145- </ svg >
146- < svg
147- class ="w-5 h-5 error-icon hidden "
148- fill ="none "
149- stroke ="currentColor "
150- viewBox ="0 0 24 24 "
151- aria-hidden ="true "
152- focusable ="false "
153- >
154- < path
155- stroke-linecap ="round "
156- stroke-linejoin ="round "
157- stroke-width ="2 "
158- d ="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z "
159- > </ path >
160- </ svg >
149+ < span class ="success-icon "> ${ successIconMarkup ? unsafeHTML ( successIconMarkup ) : null } </ span >
150+ < span class ="error-icon hidden "> ${ errorIconMarkup ? unsafeHTML ( errorIconMarkup ) : null } </ span >
161151 < span class ="toast-message "> ${ this . message } </ span >
162152 </ div >
163153 </ div >
0 commit comments