From 7328c6c0ecc94279a1ada7fb87eb7cb225974ad5 Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Tue, 7 Nov 2023 05:32:09 +0000 Subject: [PATCH] fix: Added min and max width for sidebar size for desktop --- packages/nc-gui/components/dashboard/View.vue | 48 +++++++++++++++++-- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/packages/nc-gui/components/dashboard/View.vue b/packages/nc-gui/components/dashboard/View.vue index d2fc9316ca..e9390e8e19 100644 --- a/packages/nc-gui/components/dashboard/View.vue +++ b/packages/nc-gui/components/dashboard/View.vue @@ -89,6 +89,8 @@ function handleMouseMove(e: MouseEvent) { function onWindowResize() { viewportWidth.value = window.innerWidth + + onResize(currentSidebarSize.value) } onMounted(() => { @@ -122,25 +124,56 @@ watch(sidebarState, () => { onMounted(() => { handleSidebarOpenOnMobileForNonViews() }) + +function onResize(widthPercent: any) { + if (isMobileMode.value) return + + const width = (widthPercent * viewportWidth.value) / 100 + + const fontSize = parseFloat(getComputedStyle(document.documentElement).fontSize) + + const widthRem = width / fontSize + + if (widthRem < 16) { + currentSidebarSize.value = ((16 * fontSize) / viewportWidth.value) * 100 + return + } else if (widthRem > 23.5) { + currentSidebarSize.value = ((23.5 * fontSize) / viewportWidth.value) * 100 + return + } + + console.log('onResize', widthRem, fontSize) + currentSidebarSize.value = widthPercent +} + +watch( + () => sideBarSize.value.current, + () => { + console.log('sidebarState', sideBarSize.value.current) + }, +)