mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
Use svelte:window to bind winWidth to improve SSR
Removed handler
This commit is contained in:
parent
c329008e62
commit
ee27d7b8cd
1 changed files with 3 additions and 13 deletions
|
@ -18,23 +18,13 @@
|
|||
|
||||
let isSideNavOpen = undefined;
|
||||
let winWidth = undefined;
|
||||
|
||||
onMount(() => {
|
||||
winWidth = window.innerWidth
|
||||
window.addEventListener('resize', () => {
|
||||
winWidth = window.innerWidth;
|
||||
$: isSideNavOpen = winWidth >= 1056
|
||||
|
||||
if (winWidth >= 1056) {
|
||||
isSideNavOpen = true;
|
||||
} else {
|
||||
isSideNavOpen = false;
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$: ariaLabel = company + (uiShellAriaLabel || $$props['aria-label'] || platformName);
|
||||
</script>
|
||||
|
||||
<svelte:window bind:innerWidth={winWidth} />
|
||||
|
||||
<header aria-label={ariaLabel} class={cx('--header')} role="banner">
|
||||
{#if winWidth < 1056}
|
||||
<HamburgerMenu bind:isOpen={isSideNavOpen} />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue