Skip to content

Commit

Permalink
fix: better is active detection (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Jan 22, 2025
1 parent 44b69dc commit 7601197
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/lib/components/Navbar/NavbarItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
isActive?: () => boolean;
} & { icon?: string & Omit<IconProps, 'icon'> };
const startsWithHref = () => page.url.pathname.startsWith(href);
const matchesPath = () => page.url.pathname === href;
let {
href,
Expand All @@ -23,7 +23,7 @@
...iconProps
}: Props = $props();
const isActive = isActiveOverride ?? startsWithHref;
const isActive = isActiveOverride ?? matchesPath;
let active = $derived(activeOverride ?? isActive());
const styles = tv({
Expand Down
24 changes: 13 additions & 11 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@
</Navbar>
</AppShellHeader>

<AppShellSidebar class="min-w-[225px]">
<NavbarItem title="Home" icon={mdiHome} href="/" />
{#each componentGroups as group}
<NavbarGroup title={group.title} />
{#each group.components as component}
<NavbarItem
href={asComponentHref(component.name)}
title={component.name}
icon={component.icon}
/>
<AppShellSidebar class="min-w-[250px]">
<div class="mr-0 mt-4 md:mr-4">
<NavbarItem title="Home" icon={mdiHome} href="/" />
{#each componentGroups as group}
<NavbarGroup title={group.title} />
{#each group.components as component}
<NavbarItem
href={asComponentHref(component.name)}
title={component.name}
icon={component.icon}
/>
{/each}
{/each}
{/each}
</div>
</AppShellSidebar>

<section class="flex h-full flex-col">
Expand Down
1 change: 1 addition & 0 deletions src/routes/components/heading/SizeExample.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
<Heading size="medium">Heading</Heading>
<Heading size="large">Heading</Heading>
<Heading size="giant">Heading</Heading>
<Heading size="title">Heading</Heading>
</Stack>

0 comments on commit 7601197

Please sign in to comment.