11import { css , html , isServer , type PropertyValues , type SVGTemplateResult } from 'lit' ;
22import { customElement , property , state } from 'lit/decorators.js' ;
33import { ThemedElement } from '../themed-element' ;
4+ import cloudOff from './icons/cloud-off' ;
5+ import cloudUpload from './icons/cloud-upload' ;
46
57// Lit replacement for the retired `<iron-icon icon="hoverboard:name">` Polymer iconset.
68// Each icon is its own module under ./icons so only the icons a page uses are loaded.
@@ -48,8 +50,6 @@ const ICONS: Record<string, () => Promise<{ default: SVGTemplateResult }>> = {
4850 people : ( ) => import ( './icons/people' ) ,
4951 registration : ( ) => import ( './icons/registration' ) ,
5052 'bell-off' : ( ) => import ( './icons/bell-off' ) ,
51- 'cloud-off' : ( ) => import ( './icons/cloud-off' ) ,
52- 'cloud-upload' : ( ) => import ( './icons/cloud-upload' ) ,
5353 'bell-outline' : ( ) => import ( './icons/bell-outline' ) ,
5454 monitor : ( ) => import ( './icons/monitor' ) ,
5555 sun : ( ) => import ( './icons/sun' ) ,
@@ -59,7 +59,11 @@ const ICONS: Record<string, () => Promise<{ default: SVGTemplateResult }>> = {
5959 'density-large' : ( ) => import ( './icons/density-large' ) ,
6060} ;
6161
62- const loaded = new Map < string , SVGTemplateResult > ( ) ;
62+ // The icons that show offline are bundled, since their chunks might not be cached.
63+ const loaded = new Map < string , SVGTemplateResult > ( [
64+ [ 'cloud-off' , cloudOff ] ,
65+ [ 'cloud-upload' , cloudUpload ] ,
66+ ] ) ;
6367
6468@customElement ( 'hoverboard-icon' )
6569export class HoverboardIcon extends ThemedElement {
@@ -104,12 +108,12 @@ export class HoverboardIcon extends ThemedElement {
104108 }
105109
106110 private loadIcon ( name : string ) {
111+ const cached = loaded . get ( name ) ;
107112 const load = ICONS [ name ] ;
108- if ( ! load ) {
113+ if ( ! cached && ! load ) {
109114 return ;
110115 }
111- const cached = loaded . get ( name ) ;
112- const loading = ( cached ? Promise . resolve ( { default : cached } ) : load ( ) )
116+ const loading = ( cached ? Promise . resolve ( { default : cached } ) : load ! ( ) )
113117 . then ( ( module ) => {
114118 loaded . set ( name , module . default ) ;
115119 if ( this . name === name ) {
0 commit comments