mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
Fix window is undefined
Moving global window access to onMount hook for to fix "window is undefined" error when using with sapper, etc.
This commit is contained in:
parent
f085328279
commit
c329008e62
1 changed files with 16 additions and 12 deletions
|
@ -14,10 +14,13 @@
|
||||||
import UIShellSideNavWrapper from './UIShellSideNav/UIShellSideNavWrapper.svelte';
|
import UIShellSideNavWrapper from './UIShellSideNav/UIShellSideNavWrapper.svelte';
|
||||||
import UIShellSideNavItem from './UIShellSideNav/UIShellSideNavItem.svelte';
|
import UIShellSideNavItem from './UIShellSideNav/UIShellSideNavItem.svelte';
|
||||||
import HamburgerMenu from './UIShellSideNav/HamburgerMenu.svelte';
|
import HamburgerMenu from './UIShellSideNav/HamburgerMenu.svelte';
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
let isSideNavOpen = undefined;
|
let isSideNavOpen = undefined;
|
||||||
let winWidth = window.innerWidth;
|
let winWidth = undefined;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
winWidth = window.innerWidth
|
||||||
window.addEventListener('resize', () => {
|
window.addEventListener('resize', () => {
|
||||||
winWidth = window.innerWidth;
|
winWidth = window.innerWidth;
|
||||||
|
|
||||||
|
@ -27,6 +30,7 @@
|
||||||
isSideNavOpen = false;
|
isSideNavOpen = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
|
||||||
$: ariaLabel = company + (uiShellAriaLabel || $$props['aria-label'] || platformName);
|
$: ariaLabel = company + (uiShellAriaLabel || $$props['aria-label'] || platformName);
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue