This repository was archived by the owner on May 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +85
-5
lines changed Expand file tree Collapse file tree 4 files changed +85
-5
lines changed Original file line number Diff line number Diff line change
1
+ <script setup lang="ts">
2
+ import type { NavItem } from ' @nuxt/content/dist/runtime/types'
3
+
4
+ const props = defineProps <{
5
+ item: NavItem
6
+ }>()
7
+
8
+ const ui = useUiState ()
9
+
10
+ const resolved = computed (() => {
11
+ if (props .item .children ?.length === 1 )
12
+ return props .item .children [0 ]
13
+ return props .item
14
+ })
15
+ </script >
16
+
17
+ <template >
18
+ <div px1 py0.5 class =" content-nav-item" >
19
+ <template v-if =" resolved .children ?.length " >
20
+ <details >
21
+ <summary >
22
+ <div flex =" ~ gap-1 items-center" cursor-pointer select-none >
23
+ <div class =" caret" i-ph-caret-right-duotone text-sm op50 transition duration-400 />
24
+ <div i-ph-folder-simple-duotone />
25
+ <div ml1 >
26
+ {{ resolved.title }}
27
+ </div >
28
+ </div >
29
+ </summary >
30
+ <div v-if =" resolved.children?.length" pl-2 >
31
+ <ContentNavItem v-for =" child in resolved.children" :key =" child.url" :item =" child" />
32
+ </div >
33
+ </details >
34
+ </template >
35
+ <NuxtLink
36
+ v-else :to =" resolved._path"
37
+ flex =" ~ gap-1 items-center"
38
+ hover =" text-primary"
39
+ @click =" ui.isContentDropdownShown = false"
40
+ >
41
+ <div i-ph-caret-right-duotone class =" caret" text-sm op0 />
42
+ <div i-ph-file-duotone />
43
+ <div ml1 >
44
+ {{ resolved.title }}
45
+ </div >
46
+ </NuxtLink >
47
+ </div >
48
+ </template >
49
+
50
+ <style >
51
+ .content-nav-item details summary {
52
+ list-style-type : none ;
53
+ }
54
+
55
+ .content-nav-item details [open ] .caret {
56
+ transform : rotate (90deg );
57
+ }
58
+ </style >
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
const { page } = useContent ()
3
+ const ui = useUiState ()
3
4
4
5
const sourceUrl = computed (() => page .value ?._file
5
6
? ` https://github.com/nuxt/learn.nuxt.com/edit/main/content/${page .value ._file } `
6
7
: undefined )
8
+
9
+ const { data : navigation } = await useAsyncData (' navigation' , () => fetchContentNavigation ())
7
10
</script >
8
11
9
12
<template >
10
- <div h-full grid =" ~ rows-[min-content_1fr_min-content]" >
11
- <div flex =" ~ gap-2 items-center" border =" b base dashed" bg-faded px4 py2 >
13
+ <div grid =" ~ rows-[min-content_1fr_min-content]" relative h-full >
14
+ <button
15
+ flex =" ~ gap-2 items-center" border =" b base dashed" bg-faded px4 py2
16
+ @click =" ui.isContentDropdownShown = !ui.isContentDropdownShown"
17
+ >
12
18
<div i-ph-book-duotone />
13
19
<NuxtLink to =" /" text-sm >
14
20
Guide
15
21
</NuxtLink >
22
+ <div flex-auto />
23
+ <div i-ph-caret-down-duotone text-sm op50 transition duration-400 :class =" ui.isContentDropdownShown ? 'rotate-180' : ''" />
24
+ </button >
25
+ <div relative h-full of-hidden >
26
+ <article class =" max-w-none prose" h-full of-auto p6 >
27
+ <ContentDoc />
28
+ </article >
29
+ <!-- Navigration Dropdown -->
30
+ <div
31
+ v-if =" ui.isContentDropdownShown"
32
+ flex =" ~ col"
33
+ border =" b base"
34
+ absolute left-0 right-0 top-0 max-h-60vh py2
35
+ backdrop-blur-10 bg-base important-bg-opacity-80
36
+ >
37
+ <ContentNavItem v-for =" item in navigation" :key =" item.url" :item =" item" />
38
+ </div >
16
39
</div >
17
- <article class =" max-w-none prose" of-auto p6 >
18
- <ContentDoc />
19
- </article >
20
40
<div border =" t base dashed" px6 py2 >
21
41
<NuxtLink
22
42
v-if =" sourceUrl"
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
export const useUiState = defineStore ( 'ui' , ( ) => {
2
2
const isPanelDragging = ref ( false )
3
+ const isContentDropdownShown = ref ( false )
3
4
4
5
const persistState = reactive ( getLayoutDefaults ( ) )
5
6
@@ -44,6 +45,7 @@ export const useUiState = defineStore('ui', () => {
44
45
45
46
return {
46
47
isPanelDragging,
48
+ isContentDropdownShown,
47
49
toggleTerminal,
48
50
resetLayout,
49
51
...toRefs ( persistState ) ,
You can’t perform that action at this time.
0 commit comments