From ec30e076bc0cc6ce0d24eda5fc0cca43774a2281 Mon Sep 17 00:00:00 2001 From: Em_Dev Date: Sat, 20 Apr 2024 14:40:44 +0100 Subject: [PATCH] feat: list view on courses page (#269) * working on the list view * working on the list view navigation * worked on the list view for the course page * worked on the list view for the course page * clean up * rename store --------- Co-authored-by: Rotimi Best --- .../Courses/components/Card/index.svelte | 9 +- .../Courses/components/List/Loader.svelte | 7 ++ .../Courses/components/List/index.svelte | 90 +++++++++++++++++++ .../src/lib/components/Courses/index.svelte | 83 ++++++++++++----- .../src/lib/components/Courses/store.ts | 9 +- .../routes/org/[slug]/courses/+page.svelte | 30 ++++++- 6 files changed, 200 insertions(+), 28 deletions(-) create mode 100644 apps/dashboard/src/lib/components/Courses/components/List/Loader.svelte create mode 100644 apps/dashboard/src/lib/components/Courses/components/List/index.svelte diff --git a/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte b/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte index 93f4b062..2c323b62 100644 --- a/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte +++ b/apps/dashboard/src/lib/components/Courses/components/Card/index.svelte @@ -14,6 +14,7 @@ import Share from 'carbon-icons-svelte/lib/Share.svelte'; import UserFollow from 'carbon-icons-svelte/lib/UserFollow.svelte'; import { t } from '$lib/utils/functions/translations'; + import { onDestroy } from 'svelte'; export let bannerImage: string | undefined; export let id = ''; @@ -28,7 +29,7 @@ export let isOnLandingPage = false; export let isLMS = false; export let progressRate = 45; - export let showContextMenu = false; + let target: any; $: formatter = getCurrencyFormatter(currency); @@ -52,9 +53,13 @@ // TODO: Delete course functionality alert('WIP: Delete course'); } + + onDestroy(() => { + console.log('unmounting card'); + }); -{#if showContextMenu} +{#if !isLMS && !isOnLandingPage} + import { SkeletonPlaceholder, SkeletonText } from 'carbon-components-svelte'; + + +
+ +
diff --git a/apps/dashboard/src/lib/components/Courses/components/List/index.svelte b/apps/dashboard/src/lib/components/Courses/components/List/index.svelte new file mode 100644 index 00000000..d19fe8fe --- /dev/null +++ b/apps/dashboard/src/lib/components/Courses/components/List/index.svelte @@ -0,0 +1,90 @@ + + + goto(`/courses/${id}`)}> +

{title}

+ +

{description}

+
+ {#if !$isMobile} + {totalLessons} + {totalStudents} + + + {#if isPublished} + Published + {:else} + Unpublished + {/if} + + + {/if} + + { + e.stopPropagation(); + }} + > + + + + + + +
diff --git a/apps/dashboard/src/lib/components/Courses/index.svelte b/apps/dashboard/src/lib/components/Courses/index.svelte index d3497af3..5c95be46 100644 --- a/apps/dashboard/src/lib/components/Courses/index.svelte +++ b/apps/dashboard/src/lib/components/Courses/index.svelte @@ -1,11 +1,20 @@ @@ -118,11 +136,19 @@ { id: '2', text: $t('courses.course_filter.lessons') } ]} /> + {#if $courseMetaDeta.view === 'list'} + setViewPreference('grid')}> + + + {:else} + setViewPreference('list')}> + + + {/if} -