Skip to content

Commit 5dc6d17

Browse files
committed
feat: add smooth animation to module collapsible
1 parent c01e899 commit 5dc6d17

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

packages/nimiq-vitepress-theme/src/layout/Sidebar.vue

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import type { NimiqVitepressSidebar, NimiqVitepressThemeConfig } from '../types'
33
import { createReusableTemplate } from '@vueuse/core'
4+
import { Motion } from 'motion-v'
45
import { CollapsibleContent, CollapsibleRoot, CollapsibleTrigger, ScrollAreaRoot, ScrollAreaScrollbar, ScrollAreaThumb, ScrollAreaViewport } from 'reka-ui'
56
import { useData, withBase } from 'vitepress'
67
import { ref } from 'vue'
@@ -74,15 +75,28 @@ function openAccordionInitialState(items: NimiqVitepressSidebar['items'][number]
7475
</CollapsibleTrigger>
7576

7677
<CollapsibleContent of-hidden data-open:shadow w-full mt-0>
77-
<div absolute z-90 bg-neutral-100 outline="~ 1.5 neutral-300" rounded-b-6 data-open:animate-slide-down data-closed:animate-slide-up w="[calc(100%-30px)]" shadow>
78+
<Motion
79+
as="div"
80+
:initial="{ height: 0,
81+
opacity: 0 }"
82+
:animate="submoduleNavigatorOpen ? { height: 'auto',
83+
opacity: 1 } : { height: 0,
84+
opacity: 0 }"
85+
:transition="{ duration: 0.25,
86+
ease: 'easeInOut' }"
87+
absolute z-90 bg-neutral-100 outline="~ 1.5 neutral-300" rounded-b-6 w="[calc(100%-30px)]" shadow
88+
>
7889
<ModulePill v-for="item in visibleModules.filter(m => m !== currentDocModule)" :key="item.text" :item="item" component="a" @click="submoduleNavigatorOpen = false" />
79-
</div>
90+
</Motion>
8091
</CollapsibleContent>
8192
</CollapsibleRoot>
8293

8394
<!-- Show expanded module pills when currentDocModule has no sidebar -->
84-
<div v-else-if="currentDocModule && (!currentDocModule.sidebar || !currentDocModule.sidebar.length)" w-full f-mt-sm>
85-
<ModulePill v-for="item in visibleModules" :key="item.text" :item="item" component="a" />
95+
<div v-else w-full f-mt-sm>
96+
<span nq-label text-11 text-neutral-700>
97+
Modules
98+
</span>
99+
<ModulePill v-for="item in visibleModules" :key="item.text" :item="item" component="a" px-0="!" />
86100
</div>
87101
</div>
88102

0 commit comments

Comments
 (0)