Skip to content

Commit 626e9ba

Browse files
style(side-panel): highlight and disable active page
1 parent 53e6910 commit 626e9ba

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

src/routes/package/[...package]/SidePanel.svelte

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script lang="ts">
22
import type { ClassValue } from "svelte/elements";
3+
import { page } from "$app/state";
34
import { ChevronRight } from "@lucide/svelte";
45
import type { CategorizedPackage } from "$lib/server/package-discoverer";
56
import { cn } from "$lib/utils";
@@ -46,28 +47,39 @@
4647
<ul class="space-y-2">
4748
{#each packages as { pkg } (pkg.name)}
4849
<li>
49-
<a
50-
href="/package/{pkg.name}"
51-
class="group inline-flex w-full items-center underline-offset-4 hover:underline"
52-
>
53-
{pkg.name}
54-
<ChevronRight
55-
class="ml-auto size-4 text-primary transition-transform group-hover:translate-x-1"
56-
/>
57-
</a>
50+
{#if page.url.pathname.endsWith(pkg.name)}
51+
<span class="font-semibold">{pkg.name}</span>
52+
{:else}
53+
<a
54+
href="/package/{pkg.name}"
55+
class="group inline-flex w-full items-center underline-offset-4 hover:underline"
56+
>
57+
{pkg.name}
58+
<ChevronRight
59+
class="ml-auto size-4 text-primary transition-transform group-hover:translate-x-1"
60+
/>
61+
</a>
62+
{/if}
5863
</li>
5964
{/each}
6065
</ul>
6166
{:else}
62-
<a
63-
href="/package/{packages[0]?.pkg.name}"
64-
class="group inline-flex w-full items-center text-xl font-bold text-primary underline-offset-4 hover:underline"
65-
>
66-
{category.name}
67-
<ChevronRight
68-
class="ml-auto size-4 text-primary transition-transform group-hover:translate-x-1"
69-
/>
70-
</a>
67+
{@const firstPackageName = packages[0]?.pkg.name ?? ""}
68+
{#if page.url.pathname.endsWith(firstPackageName)}
69+
<span class="text-xl font-bold text-primary underline underline-offset-4">
70+
{category.name}
71+
</span>
72+
{:else}
73+
<a
74+
href="/package/{firstPackageName}"
75+
class="group inline-flex w-full items-center text-xl font-bold text-primary underline-offset-4 hover:underline"
76+
>
77+
{category.name}
78+
<ChevronRight
79+
class="ml-auto size-4 text-primary transition-transform group-hover:translate-x-1"
80+
/>
81+
</a>
82+
{/if}
7183
{/if}
7284
</li>
7385
{/each}

0 commit comments

Comments
 (0)