2023-09-11 11:47:30 +01:00
|
|
|
<script lang="ts">
|
2025-11-01 15:49:29 +01:00
|
|
|
import type { Component } from 'svelte';
|
|
|
|
|
import { page } from '$app/state';
|
|
|
|
|
import BadgeHelpIcon from '@lucide/svelte/icons/badge-help';
|
|
|
|
|
import ListTodoIcon from '@lucide/svelte/icons/list-todo';
|
|
|
|
|
import MapPlusIcon from '@lucide/svelte/icons/map-plus';
|
|
|
|
|
import LayoutDashboardIcon from '@lucide/svelte/icons/layout-dashboard';
|
|
|
|
|
import LibraryBigIcon from '@lucide/svelte/icons/library-big';
|
|
|
|
|
import UsersIcon from '@lucide/svelte/icons/users';
|
2023-08-02 19:35:27 +01:00
|
|
|
import Avatar from '$lib/components/Avatar/index.svelte';
|
|
|
|
|
import { profile } from '$lib/utils/store/user';
|
2023-08-11 00:19:53 +01:00
|
|
|
import { NavClasses } from '$lib/utils/constants/reusableClass';
|
2024-09-30 01:36:12 +01:00
|
|
|
import { profileMenu, sideBar } from '$lib/components/Org/store';
|
2024-04-19 05:45:48 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
2024-05-17 01:28:59 +01:00
|
|
|
import { currentOrg } from '$lib/utils/store/org';
|
2025-11-01 15:49:29 +01:00
|
|
|
import ChevronRightIcon from '@lucide/svelte/icons/chevron-right';
|
2024-09-30 01:36:12 +01:00
|
|
|
import ProfileMenu from '$lib/components/Org/ProfileMenu/index.svelte';
|
2025-11-01 15:49:29 +01:00
|
|
|
|
2024-06-09 21:11:19 +01:00
|
|
|
interface SideLinks {
|
2024-04-19 05:45:48 +01:00
|
|
|
name: string;
|
2025-11-01 15:49:29 +01:00
|
|
|
icon: Component;
|
2024-04-19 05:45:48 +01:00
|
|
|
link: string;
|
2024-05-17 01:28:59 +01:00
|
|
|
show?: () => boolean;
|
2024-04-19 05:45:48 +01:00
|
|
|
}
|
2023-05-16 04:31:45 +00:00
|
|
|
|
2023-09-11 11:47:30 +01:00
|
|
|
function isActive(pagePath: string, itemPath: string) {
|
2023-05-16 04:31:45 +00:00
|
|
|
const pageLinkItems = pagePath.split('/');
|
|
|
|
|
const itemLinkItems = itemPath.split('/');
|
|
|
|
|
|
|
|
|
|
if (itemLinkItems.length !== pageLinkItems.length) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pagePath.includes(itemPath);
|
|
|
|
|
}
|
2024-04-19 05:45:48 +01:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
const sideLinks: SideLinks[] = $derived.by(() =>
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
name: $t('lms_navigation.home'),
|
|
|
|
|
icon: LayoutDashboardIcon,
|
|
|
|
|
link: '/lms'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('lms_navigation.my_learning'),
|
|
|
|
|
icon: LibraryBigIcon,
|
|
|
|
|
link: '/lms/mylearning'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('lms_navigation.exercise'),
|
|
|
|
|
icon: ListTodoIcon,
|
|
|
|
|
link: '/lms/exercises',
|
|
|
|
|
show() {
|
|
|
|
|
return $currentOrg?.customization?.dashboard?.exercise;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('lms_navigation.community'),
|
|
|
|
|
icon: UsersIcon,
|
|
|
|
|
link: '/lms/community',
|
|
|
|
|
show() {
|
|
|
|
|
return $currentOrg?.customization?.dashboard?.community;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('lms_navigation.explore'),
|
|
|
|
|
icon: MapPlusIcon,
|
|
|
|
|
link: '/lms/explore'
|
2024-05-17 01:28:59 +01:00
|
|
|
}
|
2025-11-01 15:49:29 +01:00
|
|
|
].filter((link) => (link.show ? link.show() : true))
|
|
|
|
|
);
|
2024-05-17 01:28:59 +01:00
|
|
|
|
2023-09-08 09:17:05 +00:00
|
|
|
const toggleSidebar = () => {
|
2023-11-01 09:45:40 +00:00
|
|
|
$sideBar.hidden = !$sideBar.hidden;
|
2023-09-08 09:17:05 +00:00
|
|
|
};
|
2023-05-16 04:31:45 +00:00
|
|
|
</script>
|
|
|
|
|
|
2024-09-30 01:36:12 +01:00
|
|
|
<div bind:this={$profileMenu.ref} class="static md:relative">
|
|
|
|
|
<aside
|
|
|
|
|
class={`${
|
|
|
|
|
$sideBar.hidden
|
2025-11-01 15:49:29 +01:00
|
|
|
? 'absolute top-[48px] z-40 -translate-x-[100%] md:relative md:top-0 md:translate-x-0'
|
|
|
|
|
: 'absolute top-[48px] z-40 translate-x-0 md:relative md:top-0'
|
|
|
|
|
} h-[calc(100vh-48px)] w-[250px] min-w-[250px] overflow-y-auto bg-gray-100 transition dark:bg-neutral-900`}
|
2024-09-30 01:36:12 +01:00
|
|
|
>
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="flex h-full flex-col">
|
|
|
|
|
<div class="border-b border-gray-200 px-4 pt-5 dark:border-neutral-600">
|
|
|
|
|
<div class="flex w-full flex-col items-center">
|
|
|
|
|
<Avatar src={$profile.avatar_url} name={$profile.fullname} shape="rounded-full" width="w-20" height="h-20" />
|
2023-05-16 04:31:45 +00:00
|
|
|
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="mt-5 flex w-full justify-center">
|
|
|
|
|
<p class="max-w-[80%] truncate whitespace-nowrap text-center text-lg font-bold dark:text-white">
|
2024-09-30 01:36:12 +01:00
|
|
|
{$profile.fullname}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<ul class="my-5">
|
2024-10-07 02:29:08 +01:00
|
|
|
{#each sideLinks as item}
|
2025-11-01 15:49:29 +01:00
|
|
|
<a href={item.link} class="text-black" onclick={toggleSidebar}>
|
2024-09-30 01:36:12 +01:00
|
|
|
<li
|
2025-11-01 15:49:29 +01:00
|
|
|
class="mb-2 flex items-center px-4 py-3 {NavClasses.item} {isActive(page.url.pathname, `${item.link}`)
|
2024-09-30 01:36:12 +01:00
|
|
|
? NavClasses.active
|
|
|
|
|
: 'dark:text-white'}"
|
|
|
|
|
>
|
2025-11-01 15:49:29 +01:00
|
|
|
<item.icon />
|
|
|
|
|
<p class="ml-2 dark:text-white">{item.name}</p>
|
2024-09-30 01:36:12 +01:00
|
|
|
</li>
|
|
|
|
|
</a>
|
|
|
|
|
{/each}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
2025-11-01 15:49:29 +01:00
|
|
|
<span class="flex-grow"></span>
|
|
|
|
|
<ul class="my-5 px-4 pb-5">
|
|
|
|
|
<a href="/lms" class="text-black" onclick={toggleSidebar}>
|
|
|
|
|
<li class="mb-2 flex items-center rounded px-4 py-3">
|
|
|
|
|
<BadgeHelpIcon size={16} />
|
|
|
|
|
<p class="ml-2 dark:text-white">{$t('lms_navigation.help')}</p>
|
2024-09-30 01:36:12 +01:00
|
|
|
</li>
|
|
|
|
|
</a>
|
|
|
|
|
<button
|
|
|
|
|
class="w-full"
|
2025-11-01 15:49:29 +01:00
|
|
|
onclick={() => {
|
2024-09-30 01:36:12 +01:00
|
|
|
$profileMenu.open = !$profileMenu.open;
|
|
|
|
|
$sideBar.hidden = true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div
|
2025-11-01 15:49:29 +01:00
|
|
|
class="mb-2 flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-black no-underline {NavClasses.item}"
|
2024-09-30 01:36:12 +01:00
|
|
|
>
|
2025-11-01 15:49:29 +01:00
|
|
|
<div class="flex items-center justify-start space-x-1 text-start">
|
|
|
|
|
<Avatar src={$profile.avatar_url} name={$profile.username} width="w-[1.2rem]" height="h-[1.2rem]" />
|
|
|
|
|
<p class="max-w-full truncate text-sm font-medium dark:text-white">
|
2024-10-07 02:29:08 +01:00
|
|
|
{$profile.fullname}
|
|
|
|
|
</p>
|
2024-09-30 01:36:12 +01:00
|
|
|
</div>
|
|
|
|
|
<div>
|
2025-11-01 15:49:29 +01:00
|
|
|
<ChevronRightIcon size={16} />
|
2024-09-30 01:36:12 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
2023-05-16 04:31:45 +00:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
2024-09-30 01:36:12 +01:00
|
|
|
</aside>
|
|
|
|
|
|
|
|
|
|
<ProfileMenu />
|
|
|
|
|
</div>
|