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

Conversation

Isaac3105
Copy link
Contributor

Closes #300

Now, if your current page is one of the pages from navebar, the corresponding item from the navebar will be highlighted.
image

Review checklist

  • Contains enough appropriate tests
  • Behavior is as expected
  • Clean, well-structured code

@Isaac3105 Isaac3105 assigned Isaac3105 and unassigned Isaac3105 Nov 30, 2024
Copy link
Collaborator

@MRita443 MRita443 left a comment

Choose a reason for hiding this comment

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

Good job! I left some suggestion as to how you can make this even better :)

src/routes/(app)/_components/layout/navbar.svelte Outdated Show resolved Hide resolved
src/routes/(app)/_components/layout/navbar.svelte Outdated Show resolved Hide resolved
src/routes/(app)/_components/layout/navbar.svelte Outdated Show resolved Hide resolved
src/routes/(app)/_components/layout/navbar.svelte Outdated Show resolved Hide resolved
Copy link
Contributor

@rubuy-74 rubuy-74 left a comment

Choose a reason for hiding this comment

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

Great job, there are just some small things that could be a little different.

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

$: currentPage = $page.url.pathname;
const links = [
Copy link
Contributor

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?

</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.

<a href="/#/">Eventos</a>
<a href="/contacts">Contactos</a>
{#each links as { href, label, pageComp }}
<a class:active={currentPage === pageComp} {href}>
Copy link
Contributor

Choose a reason for hiding this comment

The 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
https://svelte.dev/tutorial/svelte/if-blocks

@rubuy-74
Copy link
Contributor

rubuy-74 commented Jan 8, 2025

Another thing, now that the navbar has state, it should be nice to have some storybook tests. There are some examples already in the codebase but you can also use the documentation as reference.

https://storybook.js.org/docs/writing-tests

@MRita443 MRita443 self-requested a review January 17, 2025 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

navbar: highlight current page
3 participants