Files
Modrinth-plus/theseus_gui/src/components/VerticalNav.svelte

40 lines
810 B
Svelte
Raw Normal View History

2022-03-06 10:55:51 -08:00
<script lang="ts">
2022-08-03 00:44:17 -07:00
import type { SvelteComponent } from 'svelte';
import { page } from '$app/stores';
2022-03-06 10:55:51 -08:00
2022-08-03 00:44:17 -07:00
export let items: {
label: string;
/** Page href, without slash prefix */
href: string;
icon: SvelteComponent;
}[];
2022-03-06 10:55:51 -08:00
2022-08-03 00:44:17 -07:00
/** Path level in URL, zero-indexed */
export let level = 0;
2022-03-06 10:55:51 -08:00
2022-08-03 00:44:17 -07:00
let path: string[];
$: path = $page.url.pathname.substring(1).split('/');
2022-03-06 10:55:51 -08:00
</script>
<div class="vertical-nav">
2022-08-03 00:44:17 -07:00
{#each items as item (item.href)}
<a
class="nav-item"
href="/{item.href}"
class:active={path[level] === item.href}
sveltekit:prefetch
>
<svelte:component this={item.icon} />
{item.label}
</a>
{/each}
2022-03-06 10:55:51 -08:00
</div>
<style lang="postcss">
2022-08-03 00:44:17 -07:00
.vertical-nav {
display: flex;
flex-direction: column;
grid-gap: 0.25rem;
}
2022-03-06 10:55:51 -08:00
</style>