1
1
import React from "react"
2
- import { styled , Link , SimpleMenu , SimpleMenuItem , Stack } from "ol-components"
2
+ import {
3
+ styled ,
4
+ Link ,
5
+ SimpleMenu ,
6
+ SimpleMenuItem ,
7
+ Stack ,
8
+ Skeleton ,
9
+ } from "ol-components"
3
10
import NextLink from "next/link"
4
11
import { EnrollmentStatus , EnrollmentMode } from "./types"
5
12
import type { DashboardCourse } from "./types"
@@ -247,6 +254,7 @@ type DashboardCardProps = {
247
254
courseNoun ?: string
248
255
offerUpgrade ?: boolean
249
256
contextMenuItems ?: SimpleMenuItem [ ]
257
+ isLoading ?: boolean
250
258
}
251
259
const DashboardCard : React . FC < DashboardCardProps > = ( {
252
260
dashboardResource,
@@ -256,10 +264,62 @@ const DashboardCard: React.FC<DashboardCardProps> = ({
256
264
courseNoun = "Course" ,
257
265
offerUpgrade = true ,
258
266
contextMenuItems = [ ] ,
267
+ isLoading = false ,
259
268
} ) => {
260
269
const { title, marketingUrl, enrollment, run } = dashboardResource
270
+ const titleSection = isLoading ? (
271
+ < >
272
+ < Skeleton variant = "text" width = "95%" height = { 16 } />
273
+ < Skeleton variant = "text" width = { 120 } height = { 16 } />
274
+ < Skeleton variant = "text" width = { 120 } height = { 16 } />
275
+ </ >
276
+ ) : (
277
+ < >
278
+ < TitleLink size = "medium" color = "black" href = { marketingUrl } >
279
+ { title }
280
+ </ TitleLink >
281
+ { enrollment ?. status === EnrollmentStatus . Completed ? (
282
+ < SubtitleLink href = "#" >
283
+ { < RiAwardLine size = "16px" /> }
284
+ View Certificate
285
+ </ SubtitleLink >
286
+ ) : null }
287
+ { enrollment ?. mode !== EnrollmentMode . Verified && offerUpgrade ? (
288
+ < UpgradeBanner
289
+ data-testid = "upgrade-root"
290
+ canUpgrade = { run . canUpgrade }
291
+ certificateUpgradeDeadline = { run . certificateUpgradeDeadline }
292
+ certificateUpgradePrice = { run . certificateUpgradePrice }
293
+ />
294
+ ) : null }
295
+ </ >
296
+ )
297
+ const buttonSection = isLoading ? (
298
+ < Skeleton variant = "rectangular" width = { 120 } height = { 32 } />
299
+ ) : (
300
+ < >
301
+ < EnrollmentStatusIndicator
302
+ status = { enrollment ?. status }
303
+ showNotComplete = { showNotComplete }
304
+ />
305
+ < CoursewareButton
306
+ data-testid = "courseware-button"
307
+ startDate = { run . startDate }
308
+ href = { run . coursewareUrl }
309
+ endDate = { run . endDate }
310
+ courseNoun = { courseNoun }
311
+ />
312
+ </ >
313
+ )
314
+ const startDateSection = isLoading ? (
315
+ < Skeleton variant = "text" width = { 100 } height = { 24 } />
316
+ ) : run . startDate ? (
317
+ < CourseStartCountdown startDate = { run . startDate } />
318
+ ) : null
261
319
const menuItems = contextMenuItems . concat ( getDefaultContextMenuItems ( title ) )
262
- const contextMenu = (
320
+ const contextMenu = isLoading ? (
321
+ < Skeleton variant = "rectangular" width = { 12 } height = { 24 } />
322
+ ) : (
263
323
< SimpleMenu
264
324
items = { menuItems }
265
325
trigger = {
@@ -277,42 +337,14 @@ const DashboardCard: React.FC<DashboardCardProps> = ({
277
337
className = { className }
278
338
>
279
339
< Stack justifyContent = "start" alignItems = "stretch" gap = "8px" flex = { 1 } >
280
- < TitleLink size = "medium" color = "black" href = { marketingUrl } >
281
- { title }
282
- </ TitleLink >
283
- { enrollment ?. status === EnrollmentStatus . Completed ? (
284
- < SubtitleLink href = "#" >
285
- { < RiAwardLine size = "16px" /> }
286
- View Certificate
287
- </ SubtitleLink >
288
- ) : null }
289
- { enrollment ?. mode !== EnrollmentMode . Verified && offerUpgrade ? (
290
- < UpgradeBanner
291
- data-testid = "upgrade-root"
292
- canUpgrade = { run . canUpgrade }
293
- certificateUpgradeDeadline = { run . certificateUpgradeDeadline }
294
- certificateUpgradePrice = { run . certificateUpgradePrice }
295
- />
296
- ) : null }
340
+ { titleSection }
297
341
</ Stack >
298
342
< Stack gap = "8px" >
299
343
< Stack direction = "row" gap = "8px" alignItems = "center" >
300
- < EnrollmentStatusIndicator
301
- status = { enrollment ?. status }
302
- showNotComplete = { showNotComplete }
303
- />
304
- < CoursewareButton
305
- data-testid = "courseware-button"
306
- startDate = { run . startDate }
307
- href = { run . coursewareUrl }
308
- endDate = { run . endDate }
309
- courseNoun = { courseNoun }
310
- />
344
+ { buttonSection }
311
345
{ contextMenu }
312
346
</ Stack >
313
- { run . startDate ? (
314
- < CourseStartCountdown startDate = { run . startDate } />
315
- ) : null }
347
+ { startDateSection }
316
348
</ Stack >
317
349
</ CardRoot >
318
350
)
@@ -332,23 +364,7 @@ const DashboardCard: React.FC<DashboardCardProps> = ({
332
364
width = "100%"
333
365
>
334
366
< Stack direction = "column" gap = "8px" flex = { 1 } >
335
- < TitleLink size = "medium" color = "black" href = { marketingUrl } >
336
- { title }
337
- </ TitleLink >
338
- { enrollment ?. status === EnrollmentStatus . Completed ? (
339
- < SubtitleLink href = "#" >
340
- { < RiAwardLine size = "16px" /> }
341
- View Certificate
342
- </ SubtitleLink >
343
- ) : null }
344
- { enrollment ?. mode !== EnrollmentMode . Verified && offerUpgrade ? (
345
- < UpgradeBanner
346
- data-testid = "upgrade-root"
347
- canUpgrade = { run . canUpgrade }
348
- certificateUpgradeDeadline = { run . certificateUpgradeDeadline }
349
- certificateUpgradePrice = { run . certificateUpgradePrice }
350
- />
351
- ) : null }
367
+ { titleSection }
352
368
</ Stack >
353
369
{ contextMenu }
354
370
</ Stack >
@@ -358,23 +374,9 @@ const DashboardCard: React.FC<DashboardCardProps> = ({
358
374
justifyContent = "space-between"
359
375
width = "100%"
360
376
>
361
- { run . startDate ? (
362
- < Stack justifyContent = "start" >
363
- < CourseStartCountdown startDate = { run . startDate } />
364
- </ Stack >
365
- ) : null }
377
+ { startDateSection }
366
378
< Stack direction = "row" gap = "8px" alignItems = "center" >
367
- < EnrollmentStatusIndicator
368
- status = { enrollment ?. status }
369
- showNotComplete = { showNotComplete }
370
- />
371
- < CoursewareButton
372
- data-testid = "courseware-button"
373
- startDate = { run . startDate }
374
- href = { run . coursewareUrl }
375
- endDate = { run . endDate }
376
- courseNoun = { courseNoun }
377
- />
379
+ { buttonSection }
378
380
</ Stack >
379
381
</ Stack >
380
382
</ CardRoot >
0 commit comments