2023-01-03 09:26:08 +01:00
|
|
|
<script lang="ts">
|
2023-09-13 06:49:26 +01:00
|
|
|
import { Tag, ImageLoader, SkeletonPlaceholder } from 'carbon-components-svelte';
|
2023-09-13 06:38:12 +01:00
|
|
|
// import { ROLE } from '$lib/utils/constants/roles';
|
2023-08-02 19:35:27 +01:00
|
|
|
import getCurrencyFormatter from '$lib/utils/functions/getCurrencyFormatter';
|
2023-01-03 09:26:08 +01:00
|
|
|
|
|
|
|
|
export let bannerImage: string | undefined;
|
2021-08-29 07:23:19 +03:00
|
|
|
export let id = '';
|
2023-05-15 15:13:42 +00:00
|
|
|
export let slug = '';
|
2021-08-29 07:23:19 +03:00
|
|
|
export let title = '';
|
|
|
|
|
export let description = '';
|
2023-09-13 06:38:12 +01:00
|
|
|
// export let role_id = ROLE.STUDENT;
|
2023-01-03 09:26:08 +01:00
|
|
|
export let isPublished = false;
|
|
|
|
|
export let cost = 0;
|
2023-01-03 09:53:20 +01:00
|
|
|
export let totalLessons = 0;
|
2023-01-03 09:26:08 +01:00
|
|
|
export let currency = 'NGN';
|
2023-05-15 15:13:42 +00:00
|
|
|
export let isOnLandingPage = false;
|
2023-09-10 07:24:06 +01:00
|
|
|
// export let onDelete = (id: string) => {};
|
2023-01-03 09:26:08 +01:00
|
|
|
|
|
|
|
|
let formatter = getCurrencyFormatter(currency);
|
2021-12-30 22:30:30 +02:00
|
|
|
|
2023-09-13 06:38:12 +01:00
|
|
|
// function getOptions() {
|
|
|
|
|
// return [
|
|
|
|
|
// {
|
|
|
|
|
// label: 'Make a copy',
|
|
|
|
|
// // Show this option only if user has admin control over this course.
|
|
|
|
|
// show: () => role_id === ROLE.ADMIN || role_id === ROLE.TUTOR,
|
|
|
|
|
// onClick() {
|
|
|
|
|
// // IIFI of copyCourseModal
|
|
|
|
|
// (() => {
|
|
|
|
|
// $copyCourseModal.id = id;
|
|
|
|
|
// $copyCourseModal.open = true;
|
|
|
|
|
// $copyCourseModal.title = `Copy of ${title}`;
|
|
|
|
|
// })();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// // {
|
|
|
|
|
// // label: 'Delete',
|
|
|
|
|
// // show: () => role_id === ROLE.TUTOR,
|
|
|
|
|
// // onClick() {
|
|
|
|
|
// // (async () => {
|
|
|
|
|
// // await deleteCourse(id);
|
|
|
|
|
// // onDelete(id);
|
|
|
|
|
// // console.log('Deleting');
|
|
|
|
|
// // })();
|
|
|
|
|
// // }
|
|
|
|
|
// // }
|
|
|
|
|
// ].filter((option) => option.show());
|
|
|
|
|
// }
|
2021-08-29 07:23:19 +03:00
|
|
|
</script>
|
|
|
|
|
|
2023-08-04 12:41:12 +01:00
|
|
|
<a rel="prefetch" href={isOnLandingPage ? `/course/${slug}` : `/courses/${id}`} class=" text-black">
|
2023-01-03 09:26:08 +01:00
|
|
|
<div
|
2023-09-13 06:38:12 +01:00
|
|
|
class="border border-gray w-full max-w-[400px] relative hover:shadow-lg transition-all ease-in-out"
|
2021-12-30 22:30:30 +02:00
|
|
|
>
|
2023-09-13 06:38:12 +01:00
|
|
|
<div class="p-4">
|
|
|
|
|
<div class=" mb-5">
|
2023-09-13 06:49:26 +01:00
|
|
|
<ImageLoader
|
2023-09-13 06:38:12 +01:00
|
|
|
src={bannerImage ?? '/images/classroomio-course-img-template.jpg'}
|
|
|
|
|
alt="Course Logo"
|
2023-09-13 06:49:26 +01:00
|
|
|
class="h-2/5 w-full rounded"
|
|
|
|
|
>
|
|
|
|
|
<svelte:fragment slot="loading">
|
|
|
|
|
<SkeletonPlaceholder style="width: 100%; height: 10rem;" />
|
|
|
|
|
</svelte:fragment>
|
|
|
|
|
<svelte:fragment slot="error">An error occurred.</svelte:fragment>
|
|
|
|
|
</ImageLoader>
|
2023-09-13 06:38:12 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h3 class="text-xl dark:text-white title">{title}</h3>
|
|
|
|
|
<p class="mt-2 text-sm text-gray-500 dark:text-gray-300 description">
|
2023-01-03 09:26:08 +01:00
|
|
|
{description}
|
|
|
|
|
</p>
|
2023-09-13 06:38:12 +01:00
|
|
|
</div>
|
2023-05-15 15:13:42 +00:00
|
|
|
|
2023-09-13 06:38:12 +01:00
|
|
|
<div class="px-4 border border-gray border-b-0 border-l-0 border-r-0 footer">
|
|
|
|
|
<p class="text-xs pt-2 pl-2 dark:text-white">{totalLessons} lessons</p>
|
|
|
|
|
<p class="text-xs py-2">
|
2023-05-15 15:13:42 +00:00
|
|
|
{#if isOnLandingPage}
|
2023-09-13 06:38:12 +01:00
|
|
|
<span class="px-2">{!cost ? 'Free' : formatter.format(cost)}</span>
|
2023-05-15 15:13:42 +00:00
|
|
|
{:else}
|
2023-09-13 06:38:12 +01:00
|
|
|
<Tag type={isPublished ? 'green' : 'cool-gray'}>
|
2023-05-15 15:13:42 +00:00
|
|
|
{#if isPublished}
|
|
|
|
|
Published
|
|
|
|
|
{:else}
|
|
|
|
|
Unpublished
|
|
|
|
|
{/if}
|
2023-09-13 06:38:12 +01:00
|
|
|
</Tag>
|
2023-05-15 15:13:42 +00:00
|
|
|
{/if}
|
2023-01-03 09:26:08 +01:00
|
|
|
</p>
|
2021-08-29 07:23:19 +03:00
|
|
|
</div>
|
2023-01-03 09:26:08 +01:00
|
|
|
</div>
|
|
|
|
|
</a>
|
2021-08-29 07:23:19 +03:00
|
|
|
|
|
|
|
|
<style>
|
2023-05-15 15:13:42 +00:00
|
|
|
a,
|
|
|
|
|
a:hover {
|
2021-12-30 22:30:30 +02:00
|
|
|
text-decoration: none;
|
|
|
|
|
}
|
2023-01-03 09:26:08 +01:00
|
|
|
.title,
|
2021-08-29 07:23:19 +03:00
|
|
|
.description {
|
2023-01-03 09:26:08 +01:00
|
|
|
height: 40px;
|
2021-08-29 07:23:19 +03:00
|
|
|
line-height: 20px;
|
|
|
|
|
display: -webkit-box;
|
|
|
|
|
-webkit-box-orient: vertical;
|
|
|
|
|
-moz-box-orient: vertical;
|
|
|
|
|
-ms-box-orient: vertical;
|
|
|
|
|
box-orient: vertical;
|
2023-01-03 09:26:08 +01:00
|
|
|
-webkit-line-clamp: 2;
|
|
|
|
|
-moz-line-clamp: 2;
|
|
|
|
|
-ms-line-clamp: 2;
|
|
|
|
|
line-clamp: 2;
|
2021-08-29 07:23:19 +03:00
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
</style>
|