@@ -2,9 +2,9 @@ import * as React from "react";
2
2
import styled , { injectGlobal } from "styled-components" ;
3
3
4
4
export interface CardTileProps extends React . ClassAttributes < CardTile > {
5
- id : string ;
6
- name : string ;
7
- cost : number ;
5
+ id : string | null ;
6
+ name : string | null ;
7
+ cost : number | null ;
8
8
icon ?: string ;
9
9
rarity ?: string ;
10
10
disabled ?: boolean ;
@@ -106,15 +106,17 @@ const CardTileNameBase = CardTileTextElement.extend`
106
106
` ;
107
107
108
108
const CardTileName = CardTileNameBase . extend `
109
- background-image : linear-gradient(
109
+ background: linear-gradient(
110
110
65deg,
111
111
#313109,
112
112
#313131 calc(100% - 96px),
113
113
rgba(49, 49, 49, 0) calc(100% - 26px),
114
114
rgba(49, 49, 49, 0)
115
115
),
116
- ${ ( props : React . HTMLProps < HTMLDivElement > & { cardId : string } ) =>
117
- `url("https://art.hearthstonejson.com/v1/tiles/${ props . cardId } .png")` } ;
116
+ ${ ( props : React . HTMLProps < HTMLDivElement > & { cardId : string | null } ) =>
117
+ props . cardId !== null
118
+ ? `url("https://art.hearthstonejson.com/v1/tiles/${ props . cardId } .png")`
119
+ : "rgba(255, 255, 255, 0.3)" } ;
118
120
` ;
119
121
120
122
const CardTileGem = CardTileTextElement . extend `
@@ -158,8 +160,18 @@ const CardTileCounter = (CardTileTextElement as any).extend`
158
160
border-left: solid 1px black;
159
161
` ;
160
162
163
+ const SkeletonLine = ( styled . span as any ) `
164
+ display: inline-block;
165
+ background-color: rgba(255, 255, 255, 0.3);
166
+ border-radius: 1em;
167
+ height: 0.75em;
168
+ width: ${ ( props : React . HTMLProps < HTMLSpanElement > & { width ?: string } ) =>
169
+ props . width || 0 } ;
170
+ ` ;
171
+
161
172
export interface CardTileState {
162
173
flashIndex : number ;
174
+ skeletonNameWidth ?: string ;
163
175
}
164
176
165
177
export default class CardTile extends React . Component <
@@ -170,6 +182,7 @@ export default class CardTile extends React.Component<
170
182
super ( props , context ) ;
171
183
this . state = {
172
184
flashIndex : 0 ,
185
+ skeletonNameWidth : `${ 35 + Math . round ( Math . random ( ) * 35 ) } %` ,
173
186
} ;
174
187
}
175
188
@@ -190,7 +203,11 @@ export default class CardTile extends React.Component<
190
203
return (
191
204
< CardTileName cardId = { this . props . id } >
192
205
{ this . props . icon ? < img src = { this . props . icon } /> : null }
193
- { this . props . name }
206
+ { this . props . name !== null ? (
207
+ this . props . name
208
+ ) : (
209
+ < SkeletonLine width = { this . state . skeletonNameWidth } />
210
+ ) }
194
211
</ CardTileName >
195
212
) ;
196
213
}
@@ -223,7 +240,11 @@ export default class CardTile extends React.Component<
223
240
< CardTileGem
224
241
rarity = { this . props . showRarity ? this . props . rarity : undefined }
225
242
>
226
- { this . props . cost }
243
+ { this . props . cost !== null ? (
244
+ this . props . cost
245
+ ) : (
246
+ < SkeletonLine width = { "0.75em" } />
247
+ ) }
227
248
</ CardTileGem >
228
249
{ this . renderName ( ) }
229
250
{ this . renderCount ( ) }
0 commit comments