2025-10-09 01:13:06 +01:00
|
|
|
<script lang="ts">
|
2023-08-02 19:35:27 +01:00
|
|
|
import { page } from '$app/stores';
|
|
|
|
|
import { user } from '$lib/utils/store/user';
|
|
|
|
|
import { isCoursePage } from '$lib/utils/functions/app';
|
2024-04-19 05:45:48 +01:00
|
|
|
import { t } from '$lib/utils/functions/translations';
|
2025-10-09 01:13:06 +01:00
|
|
|
import type { TCustomLinks } from './types';
|
|
|
|
|
|
|
|
|
|
import Logo from './Logo.svelte';
|
|
|
|
|
import CustomLinks from './CustomLinks.svelte';
|
|
|
|
|
import AuthButtons from './AuthButtons.svelte';
|
|
|
|
|
import MobileMenu from './MobileMenu.svelte';
|
2021-04-05 07:12:51 +03:00
|
|
|
|
2023-08-18 19:28:41 +00:00
|
|
|
export let disableSignup = false;
|
2025-10-09 01:13:06 +01:00
|
|
|
export let logo: string | undefined = undefined;
|
|
|
|
|
export let orgName: string | undefined = undefined;
|
2023-08-14 06:22:03 +01:00
|
|
|
export let isOrgSite = false;
|
2023-09-26 11:23:54 +01:00
|
|
|
export let backgroundColor = 'bg-white dark:bg-black';
|
2025-10-09 01:13:06 +01:00
|
|
|
export let customLinks: TCustomLinks | undefined = undefined;
|
2021-08-18 19:47:02 +03:00
|
|
|
|
|
|
|
|
let navClass = '';
|
2025-10-09 01:13:06 +01:00
|
|
|
let mobileMenuOpen = false;
|
2021-07-27 22:53:51 +03:00
|
|
|
|
2025-10-09 01:13:06 +01:00
|
|
|
$: redirect = isCoursePage($page.url.pathname) ? `?redirect=${$page.url.pathname}` : '';
|
|
|
|
|
$: showLinks =
|
|
|
|
|
customLinks && customLinks.show && customLinks.links && customLinks.links.length > 0;
|
2023-05-16 04:31:45 +00:00
|
|
|
|
2025-10-09 01:13:06 +01:00
|
|
|
function toggleMobileMenu() {
|
|
|
|
|
mobileMenuOpen = !mobileMenuOpen;
|
|
|
|
|
}
|
2021-04-05 07:12:51 +03:00
|
|
|
</script>
|
|
|
|
|
|
2021-07-27 22:53:51 +03:00
|
|
|
<nav
|
2025-09-10 18:17:27 +01:00
|
|
|
class="{navClass} {backgroundColor} sticky top-0 z-50 flex w-full border-b border-l-0 border-r-0 border-t-0 border-gray-300 px-2 py-1"
|
2021-07-27 22:53:51 +03:00
|
|
|
>
|
|
|
|
|
<ul class="flex w-full items-center">
|
2025-10-09 01:13:06 +01:00
|
|
|
<Logo {logo} {orgName} />
|
2021-08-18 19:47:02 +03:00
|
|
|
|
2021-07-27 22:53:51 +03:00
|
|
|
<span class="flex-grow" />
|
2021-08-18 19:47:02 +03:00
|
|
|
|
2025-10-09 01:13:06 +01:00
|
|
|
<!-- Mobile Menu Button - Only show when custom links exist -->
|
|
|
|
|
{#if isOrgSite && showLinks}
|
|
|
|
|
<button
|
|
|
|
|
class="mobile-menu-btn hover:text-primary-600 rounded-md p-2 text-gray-700 transition-colors duration-200 hover:bg-gray-100 lg:hidden"
|
|
|
|
|
on:click={toggleMobileMenu}
|
|
|
|
|
aria-label="Toggle mobile menu"
|
|
|
|
|
>
|
|
|
|
|
<svg class="h-6 w-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
|
|
|
<path
|
|
|
|
|
stroke-linecap="round"
|
|
|
|
|
stroke-linejoin="round"
|
|
|
|
|
stroke-width="2"
|
|
|
|
|
d="M4 6h16M4 12h16M4 18h16"
|
|
|
|
|
></path>
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
{#if customLinks && showLinks}
|
|
|
|
|
<CustomLinks {customLinks} />
|
|
|
|
|
{/if}
|
|
|
|
|
|
2023-05-16 04:31:45 +00:00
|
|
|
{#if $user.isLoggedIn}
|
2023-08-14 06:22:03 +01:00
|
|
|
{#if isOrgSite}
|
2024-04-19 05:45:48 +01:00
|
|
|
<li><a class="block" href="/lms"> {$t('navigation.goto_lms')} </a></li>
|
2023-07-19 07:22:42 +00:00
|
|
|
{/if}
|
2025-10-09 01:13:06 +01:00
|
|
|
{:else if isOrgSite && !$page.url.pathname?.includes('/404')}
|
|
|
|
|
<!-- Hide login/signup buttons on mobile when custom links exist -->
|
|
|
|
|
<div class="hidden lg:block">
|
|
|
|
|
<AuthButtons {disableSignup} {redirect} />
|
|
|
|
|
</div>
|
|
|
|
|
{:else if !isOrgSite && !$page.url.pathname?.includes('/404')}
|
|
|
|
|
<AuthButtons {disableSignup} {redirect} />
|
2023-05-16 04:31:45 +00:00
|
|
|
{/if}
|
2021-06-01 07:19:19 +03:00
|
|
|
</ul>
|
2025-10-09 01:13:06 +01:00
|
|
|
|
|
|
|
|
{#if showLinks}
|
|
|
|
|
<MobileMenu bind:mobileMenuOpen {customLinks} {disableSignup} {redirect} />
|
|
|
|
|
{/if}
|
2021-06-01 07:19:19 +03:00
|
|
|
</nav>
|
|
|
|
|
|
2021-04-05 07:12:51 +03:00
|
|
|
<style>
|
|
|
|
|
ul {
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
padding: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ul::after {
|
2021-07-18 19:12:39 +03:00
|
|
|
content: '';
|
2021-04-05 07:12:51 +03:00
|
|
|
display: block;
|
|
|
|
|
clear: both;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
text-decoration: none;
|
2021-09-24 13:20:40 +03:00
|
|
|
color: var(--main-primary-color);
|
2021-07-27 22:53:51 +03:00
|
|
|
padding: 0 1.5em;
|
2021-04-05 07:12:51 +03:00
|
|
|
font-weight: 700;
|
|
|
|
|
display: flex;
|
2025-09-10 18:17:27 +01:00
|
|
|
gap: 0.5rem;
|
2021-04-05 07:12:51 +03:00
|
|
|
align-items: center;
|
2025-10-09 01:13:06 +01:00
|
|
|
flex-direction: column;
|
2021-04-05 07:12:51 +03:00
|
|
|
}
|
|
|
|
|
|
2025-10-09 01:13:06 +01:00
|
|
|
/* Mobile menu button styles */
|
|
|
|
|
.mobile-menu-btn {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media only screen and (max-width: 1023px) {
|
2021-04-05 07:12:51 +03:00
|
|
|
nav.hide {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
ul {
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
2021-11-07 01:31:59 +02:00
|
|
|
|
|
|
|
|
a {
|
|
|
|
|
padding: 0 0.5em;
|
|
|
|
|
}
|
2025-10-09 01:13:06 +01:00
|
|
|
|
|
|
|
|
.mobile-menu-btn {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
2021-04-05 07:12:51 +03:00
|
|
|
}
|
|
|
|
|
</style>
|