Skip to content

Commit

Permalink
fix: close navbar on mobile when changing to new page (#153)
Browse files Browse the repository at this point in the history
* feat: add story to PromiseList component

* fix: navbar on mobile does not close when changing to new page

* fix: navbar on mobile does not close when changing to new page using context

* fix: navbar on mobile does not close when changing to new page fix small feedback
  • Loading branch information
SupeemAFK authored Oct 30, 2024
1 parent de51a54 commit a356823
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/components/NavigationBar/NavigationBar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import SideMenuList from './SideMenuList.svelte';
import SideMenuPane from './SideMenuPane.svelte';
import PromiseIcon from '$components/icons/PromiseIcon.svelte';
import { setContext } from 'svelte';
let screenSize: number;
let previousFromTop = 0;
Expand All @@ -87,6 +88,10 @@
previousFromTop = currentFromTop;
sideNavActive = false;
}
setContext('closeSideNav', () => {
sideNavActive = false;
});
</script>

<svelte:window bind:innerWidth={screenSize} on:scroll={scrollEventHandler} />
Expand Down
5 changes: 5 additions & 0 deletions src/components/NavigationBar/SideMenuLink.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@
import type { Menu } from '$models/menu';
import ArrowUpRightIcon from 'carbon-icons-svelte/lib/ArrowUpRight.svelte';
import { twMerge } from 'tailwind-merge';
import { getContext } from 'svelte';
export let linkMenu: Menu;
export let additionalClass = '';
const closeSideNav: () => void = getContext('closeSideNav');
</script>

{#if linkMenu.type === 'link'}
Expand All @@ -12,6 +16,7 @@
</div>
{/if}
<a
on:click={closeSideNav}
href={linkMenu.url}
class={twMerge(
'flex w-screen items-center pl-4 text-gray-30 no-underline decoration-gray-30 transition-all duration-200 hover:text-gray-10 md:w-80',
Expand Down

0 comments on commit a356823

Please sign in to comment.