Files
classroomio/apps/dashboard/src/lib/components/Navigation/app.svelte
T

141 lines
3.3 KiB
Svelte
Raw Normal View History

<script>
2023-10-22 09:47:13 +01:00
import { goto } from '$app/navigation';
2023-08-03 19:31:59 +01:00
import { browser } from '$app/environment';
import NotificationIcon from 'carbon-icons-svelte/lib/Notification.svelte';
import Moon from 'carbon-icons-svelte/lib/Moon.svelte';
import Sun from 'carbon-icons-svelte/lib/Sun.svelte';
import Menu from 'carbon-icons-svelte/lib/Menu.svelte';
import Close from 'carbon-icons-svelte/lib/Close.svelte';
2023-10-22 09:47:13 +01:00
import ArrowLeft from 'carbon-icons-svelte/lib/ArrowLeft.svelte';
import IconButton from '$lib/components/IconButton/index.svelte';
import { appStore } from '$lib/utils/store/app';
2023-08-05 04:44:32 +01:00
import { currentOrgPath } from '$lib/utils/store/org';
import { toggleBodyByMode } from '$lib/utils/functions/app';
2023-11-01 09:45:40 +00:00
import { sideBar } from '../Org/store';
2023-08-05 04:44:32 +01:00
export let title = '';
export let navClass = '';
2023-08-05 04:44:32 +01:00
export let isCoursePage = false;
const toggleSidebar = () => {
2023-11-01 09:45:40 +00:00
$sideBar.hidden = !$sideBar.hidden;
};
2023-08-20 19:08:48 +00:00
function toggleDarkMode() {
$appStore.isDark = !$appStore.isDark;
toggleBodyByMode($appStore.isDark);
2023-08-03 19:31:59 +01:00
if (browser) {
localStorage.setItem('mode', $appStore.isDark ? 'dark' : '');
2023-08-03 19:31:59 +01:00
}
}
2023-08-05 04:44:32 +01:00
2023-10-22 09:47:13 +01:00
$: coursesPath = $appStore.isOrgSite
? '/lms/mylearning'
: isCoursePage
? `${$currentOrgPath}/courses`
: $currentOrgPath;
</script>
2023-08-20 19:08:48 +00:00
<nav
class="{navClass} flex w-full p-1 md:px-6 bg-primary-700 transition delay-150 duration-300 ease-in-out h-[48px]"
2023-08-20 19:08:48 +00:00
>
<ul class="flex w-full items-center">
2023-08-05 07:47:17 +01:00
<div class="flex items-center text-white">
<li class="md:hidden">
2023-11-01 09:45:40 +00:00
<IconButton
onClick={() => {
toggleSidebar();
}}
>
{#if $sideBar.hidden}
<Menu size={16} class=" text-white" />
{:else}
<Close size={16} class=" text-white" />
{/if}
</IconButton>
</li>
2023-08-05 07:47:17 +01:00
{#if isCoursePage}
2023-10-04 08:18:33 +01:00
<li class="hidden md:block">
2023-11-01 09:45:40 +00:00
<IconButton
onClick={() => {
toggleSidebar();
}}
>
2023-10-04 08:18:33 +01:00
<Menu size={16} class=" text-white" />
</IconButton>
</li>
2023-10-22 09:47:13 +01:00
<li class="hidden md:block">
<IconButton onClick={() => goto(coursesPath)}>
<ArrowLeft size={16} class="text-white" />
</IconButton>
</li>
2023-08-05 07:47:17 +01:00
{/if}
2023-08-05 04:44:32 +01:00
<a
href={coursesPath}
2023-08-05 04:44:32 +01:00
title="Go to {isCoursePage ? 'Courses' : 'ClassroomIO Home'}"
id="logo"
2023-10-22 09:47:13 +01:00
class="text-lg line-clamp-1"
2023-08-05 04:44:32 +01:00
>
{isCoursePage ? title : 'ClassroomIO'}
</a>
</div>
<span class="flex-grow" />
<li>
<NotificationIcon size={20} class="text-white mr-2" />
</li>
<li>
2023-08-20 19:08:48 +00:00
<IconButton size="small" onClick={toggleDarkMode}>
{#if $appStore.isDark}
<Sun size={16} class="text-white" />
{:else}
<Moon size={16} class="text-white" />
{/if}
</IconButton>
</li>
2023-05-02 23:55:26 +00:00
<li />
</ul>
</nav>
<style>
ul {
padding: 0;
}
/* clearfix */
ul::after {
content: '';
display: block;
clear: both;
}
/* li.new-question {
margin-top: 10px;
} */
a {
text-decoration: none;
color: #fff;
font-weight: 700;
}
@media only screen and (max-width: 1002px) {
nav.hide {
display: none;
}
ul {
align-items: center;
}
a {
padding: 0 0.5em;
}
}
</style>