@@ -7,11 +7,15 @@ import {
7
7
linksToMany ,
8
8
FieldDef ,
9
9
containsMany ,
10
+ type CardorFieldTypeIcon ,
10
11
} from ' ./card-api' ;
11
12
import StringField from ' ./string' ;
12
13
import BooleanField from ' ./boolean' ;
13
14
import CodeRef from ' ./code-ref' ;
14
15
import MarkdownField from ' ./markdown' ;
16
+ import { restartableTask } from ' ember-concurrency' ;
17
+ import { LoadingIndicator } from ' @cardstack/boxel-ui/components' ;
18
+ import { loadCard } from ' @cardstack/runtime-common' ;
15
19
16
20
import GlimmerComponent from ' @glimmer/component' ;
17
21
import BoxModel from ' @cardstack/boxel-icons/box-model' ;
@@ -98,14 +102,39 @@ export class CatalogEntry extends CardDef {
98
102
};
99
103
100
104
static isolated = class Isolated extends Component <typeof this > {
101
- get icon() {
105
+ icon: CardorFieldTypeIcon | undefined ;
106
+
107
+ get defaultIcon() {
102
108
return this .args .model .constructor ?.icon ;
103
109
}
110
+ constructor (owner : any , args : any ) {
111
+ super (owner , args );
112
+ this .loadCardIcon .perform ();
113
+ }
114
+
115
+ private loadCardIcon = restartableTask (async () => {
116
+ if (this .args .model .ref && this .args .model .id ) {
117
+ let card = await loadCard (this .args .model .ref , {
118
+ loader: (import .meta as any ).loader ,
119
+ relativeTo: new URL (this .args .model .id ),
120
+ });
121
+ this .icon = card .icon ;
122
+ }
123
+ });
124
+
104
125
<template >
105
126
<div class =' container' >
106
127
<div class =' header' >
107
128
<div class =' header-icon-container' >
108
- <this .icon class =' box header-icon-svg' />
129
+ {{#if this . loadCardIcon.isRunning }}
130
+ <LoadingIndicator class =' box header-icon-svg' />
131
+ {{else }}
132
+ {{#if this . icon }}
133
+ <this .icon class =' box header-icon-svg' />
134
+ {{else }}
135
+ <this .defaultIcon class =' box header-icon-svg' />
136
+ {{/if }}
137
+ {{/if }}
109
138
</div >
110
139
<div class =' header-info-container' >
111
140
<div class =' box' >
0 commit comments