Skip to content
This repository was archived by the owner on May 1, 2025. It is now read-only.

Commit 21b5157

Browse files
committed
fix: improve navigation
1 parent 097e074 commit 21b5157

File tree

6 files changed

+55
-19
lines changed

6 files changed

+55
-19
lines changed

components/ContentNavItem.vue

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
<script setup lang="ts">
22
import type { NavItem } from '@nuxt/content/dist/runtime/types'
33
4-
const props = defineProps<{
5-
item: NavItem
6-
}>()
4+
const props = withDefaults(
5+
defineProps<{
6+
item: NavItem
7+
level: number
8+
}>(),
9+
{
10+
level: 0,
11+
},
12+
)
713
814
const ui = useUiState()
915
@@ -12,30 +18,42 @@ const resolved = computed(() => {
1218
return props.item.children[0]
1319
return props.item
1420
})
21+
22+
const paddingLeft = computed(() => `${0.5 + props.level * 0.8}rem`)
1523
</script>
1624

1725
<template>
18-
<div px1 py0.5 class="content-nav-item">
26+
<div class="content-nav-item">
1927
<template v-if="resolved.children?.length">
2028
<details>
2129
<summary>
22-
<div flex="~ gap-1 items-center" cursor-pointer select-none>
30+
<div
31+
flex="~ gap-1 items-center" cursor-pointer select-none px1 py0.5
32+
hover="text-primary bg-active"
33+
:style="{ paddingLeft }"
34+
>
2335
<div class="caret" i-ph-caret-right-duotone text-sm op50 transition duration-400 />
2436
<div i-ph-folder-simple-duotone />
2537
<div ml1>
2638
{{ resolved.title }}
2739
</div>
2840
</div>
2941
</summary>
30-
<div v-if="resolved.children?.length" pl-2>
31-
<ContentNavItem v-for="child in resolved.children" :key="child.url" :item="child" />
42+
<div v-if="resolved.children?.length">
43+
<ContentNavItem
44+
v-for="child in resolved.children"
45+
:key="child.url" :item="child" :level="props.level + 1"
46+
/>
3247
</div>
3348
</details>
3449
</template>
3550
<NuxtLink
36-
v-else :to="resolved._path"
51+
v-else
52+
:to="resolved._path"
53+
px1 py0.5
54+
:style="{ paddingLeft }"
3755
flex="~ gap-1 items-center"
38-
hover="text-primary"
56+
hover="text-primary bg-active "
3957
@click="ui.isContentDropdownShown = false"
4058
>
4159
<div i-ph-caret-right-duotone class="caret" text-sm op0 />

components/PanelDocs.vue

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const sourceUrl = computed(() => page.value?._file
6767
<div i-ph-book-duotone />
6868
<template v-for="bc, idx of breadcrumbs" :key="bc.path">
6969
<div v-if="idx !== 0" i-ph-caret-right mx--1 text-sm op50 />
70-
<NuxtLink :to="bc.path" text-sm hover="underline underline-dashed text-primary">
70+
<NuxtLink :to="bc.path" text-sm hover="text-primary">
7171
{{ bc.title }}
7272
</NuxtLink>
7373
</template>
@@ -109,15 +109,17 @@ const sourceUrl = computed(() => page.value?._file
109109
</div>
110110
</article>
111111
<!-- Navigration Dropdown -->
112-
<div
113-
v-if="ui.isContentDropdownShown"
114-
flex="~ col"
115-
border="b base"
116-
absolute left-0 right-0 top-0 max-h-60vh py2
117-
backdrop-blur-10 bg-base important-bg-opacity-80
118-
>
119-
<ContentNavItem v-for="item in navigation" :key="item.url" :item="item" />
120-
</div>
112+
<Transition name="nav-dropdown">
113+
<div
114+
v-if="ui.isContentDropdownShown"
115+
flex="~ col"
116+
border="b base"
117+
absolute left-0 right-0 top-0 max-h-60vh py2
118+
backdrop-blur-10 bg-base important-bg-opacity-80
119+
>
120+
<ContentNavItem v-for="item in navigation" :key="item.url" :item="item" />
121+
</div>
122+
</Transition>
121123
</div>
122124
<div border="t base dashed" px6 py2>
123125
<NuxtLink
@@ -131,3 +133,19 @@ const sourceUrl = computed(() => page.value?._file
131133
</div>
132134
</div>
133135
</template>
136+
137+
<style>
138+
.nav-dropdown-enter-active {
139+
transition: all 0.1s ease-out;
140+
}
141+
142+
.nav-dropdown-leave-active {
143+
transition: all 0.1s cubic-bezier(1, 0.5, 0.8, 1);
144+
}
145+
146+
.nav-dropdown-enter-from,
147+
.nav-dropdown-leave-to {
148+
transform: translateY(-100%);
149+
opacity: 0;
150+
}
151+
</style>
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)