Files
classroomio/apps/dashboard/src/lib/features/lms/components/learning.svelte
T

58 lines
2.2 KiB
Svelte
Raw Normal View History

<script lang="ts">
import { goto } from '$app/navigation';
import { Button } from '@cio/ui/base/button';
import { courses } from '$features/course/utils/store';
2024-04-19 05:45:48 +01:00
import { t } from '$lib/utils/functions/translations';
import { Empty } from '@cio/ui/custom/empty';
import BookOpenIcon from '@lucide/svelte/icons/book-open';
const gotoCourse = (id: string | undefined) => {
if (!id) return;
goto(`/courses/${id}/lessons?next=true`);
};
2025-11-01 15:49:29 +01:00
let last3Courses = $derived($courses.length > 0 ? $courses.slice(0, 3) : []);
</script>
<section class="h-full">
2025-11-01 15:49:29 +01:00
<p class="pb-3 text-base font-semibold text-[#040F2D] dark:text-white">
2024-04-19 05:45:48 +01:00
{$t('dashboard.current_lesson')}
</p>
<div
2025-11-01 15:49:29 +01:00
class="flex w-full flex-col items-center gap-2 rounded border border-[#EAEAEA] p-3 lg:h-[40vh] dark:bg-neutral-800"
>
{#if last3Courses.length > 0}
2025-11-01 15:49:29 +01:00
<div class="flex h-full w-full flex-col justify-start overflow-y-auto">
{#each last3Courses as course}
<div class="p-5">
2025-11-01 15:49:29 +01:00
<span class="flex flex-col items-start gap-3 pb-5 lg:flex-row">
<img
src={course.logo || '/images/classroomio-course-img-template.jpg'}
alt="course"
2025-11-01 15:49:29 +01:00
class="hidden lg:block lg:h-[60px] lg:w-[60px]"
/>
<div class="w-full">
<p class="text-base font-semibold dark:text-white">{course.title}</p>
<p class="line-clamp-2 text-xs font-normal text-[#656565] dark:text-white">
{course.description}
</p>
</div>
<Button variant="outline" onclick={() => gotoCourse(course.id)}>
{$t('dashboard.continue')}
</Button>
</span>
2025-11-01 15:49:29 +01:00
<div class="relative h-1 w-full bg-[#EAEAEA]">
<div
2025-11-01 15:49:29 +01:00
style="width: {Math.round(((course?.progress_rate ?? 0) / (course?.total_lessons ?? 0)) * 100) || 0}%"
class="bg-primary-700 absolute left-0 top-0 h-full"
></div>
</div>
</div>
{/each}
</div>
{:else}
<Empty title={$t('dashboard.no_courses')} description={$t('dashboard.start_course')} icon={BookOpenIcon} />
{/if}
</div>
</section>