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 8 commits into
base: develop
Choose a base branch
from
25 changes: 21 additions & 4 deletions src/routes/(app)/_components/layout/navbar.svelte
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
<script>
import { onMount } from 'svelte';
let currentUrl = '';

onMount(() => {
currentUrl = window.location.href;
});
</script>
Isaac3105 marked this conversation as resolved.
Show resolved Hide resolved

<nav
class="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 +18,17 @@
</a>
</div>
<div class="flex justify-end gap-7">
<a href="#/">Equipa</a>
<a href="#/">Projetos</a>
<a href="#/">Eventos</a>
<a href="#/">Contactos</a>
<a class:active={currentUrl === "http://localhost:3000/#/team/"} href="#/team/"><p class = "font-bold">Equipa</p></a>
<a class:active={currentUrl === "http://localhost:3000/#/projects/"} href="#/projects/"><p class = "font-bold">Projetos</p></a>
<a class:active={currentUrl === "http://localhost:3000/#/events/"} href="#/events/"><p class = "font-bold">Eventos</p></a>
<a class:active={currentUrl === "http://localhost:3000/#/contacts/"} href="#/contacts/"><p class = "font-bold">Contactos</p></a>
Isaac3105 marked this conversation as resolved.
Show resolved Hide resolved
Isaac3105 marked this conversation as resolved.
Show resolved Hide resolved
</div>
</nav>

<style>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are using Tailwind to define the style of html components, you should avoid using pure CSS.

.active {
background-color: rgba(116, 20, 20, 0.4);
padding: 2px 3px;
Isaac3105 marked this conversation as resolved.
Show resolved Hide resolved
border-radius: 4px;
}
</style>