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) + }, +)