2023-01-03 09:26:08 +01:00
|
|
|
<script>
|
2023-08-02 19:35:27 +01:00
|
|
|
import { page } from '$app/stores';
|
|
|
|
|
import HelpIcon from 'carbon-icons-svelte/lib/Help.svelte';
|
|
|
|
|
import ForumIcon from 'carbon-icons-svelte/lib/Forum.svelte';
|
2023-01-03 09:26:08 +01:00
|
|
|
|
2023-08-02 19:35:27 +01:00
|
|
|
import TextChip from '$lib/components/Chip/Text.svelte';
|
|
|
|
|
import OrgSelector from '$lib/components/OrgSelector/OrgSelector.svelte';
|
|
|
|
|
import HomeIcon from '$lib/components/Icons/HomeIcon.svelte';
|
|
|
|
|
import CourseIcon from '$lib/components/Icons/CourseIcon.svelte';
|
|
|
|
|
import QuizIcon from '$lib/components/Icons/QuizIcon.svelte';
|
|
|
|
|
import SiteSettingsIcon from '$lib/components/Icons/SiteSettingsIcon.svelte';
|
|
|
|
|
import AudienceIcon from '$lib/components/Icons/AudienceIcon.svelte';
|
|
|
|
|
import Avatar from '$lib/components/Avatar/index.svelte';
|
|
|
|
|
import { currentOrg, currentOrgPath } from '$lib/utils/store/org';
|
|
|
|
|
import { profile } from '$lib/utils/store/user';
|
2023-01-03 09:26:08 +01:00
|
|
|
|
2023-08-02 19:35:27 +01:00
|
|
|
let activeClass = 'bg-gray-200 dark:bg-gray-700';
|
2023-01-03 09:26:08 +01:00
|
|
|
|
2023-05-20 23:53:28 +00:00
|
|
|
const menuItems = [
|
|
|
|
|
{
|
|
|
|
|
path: '',
|
|
|
|
|
label: 'Home',
|
|
|
|
|
},
|
2023-06-17 19:11:29 +00:00
|
|
|
{
|
|
|
|
|
path: '/quiz',
|
|
|
|
|
label: 'Quizzes',
|
|
|
|
|
},
|
2023-05-20 23:53:28 +00:00
|
|
|
{
|
|
|
|
|
path: '/courses',
|
|
|
|
|
label: 'Courses',
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
path: '/community',
|
|
|
|
|
label: 'Community',
|
|
|
|
|
},
|
2023-06-17 19:11:29 +00:00
|
|
|
// {
|
|
|
|
|
// path: '/site',
|
|
|
|
|
// label: 'Site settings',
|
|
|
|
|
// },
|
2023-05-20 23:53:28 +00:00
|
|
|
{
|
|
|
|
|
path: '/audience',
|
|
|
|
|
label: 'Audience',
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
2023-01-03 09:26:08 +01:00
|
|
|
function isActive(pagePath, itemPath) {
|
|
|
|
|
const pageLinkItems = pagePath.split('/');
|
|
|
|
|
const itemLinkItems = itemPath.split('/');
|
|
|
|
|
|
|
|
|
|
if (itemLinkItems.length !== pageLinkItems.length) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pagePath.includes(itemPath);
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
2023-05-05 20:19:45 +00:00
|
|
|
<aside class="root bg-gray-100 dark:bg-gray-700 h-full">
|
2023-01-03 09:26:08 +01:00
|
|
|
<div class="h-full flex flex-col">
|
2023-04-22 20:00:37 +00:00
|
|
|
<div class="border-b border-gray-200 pt-5 px-4">
|
2023-07-28 09:06:03 +01:00
|
|
|
{#if $currentOrg.avatar_url && $currentOrg.name}
|
2023-05-02 23:55:26 +00:00
|
|
|
<Avatar
|
|
|
|
|
src={$currentOrg.avatar_url}
|
|
|
|
|
name={$currentOrg.name}
|
|
|
|
|
shape="rounded-md"
|
|
|
|
|
width="w-7"
|
|
|
|
|
height="h-7"
|
|
|
|
|
/>
|
2023-07-28 09:06:03 +01:00
|
|
|
{:else if $currentOrg.shortName}
|
2023-05-02 23:55:26 +00:00
|
|
|
<TextChip
|
|
|
|
|
value={$currentOrg.shortName}
|
|
|
|
|
className="bg-blue-200 font-bold"
|
|
|
|
|
/>
|
|
|
|
|
{/if}
|
2023-01-03 09:26:08 +01:00
|
|
|
|
|
|
|
|
<OrgSelector />
|
|
|
|
|
|
|
|
|
|
<ul class="my-5">
|
2023-05-20 23:53:28 +00:00
|
|
|
{#each menuItems as menuItem}
|
2023-06-17 19:11:29 +00:00
|
|
|
<a
|
|
|
|
|
href="{$currentOrgPath}{menuItem.path}"
|
|
|
|
|
class="text-black no-underline"
|
|
|
|
|
>
|
2023-05-20 23:53:28 +00:00
|
|
|
<li
|
|
|
|
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 dark:hover:bg-gray-500 {isActive(
|
2023-08-02 19:35:27 +01:00
|
|
|
$page.url.pathname,
|
2023-05-20 23:53:28 +00:00
|
|
|
`${$currentOrgPath}${menuItem.path}`
|
|
|
|
|
) && activeClass}"
|
|
|
|
|
>
|
|
|
|
|
{#if menuItem.path === ''}
|
|
|
|
|
<HomeIcon />
|
|
|
|
|
{:else if menuItem.path === '/courses'}
|
|
|
|
|
<CourseIcon />
|
|
|
|
|
{:else if menuItem.path === '/site'}
|
|
|
|
|
<SiteSettingsIcon />
|
|
|
|
|
{:else if menuItem.path === '/community'}
|
2023-08-02 19:35:27 +01:00
|
|
|
<ForumIcon size={20} class="carbon-icon" />
|
2023-06-17 19:11:29 +00:00
|
|
|
{:else if menuItem.path === '/quiz'}
|
|
|
|
|
<QuizIcon />
|
2023-05-20 23:53:28 +00:00
|
|
|
{:else if menuItem.path === '/audience'}
|
|
|
|
|
<AudienceIcon />
|
|
|
|
|
{/if}
|
|
|
|
|
<p class="dark:text-white ml-2">{menuItem.label}</p>
|
|
|
|
|
</li>
|
|
|
|
|
</a>
|
|
|
|
|
{/each}
|
2023-01-03 09:26:08 +01:00
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="flex-grow" />
|
2023-04-22 20:00:37 +00:00
|
|
|
<ul class="my-5 pb-5 px-4">
|
2023-06-17 19:11:29 +00:00
|
|
|
<a href={$currentOrgPath} class="text-black no-underline">
|
2023-05-05 20:19:45 +00:00
|
|
|
<li
|
|
|
|
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 dark:hover:bg-gray-500"
|
|
|
|
|
>
|
2023-08-02 19:35:27 +01:00
|
|
|
<HelpIcon size={20} class="carbon-icon" />
|
2023-05-05 20:19:45 +00:00
|
|
|
<p class="dark:text-white ml-2">Help</p>
|
2023-01-03 09:26:08 +01:00
|
|
|
</li>
|
|
|
|
|
</a>
|
2023-06-17 19:11:29 +00:00
|
|
|
<a href="{$currentOrgPath}/settings" class="text-black no-underline">
|
2023-01-03 09:26:08 +01:00
|
|
|
<li
|
2023-05-05 20:19:45 +00:00
|
|
|
class="flex items-center py-3 px-4 mb-2 rounded hover:bg-gray-200 dark:hover:bg-gray-500 {isActive(
|
2023-08-02 19:35:27 +01:00
|
|
|
$page.url.pathname,
|
2023-05-20 23:53:28 +00:00
|
|
|
`${$currentOrgPath}/settings`
|
2023-01-03 09:26:08 +01:00
|
|
|
) && activeClass}"
|
|
|
|
|
>
|
2023-05-02 23:55:26 +00:00
|
|
|
<Avatar
|
|
|
|
|
src={$profile.avatar_url}
|
|
|
|
|
name={$profile.username}
|
|
|
|
|
width="w-7"
|
|
|
|
|
height="h-7"
|
|
|
|
|
/>
|
2023-05-05 20:19:45 +00:00
|
|
|
<p class="dark:text-white ml-2">Settings</p>
|
2023-01-03 09:26:08 +01:00
|
|
|
</li>
|
|
|
|
|
</a>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
</aside>
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
.root {
|
|
|
|
|
width: 250px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|