Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
adriandelgado committed Aug 5, 2024
1 parent 99694ef commit bed9703
Showing 1 changed file with 17 additions and 68 deletions.
85 changes: 17 additions & 68 deletions src/routes/components/Navbar.svelte
Original file line number Diff line number Diff line change
@@ -1,85 +1,34 @@
<script lang="ts">
import { page } from "$app/stores";
import { derived } from "svelte/store";
import logo from "$lib/assets/images/logo.png";
// Derivar la ruta actual desde el store de la página
const path = derived(page, ($page) => $page.url.pathname);
const current_path = $derived($page.url.pathname);
// Variable que mantiene el path actual
let currentPath: string;
// Suscribirse al store para obtener actualizaciones
path.subscribe((value) => {
currentPath = value;
});
const LINKS = [
{ text: "Inicio", href: "/" },
{ text: "Eventos", href: "/events" },
{ text: "Proyectos", href: "/projects" },
{ text: "Contacto", href: "/contact" },
{ text: "Miembros", href: "/members" },
];
</script>

<nav class="relative flex items-center justify-between bg-black p-4">
<div class="flex items-center">
<img src={logo} alt="Logo" class="mr-4 h-10" />
</div>
<div class="flex space-x-8 text-lg text-white">
<!-- Enlace Inicio -->
<a href="/" class="hover:underline">
{#if currentPath === "/"}
<span class="font-bold text-green-400">
<span class="text-green-400">{"{"}</span>
<span class="text-white">Inicio</span>
<span class="text-green-400">{"}"}</span>
</span>
{:else}
Inicio
{/if}
</a>
<!-- Enlace Eventos -->
<a href="/events" class="hover:underline">
{#if currentPath === "/events"}
<span class="font-bold text-green-400">
<span class="text-green-400">{"{"}</span>
<span class="text-white">Eventos</span>
<span class="text-green-400">{"}"}</span>
</span>
{:else}
Eventos
{/if}
</a>
<!-- Enlace Proyectos -->
<a href="/projects" class="hover:underline">
{#if currentPath === "/projects"}
<span class="font-bold text-green-400">
<span class="text-green-400">{"{"}</span>
<span class="text-white">Proyectos</span>
<span class="text-green-400">{"}"}</span>
</span>
{:else}
Proyectos
{/if}
</a>
<!-- Enlace Contacto -->
<a href="/contact" class="hover:underline">
{#if currentPath === "/contact"}
<span class="font-bold text-green-400">
<span class="text-green-400">{"{"}</span>
<span class="text-white">Contacto</span>
<span class="text-green-400">{"}"}</span>
</span>
{:else}
Contacto
{/if}
</a>
<!-- Enlace Miembros -->
<a href="/member" class="hover:underline">
{#if currentPath === "/member"}
<span class="font-bold text-green-400">
{#each LINKS as { href, text }}
<a {href} class="font-bold hover:underline">
{#if current_path === href}
<span class="text-green-400">{"{"}</span>
<span class="text-white">Miembros</span>
<span>{text}</span>
<span class="text-green-400">{"}"}</span>
</span>
{:else}
Miembros
{/if}
</a>
{:else}
<span>{text}</span>
{/if}
</a>
{/each}
</div>
<div class="absolute bottom-0 left-0 z-0 h-px w-full bg-green-500"></div>
</nav>

0 comments on commit bed9703

Please sign in to comment.