From 1e982ade89b81e8a5a8e89e7c880e9e6d7a0efd3 Mon Sep 17 00:00:00 2001 From: Michael Wilson Date: Wed, 8 Feb 2023 11:58:27 +0930 Subject: [PATCH 1/3] feat(Menu): remove window & add currentUrl to props --- components/mdc/Menu/Menu.svelte | 2 -- 1 file changed, 2 deletions(-) diff --git a/components/mdc/Menu/Menu.svelte b/components/mdc/Menu/Menu.svelte index 1694c9c1..fb0c2b87 100644 --- a/components/mdc/Menu/Menu.svelte +++ b/components/mdc/Menu/Menu.svelte @@ -10,8 +10,6 @@ export let currentUrl = '' let menu = {} let element = {} -//don't use window for ssr -$: currentUrl = window?.location?.pathname || currentUrl $: menu.open = menuOpen onMount(() => { From 74efebb287d7bfe3d8d6c2f299442105aa9c3143 Mon Sep 17 00:00:00 2001 From: Michael Wilson Date: Wed, 8 Feb 2023 12:07:26 +0930 Subject: [PATCH 2/3] add currentUrl type --- index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/index.d.ts b/index.d.ts index 0db9758c..db4fa8c7 100644 --- a/index.d.ts +++ b/index.d.ts @@ -161,6 +161,7 @@ declare module '@silintl/ui-components' { interface MenuProps extends svelte.JSX.HTMLAttributes { menuItems?: MenuItem[] menuOpen?: boolean + currentUrl?: string } export class Menu extends SvelteComponentTyped {} From b0aca3233d4c0aa0bbfa1df1830da44ff6ef72d9 Mon Sep 17 00:00:00 2001 From: Michael Wilson Date: Wed, 8 Feb 2023 13:53:13 +0930 Subject: [PATCH 3/3] feat(Menu): remove focus of menuItem based on path. Add currentUrl story BREAKING CHANGE: remove checking of current path to focus menu item --- stories/Menu.stories.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/stories/Menu.stories.svelte b/stories/Menu.stories.svelte index 0de425eb..147f02c0 100644 --- a/stories/Menu.stories.svelte +++ b/stories/Menu.stories.svelte @@ -7,6 +7,7 @@ let content = 'Menu Button' const args = { class: 'dib relative opacity1', //for some reason the menu isn't behaving in storybook menuOpen: true, + currentUrl: '/?path=/story/atoms-menu--primary', menuItems: [ { subtitle: 'Alerts', @@ -15,16 +16,17 @@ const args = { icon: 'notifications', label: 'Alerts', action: () => alert('Hello!'), + url: '/?path=/story/atoms-menu--primary', }, { icon: 'settings', label: 'User settings', - url: '/household/settings', + url: '/', }, { icon: 'logout', label: 'Sign out', - url: '/logout', + url: '/', }, ], toggleMenu() {