Skip to content

Commit

Permalink
Merge pull request #182 from silinternational/feature/remove-window
Browse files Browse the repository at this point in the history
feat(Menu): remove window & add currentUrl to props
  • Loading branch information
hobbitronics authored Feb 8, 2023
2 parents e4b0b03 + b0aca32 commit a655d39
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 0 additions & 2 deletions components/mdc/Menu/Menu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ declare module '@silintl/ui-components' {
interface MenuProps extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap['div']> {
menuItems?: MenuItem[]
menuOpen?: boolean
currentUrl?: string
}
export class Menu extends SvelteComponentTyped<MenuProps> {}

Expand Down
6 changes: 4 additions & 2 deletions stories/Menu.stories.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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() {
Expand Down

0 comments on commit a655d39

Please sign in to comment.