Browse Source

feat(gui-v2): use useSidebar with storageKey

pull/3174/head
Wing-Kam Wong 2 years ago
parent
commit
4875f22c17
  1. 14
      packages/nc-gui-v2/components/smartsheet/sidebar/index.vue

14
packages/nc-gui-v2/components/smartsheet/sidebar/index.vue

@ -21,9 +21,9 @@ const route = useRoute()
provide(ViewListInj, views) provide(ViewListInj, views)
/** Sidebar visible */ /** Sidebar visible */
const sidebarOpen = inject(RightSidebarInj, ref(true)) const { isOpen } = useSidebar({ storageKey: 'nc-right-sidebar' })
const sidebarCollapsed = computed(() => !sidebarOpen.value) const sidebarCollapsed = computed(() => !isOpen.value)
/** Sidebar ref */ /** Sidebar ref */
const sidebar = ref() const sidebar = ref()
@ -96,21 +96,21 @@ function onCreate(view: GridType | FormType | KanbanType | GalleryType) {
class="group color-transition cursor-pointer hover:ring active:ring-pink-500 z-1 flex items-center p-[1px] absolute top-1/2 left-[-1rem] shadow bg-gray-100 rounded-full" class="group color-transition cursor-pointer hover:ring active:ring-pink-500 z-1 flex items-center p-[1px] absolute top-1/2 left-[-1rem] shadow bg-gray-100 rounded-full"
> >
<MaterialSymbolsChevronRightRounded <MaterialSymbolsChevronRightRounded
v-if="sidebarOpen" v-if="isOpen"
class="transform group-hover:(scale-115 text-pink-500) text-xl text-gray-400 nc-right-sidebar-toggle" class="transform group-hover:(scale-115 text-pink-500) text-xl text-gray-400 nc-right-sidebar-toggle"
@click="sidebarOpen = false" @click="isOpen = false"
/> />
<MaterialSymbolsChevronLeftRounded <MaterialSymbolsChevronLeftRounded
v-else v-else
class="transform group-hover:(scale-115 text-pink-500) text-xl text-gray-400 nc-right-sidebar-toggle" class="transform group-hover:(scale-115 text-pink-500) text-xl text-gray-400 nc-right-sidebar-toggle"
@click="sidebarOpen = true" @click="isOpen = true"
/> />
</div> </div>
</Transition> </Transition>
</a-tooltip> </a-tooltip>
<Toolbar v-if="sidebarOpen" class="flex items-center py-3 px-3 justify-between border-b-1" /> <Toolbar v-if="isOpen" class="flex items-center py-3 px-3 justify-between border-b-1" />
<Toolbar v-else class="py-3 px-2 max-w-[50px] flex !flex-col-reverse gap-4 items-center mt-[-1px]"> <Toolbar v-else class="py-3 px-2 max-w-[50px] flex !flex-col-reverse gap-4 items-center mt-[-1px]">
<template #start> <template #start>
@ -136,7 +136,7 @@ function onCreate(view: GridType | FormType | KanbanType | GalleryType) {
</template> </template>
</Toolbar> </Toolbar>
<div v-if="sidebarOpen" class="flex-1 flex flex-col"> <div v-if="isOpen" class="flex-1 flex flex-col">
<MenuTop @open-modal="openModal" @deleted="loadViews" @sorted="loadViews" /> <MenuTop @open-modal="openModal" @deleted="loadViews" @sorted="loadViews" />
<a-divider v-if="isUIAllowed('virtualViewsCreateOrEdit')" class="my-2" /> <a-divider v-if="isUIAllowed('virtualViewsCreateOrEdit')" class="my-2" />

Loading…
Cancel
Save