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

highlighted the current page item on navebar #303

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
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
31 changes: 27 additions & 4 deletions src/routes/(app)/_components/layout/navbar.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
<script>
// @ts-expect-error Import is as expected but throws error

import { page } from '$app/stores';

$: currentPage = $page.url.pathname;
const links = [
{ href: '/team/', label: 'Equipa', pageComp: '/team' },
{ href: '/projects/', label: 'Projetos', pageComp: '/projects' },
{ href: '/events/', label: 'Eventos', pageComp: '/events' },
{ href: '/contacts/', label: 'Contactos', pageComp: '/contacts' }
];
</script>

<nav
class="fixed hidden h-min w-full grid-cols-2 items-center justify-center px-7 py-2 font-raleway text-xs text-white sm:grid sm:text-base"
aria-label="Navigation Bar"
Expand All @@ -9,9 +23,18 @@
</a>
</div>
<div class="flex justify-end gap-7">
<a href="/#/">Equipa</a>
<a href="/#/">Projetos</a>
<a href="/#/">Eventos</a>
<a href="/contacts">Contactos</a>
{#each links as { href, label, pageComp }}
<a class:active={currentPage === pageComp} {href}>
<p class="font-bold">{label}</p>
</a>
{/each}
</div>
</nav>

<style>
.active {
background-color: theme('colors.muted-red.400');
padding: 2px 6px;
border-radius: 4px;
}
</style>
Loading