2023-09-11 11:47:30 +01:00
|
|
|
<script lang="ts">
|
2023-08-02 19:35:27 +01:00
|
|
|
import { page } from '$app/stores';
|
|
|
|
|
import HelpIcon from 'carbon-icons-svelte/lib/Help.svelte';
|
2023-08-15 14:28:51 +00:00
|
|
|
import LicenseDraft from 'carbon-icons-svelte/lib/LicenseDraft.svelte';
|
2024-07-09 21:17:34 +01:00
|
|
|
import Explore from 'carbon-icons-svelte/lib/Explore.svelte';
|
2023-08-02 19:35:27 +01:00
|
|
|
import HomeIcon from '$lib/components/Icons/HomeIcon.svelte';
|
|
|
|
|
import CourseIcon from '$lib/components/Icons/CourseIcon.svelte';
|
2023-08-07 19:44:26 +00:00
|
|
|
import CommunityIcon from '$lib/components/Icons/CommunityIcon.svelte';
|
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';
|
2024-09-30 01:36:12 +01:00
|
|
|
import { ChevronRight } from 'carbon-icons-svelte';
|
|
|
|
|
import ProfileMenu from '$lib/components/Org/ProfileMenu/index.svelte';
|
2024-06-09 21:11:19 +01:00
|
|
|
interface SideLinks {
|
2024-04-19 05:45:48 +01:00
|
|
|
name: string;
|
|
|
|
|
icon: any;
|
|
|
|
|
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
|
|
|
|
2024-06-09 21:11:19 +01:00
|
|
|
let sideLinks: SideLinks[] = [];
|
2024-04-19 05:45:48 +01:00
|
|
|
|
|
|
|
|
$: sideLinks = [
|
2023-08-07 19:44:26 +00:00
|
|
|
{
|
2024-04-19 05:45:48 +01:00
|
|
|
name: $t('lms_navigation.home'),
|
2023-08-07 19:44:26 +00:00
|
|
|
icon: HomeIcon,
|
|
|
|
|
link: '/lms'
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-19 05:45:48 +01:00
|
|
|
name: $t('lms_navigation.my_learning'),
|
2023-08-07 19:44:26 +00:00
|
|
|
icon: CourseIcon,
|
|
|
|
|
link: '/lms/mylearning'
|
|
|
|
|
},
|
|
|
|
|
{
|
2024-04-19 05:45:48 +01:00
|
|
|
name: $t('lms_navigation.exercise'),
|
2023-08-15 14:28:51 +00:00
|
|
|
icon: LicenseDraft,
|
2024-05-17 01:28:59 +01:00
|
|
|
link: '/lms/exercises',
|
|
|
|
|
show() {
|
|
|
|
|
return $currentOrg?.customization?.dashboard?.exercise;
|
|
|
|
|
}
|
2023-08-07 19:44:26 +00:00
|
|
|
},
|
|
|
|
|
{
|
2024-04-19 05:45:48 +01:00
|
|
|
name: $t('lms_navigation.community'),
|
2023-08-07 19:44:26 +00:00
|
|
|
icon: CommunityIcon,
|
2024-05-17 01:28:59 +01:00
|
|
|
link: '/lms/community',
|
|
|
|
|
show() {
|
|
|
|
|
return $currentOrg?.customization?.dashboard?.community;
|
|
|
|
|
}
|
2024-07-09 21:17:34 +01:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: $t('lms_navigation.explore'),
|
|
|
|
|
icon: Explore,
|
|
|
|
|
link: '/lms/explore'
|
2023-08-07 19:44:26 +00:00
|
|
|
}
|
2024-05-17 01:28:59 +01:00
|
|
|
].filter((link) => (link.show ? link.show() : true));
|
|
|
|
|
|
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
|
|
|
|
|
? '-translate-x-[100%] absolute md:translate-x-0 md:relative z-40 top-[48px] md:top-0'
|
|
|
|
|
: 'translate-x-0 absolute md:relative z-40 top-[48px] md:top-0'
|
|
|
|
|
} overflow-y-auto transition w-[250px] min-w-[250px] bg-gray-100 dark:bg-neutral-900 h-[calc(100vh-48px)]`}
|
|
|
|
|
>
|
|
|
|
|
<div class="h-full flex flex-col">
|
|
|
|
|
<div class="border-b border-gray-200 dark:border-neutral-600 pt-5 px-4">
|
|
|
|
|
<div class="w-full flex 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
|
|
|
|
2024-09-30 01:36:12 +01:00
|
|
|
<div class="mt-5 flex justify-center w-full">
|
|
|
|
|
<p
|
|
|
|
|
class="dark:text-white text-lg font-bold whitespace-nowrap truncate max-w-[80%] text-center"
|
2023-08-07 19:44:26 +00:00
|
|
|
>
|
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}
|
2024-09-30 01:36:12 +01:00
|
|
|
<a href={item.link} class="text-black" on:click={toggleSidebar}>
|
|
|
|
|
<li
|
|
|
|
|
class="flex items-center py-3 px-4 mb-2 {NavClasses.item} {isActive(
|
|
|
|
|
$page.url.pathname,
|
|
|
|
|
`${item.link}`
|
|
|
|
|
)
|
|
|
|
|
? NavClasses.active
|
|
|
|
|
: 'dark:text-white'}"
|
|
|
|
|
>
|
|
|
|
|
<svelte:component this={item.icon} size={24} class="carbon-icon dark:fill-[#fff]" />
|
|
|
|
|
<p class="dark:text-white ml-2">{item.name}</p>
|
|
|
|
|
</li>
|
|
|
|
|
</a>
|
|
|
|
|
{/each}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="flex-grow" />
|
|
|
|
|
<ul class="my-5 pb-5 px-4">
|
|
|
|
|
<a href="/lms" class="text-black" on:click={toggleSidebar}>
|
|
|
|
|
<li class="flex items-center py-3 px-4 mb-2 rounded">
|
|
|
|
|
<HelpIcon size={20} class="carbon-icon dark:text-white" />
|
|
|
|
|
<p class="dark:text-white ml-2">{$t('lms_navigation.help')}</p>
|
|
|
|
|
</li>
|
|
|
|
|
</a>
|
|
|
|
|
<button
|
|
|
|
|
class="w-full"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
$profileMenu.open = !$profileMenu.open;
|
|
|
|
|
$sideBar.hidden = true;
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
class="text-black no-underline cursor-pointer flex items-center justify-between mb-2 px-2.5 py-1.5 w-full {NavClasses.item}"
|
|
|
|
|
>
|
|
|
|
|
<div class="flex text-start items-center justify-start space-x-1">
|
|
|
|
|
<Avatar
|
|
|
|
|
src={$profile.avatar_url}
|
|
|
|
|
name={$profile.username}
|
|
|
|
|
width="w-[1.2rem]"
|
|
|
|
|
height="h-[1.2rem]"
|
|
|
|
|
/>
|
2024-10-07 02:29:08 +01:00
|
|
|
<p class="text-sm dark:text-white font-medium truncate max-w-full">
|
|
|
|
|
{$profile.fullname}
|
|
|
|
|
</p>
|
2024-09-30 01:36:12 +01:00
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<ChevronRight />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
2023-05-16 04:31:45 +00:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
2024-09-30 01:36:12 +01:00
|
|
|
</aside>
|
|
|
|
|
|
|
|
|
|
<ProfileMenu />
|
|
|
|
|
</div>
|