-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: develop
Are you sure you want to change the base?
Changes from 7 commits
900a1fc
020dacc
4880a3c
d1720fa
f952086
9840700
cee9075
288f297
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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" | ||
|
@@ -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}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you could use a svelte conditional or a ternary to render the different items on the navbar. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Conditional_operator |
||
<p class="font-bold">{label}</p> | ||
</a> | ||
{/each} | ||
</div> | ||
</nav> | ||
|
||
<style> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: theme('colors.muted-red.400'); | ||
padding: 2px 6px; | ||
border-radius: 4px; | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the pages that are not ready, this is linking for a 404 page. Shouldn't it be better to redirect to "#", as it was before?