Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use remote nav #101

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/lib/DesktopNav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<nav class:scrolled="{scrollMode}" class="left-nav" bind:clientWidth={leftNavWidth}>
{#each navigationLinksLeft as navigationLink, index (navigationLink.key)}
{#if !navigationLink.subsections}
{#if navigationLink.href}
<a href="{navigationLink.href}">{navigationLink.key}</a>
{:else}
<div on:mouseenter={(event) => {
Expand Down Expand Up @@ -42,7 +42,7 @@

<nav class:scrolled="{scrollMode}" class="right-nav" bind:clientWidth={rightNavWidth}>
{#each navigationLinksRight as navigationLink}
{#if !navigationLink.subsections}
{#if navigationLink.href}
<a href="{navigationLink.href}">{navigationLink.key}</a>
{:else}
<div on:mouseenter={(event) => {
Expand Down
5 changes: 2 additions & 3 deletions src/lib/MobileNav.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
import { afterNavigate } from "$app/navigation";
import NavLines from "$lib/NavLines.svelte";

export let navigationLinksLeft;
export let navigationLinksRight;
export let navigation;
export let scrollMode;
let isMobileMenuOpen;

Expand Down Expand Up @@ -35,7 +34,7 @@
</button>
</div>
<nav>
{#each [...navigationLinksLeft, ...navigationLinksRight] as navigationLink}
{#each navigation as navigationLink}
{#if navigationLink.href}
<div class="link-wrapper">
<a href="{navigationLink.href}">{navigationLink.key}</a>
Expand Down
30 changes: 5 additions & 25 deletions src/lib/Navbar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,10 @@
import DesktopNav from "$lib/DesktopNav.svelte";
import ProgressBar from "$lib/ProgressBar.svelte";

const navigationLinksLeft = [
{ key: "Новини", href: "/news" },
{ key: "За ученика", subsections: [
{ key: "Седмично разписание", href: "/student/weekly-schedule" },
{ key: "Учебници", href: "/student/books" },
{ key: "Вестник", href: "/student/newspaper" }
]},
{ key: "Прием", href: "/admission" },
{ key: "Организация", subsections: [
{ key: "Графици", href: "/organisation/schedules" },
{ key: "Документи", href: "/organisation/documents" },
{ key: "Административни услуги", href: "/organisation/administrative-services" },
{ key: "Бланки", href: "/organisation/forms" },
{ key: "Бюджет", href: "/organisation/budget" }
]},
];

const navigationLinksRight = [
{ key: "Проекти", href: "/projects" },
{ key: "Постижения", href: "/achievements" },
{ key: "За нас", href: "/about-us" },
{ key: "Контакти", href: "/contacts" },
];
export let navigation;

const navigationLinksRight = structuredClone(navigation)
const navigationLinksLeft = navigationLinksRight.splice(0, navigation.length / 2);

const mobileBreakpoint = 1150;

Expand Down Expand Up @@ -71,8 +52,7 @@
navigationLinksRight={navigationLinksRight} />
{:else}
<MobileNav scrollMode={scrollMode}
navigationLinksLeft={navigationLinksLeft}
navigationLinksRight={navigationLinksRight} />
navigation="{navigation}"/>
{/if}
{/if}
</div>
Expand Down
10 changes: 10 additions & 0 deletions src/routes/+layout.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ export async function load({ fetch }) {
}
}
}
Navigation {
sections {
key
href
subsections {
key
href
}
}
}
Contact {
locationInfo {
address
Expand Down
3 changes: 2 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@
showTitle="{$layout.navbar.showTitle}"
logoHref="{env.PUBLIC_SERVER_URL + data.MainInfo.logo.url}"
logoHrefAlt="{data.MainInfo.logo.alt}"
logoWidth="{data.MainInfo.logo.width}" />
logoWidth="{data.MainInfo.logo.width}"
navigation="{data.Navigation.sections}" />

<slot />

Expand Down
Loading