mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21: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 isSideNavOpen = undefined;
|
||||||
let winWidth = undefined;
|
let winWidth = undefined;
|
||||||
|
$: isSideNavOpen = winWidth >= 1056
|
||||||
onMount(() => {
|
|
||||||
winWidth = window.innerWidth
|
|
||||||
window.addEventListener('resize', () => {
|
|
||||||
winWidth = window.innerWidth;
|
|
||||||
|
|
||||||
if (winWidth >= 1056) {
|
|
||||||
isSideNavOpen = true;
|
|
||||||
} else {
|
|
||||||
isSideNavOpen = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
|
|
||||||
$: ariaLabel = company + (uiShellAriaLabel || $$props['aria-label'] || platformName);
|
$: ariaLabel = company + (uiShellAriaLabel || $$props['aria-label'] || platformName);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:window bind:innerWidth={winWidth} />
|
||||||
|
|
||||||
<header aria-label={ariaLabel} class={cx('--header')} role="banner">
|
<header aria-label={ariaLabel} class={cx('--header')} role="banner">
|
||||||
{#if winWidth < 1056}
|
{#if winWidth < 1056}
|
||||||
<HamburgerMenu bind:isOpen={isSideNavOpen} />
|
<HamburgerMenu bind:isOpen={isSideNavOpen} />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue