From bb261fcc4aa36786a7087114690d840e5bc1d01f Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Mon, 13 Jan 2025 21:20:31 -0800 Subject: [PATCH] refac: styling --- src/lib/components/layout/Sidebar.svelte | 27 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index a69e3290b..2d4262f42 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -345,12 +345,19 @@ onMount(async () => { showPinnedChat = localStorage?.showPinnedChat ? localStorage.showPinnedChat === 'true' : true; - mobile.subscribe((e) => { - if ($showSidebar && e) { + mobile.subscribe((value) => { + if ($showSidebar && value) { showSidebar.set(false); } - if (!$showSidebar && !e) { + if ($showSidebar && !value) { + const navElement = document.getElementsByTagName('nav')[0]; + if (navElement) { + navElement.style['-webkit-app-region'] = 'drag'; + } + } + + if (!$showSidebar && !value) { showSidebar.set(true); } }); @@ -362,14 +369,16 @@ // nav element is not available on the first render const navElement = document.getElementsByTagName('nav')[0]; - if ($mobile) { - if (!value) { - navElement.style['-webkit-app-region'] = 'drag'; + if (navElement) { + if ($mobile) { + if (!value) { + navElement.style['-webkit-app-region'] = 'drag'; + } else { + navElement.style['-webkit-app-region'] = 'no-drag'; + } } else { - navElement.style['-webkit-app-region'] = 'no-drag'; + navElement.style['-webkit-app-region'] = 'drag'; } - } else { - navElement.style['-webkit-app-region'] = 'drag'; } });