2023-01-03 09:26:08 +01:00
|
|
|
<script>
|
2023-08-02 19:35:27 +01:00
|
|
|
import { page } from '$app/stores';
|
2023-08-03 19:31:59 +01:00
|
|
|
import { browser } from '$app/environment';
|
2023-08-02 19:35:27 +01:00
|
|
|
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';
|
2023-05-05 20:19:45 +00:00
|
|
|
|
2023-08-02 19:35:27 +01:00
|
|
|
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';
|
2023-08-02 19:35:27 +01:00
|
|
|
import { toggleBodyByTheme } from '$lib/utils/functions/app';
|
2023-01-03 09:26:08 +01:00
|
|
|
|
2023-08-05 04:44:32 +01:00
|
|
|
export let title = '';
|
2023-01-03 09:26:08 +01:00
|
|
|
export let navClass = '';
|
2023-08-05 04:44:32 +01:00
|
|
|
export let isCoursePage = false;
|
2023-05-05 20:19:45 +00:00
|
|
|
|
|
|
|
|
function toggleTheme() {
|
|
|
|
|
$appStore.isDark = !$appStore.isDark;
|
|
|
|
|
|
|
|
|
|
toggleBodyByTheme($appStore.isDark);
|
2023-08-03 19:31:59 +01:00
|
|
|
|
|
|
|
|
if (browser) {
|
|
|
|
|
localStorage.setItem('theme', $appStore.isDark ? 'dark' : '');
|
|
|
|
|
}
|
2023-05-05 20:19:45 +00:00
|
|
|
}
|
2023-08-05 04:44:32 +01:00
|
|
|
|
|
|
|
|
function getPathName(_isCoursePage) {
|
|
|
|
|
if (!_isCoursePage) {
|
2023-08-05 05:48:32 +01:00
|
|
|
return $currentOrgPath ?? '/';
|
2023-08-05 04:44:32 +01:00
|
|
|
}
|
|
|
|
|
|
2023-08-05 05:48:32 +01:00
|
|
|
return $currentOrgPath ? `${$currentOrgPath}/courses` : '';
|
2023-08-05 04:44:32 +01:00
|
|
|
}
|
2023-01-03 09:26:08 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<nav class="{navClass} flex w-full p-2 md:px-6 bg-blue-600">
|
|
|
|
|
<ul class="flex w-full items-center">
|
|
|
|
|
<div class="">
|
2023-08-05 04:44:32 +01:00
|
|
|
<a
|
|
|
|
|
href={getPathName(isCoursePage)}
|
|
|
|
|
title="Go to {isCoursePage ? 'Courses' : 'ClassroomIO Home'}"
|
|
|
|
|
id="logo"
|
|
|
|
|
class="text-lg"
|
|
|
|
|
>
|
|
|
|
|
{isCoursePage ? title : 'ClassroomIO'}
|
2023-01-03 09:26:08 +01:00
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<span class="flex-grow" />
|
|
|
|
|
|
|
|
|
|
<li>
|
2023-08-02 19:35:27 +01:00
|
|
|
<NotificationIcon size={20} class="text-white mr-2" />
|
2023-01-03 09:26:08 +01:00
|
|
|
</li>
|
2023-05-05 20:19:45 +00:00
|
|
|
<li>
|
|
|
|
|
<IconButton size="small" onClick={toggleTheme}>
|
|
|
|
|
{#if $appStore.isDark}
|
2023-08-02 19:35:27 +01:00
|
|
|
<Sun size={16} class="text-white" />
|
2023-05-05 20:19:45 +00:00
|
|
|
{:else}
|
2023-08-02 19:35:27 +01:00
|
|
|
<Moon size={16} class="text-white" />
|
2023-05-05 20:19:45 +00:00
|
|
|
{/if}
|
|
|
|
|
</IconButton>
|
|
|
|
|
</li>
|
2023-05-02 23:55:26 +00:00
|
|
|
<li />
|
2023-01-03 09:26:08 +01:00
|
|
|
</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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* [aria-current] {
|
|
|
|
|
color: var(--main-primary-color);
|
|
|
|
|
position: relative;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
}
|
|
|
|
|
[aria-current]::after {
|
|
|
|
|
position: absolute;
|
|
|
|
|
content: '';
|
|
|
|
|
width: calc(100% - 3em);
|
|
|
|
|
height: 2px;
|
|
|
|
|
background-color: var(--main-primary-color);
|
|
|
|
|
display: block;
|
|
|
|
|
bottom: -17px;
|
|
|
|
|
} */
|
|
|
|
|
|
|
|
|
|
@media only screen and (max-width: 1002px) {
|
|
|
|
|
nav.hide {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
ul {
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
padding: 0 0.5em;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|