From cbae02cbbb9e4e14809f9017c8dcaf45b502215b Mon Sep 17 00:00:00 2001 From: Muhammed Mustafa Date: Mon, 25 Sep 2023 13:39:08 +0000 Subject: [PATCH] feat: Added config pinia store and integared isMobileMode with UI --- .../components/dashboard/Sidebar/Header.vue | 2 + packages/nc-gui/components/dashboard/View.vue | 11 +++++ .../components/smartsheet/Pagination.vue | 4 +- .../nc-gui/components/smartsheet/Toolbar.vue | 47 ++++++++++++------- .../nc-gui/components/smartsheet/Topbar.vue | 10 ++-- packages/nc-gui/store/config.ts | 29 ++++++++++++ 6 files changed, 80 insertions(+), 23 deletions(-) create mode 100644 packages/nc-gui/store/config.ts diff --git a/packages/nc-gui/components/dashboard/Sidebar/Header.vue b/packages/nc-gui/components/dashboard/Sidebar/Header.vue index f6ff58e904..511d206a35 100644 --- a/packages/nc-gui/components/dashboard/Sidebar/Header.vue +++ b/packages/nc-gui/components/dashboard/Sidebar/Header.vue @@ -4,6 +4,8 @@ const workspaceStore = useWorkspace() const { isLeftSidebarOpen } = storeToRefs(useSidebarStore()) const { activeWorkspace, isWorkspaceLoading } = storeToRefs(workspaceStore) + +const { isMobileMode } = useGlobal() diff --git a/packages/nc-gui/components/smartsheet/Topbar.vue b/packages/nc-gui/components/smartsheet/Topbar.vue index 012d0576dc..951f50abe0 100644 --- a/packages/nc-gui/components/smartsheet/Topbar.vue +++ b/packages/nc-gui/components/smartsheet/Topbar.vue @@ -10,7 +10,7 @@ const isPublic = inject(IsPublicInj, ref(false)) const { isViewsLoading } = storeToRefs(useViewsStore()) -const { isMobileMode } = useGlobal() +const { isMobileMode } = storeToRefs(useConfigStore()) const isSharedBase = computed(() => route.value.params.typeOrId === 'base') @@ -31,11 +31,13 @@ const isSharedBase = computed(() => route.value.params.typeOrId === 'base') -
+
-
+
+ +
- + diff --git a/packages/nc-gui/store/config.ts b/packages/nc-gui/store/config.ts new file mode 100644 index 0000000000..a7a478323c --- /dev/null +++ b/packages/nc-gui/store/config.ts @@ -0,0 +1,29 @@ +import { defineStore } from 'pinia' + +export const useConfigStore = defineStore('configStore', () => { + const { isMobileMode: globalIsMobile } = useGlobal() + const isMobileMode = ref(window.innerWidth < 820) + + const isViewPortMobile = () => window.innerWidth < 820 + + const onViewPortResize = () => { + isMobileMode.value = isViewPortMobile() + } + + window.addEventListener('DOMContentLoaded', onViewPortResize) + window.addEventListener('resize', onViewPortResize) + + watch( + isMobileMode, + () => { + globalIsMobile.value = isMobileMode.value + }, + { + immediate: true, + }, + ) + + return { + isMobileMode, + } +})