@@ -6,14 +6,20 @@ import { NuxtLink } from '#components'
6
6
const props = withDefaults (defineProps <{
7
7
node: ModuleTreeNode
8
8
icon? : string
9
+ iconOpen? : string
9
10
link? : string | boolean
11
+ padding? : number
12
+ open? : boolean
10
13
}>(), {
11
- icon: ' i-carbon-folder' ,
14
+ icon: ' i-catppuccin:folder catppuccin' ,
15
+ iconOpen: ' i-catppuccin:folder-open catppuccin' ,
16
+ padding: 0 ,
12
17
})
13
18
14
19
const emit = defineEmits <{
15
20
(e : ' select' , node : ModuleDest ): void
16
21
}>()
22
+ const open = defineModel <boolean >(' open' , { required: false , default: true })
17
23
const route = useRoute ()
18
24
const location = window .location
19
25
function select(node : ModuleDest ) {
@@ -24,40 +30,48 @@ function select(node: ModuleDest) {
24
30
</script >
25
31
26
32
<template >
27
- <details open >
33
+ <details : open= " open " @toggle = " e => open = (e.target as HTMLDetailsElement)?.open " >
28
34
<summary
29
35
cursor-default
30
36
select-none
31
37
text-sm
32
38
truncate
33
- p =" y1"
39
+ :style =" { paddingLeft: `${padding + 0.5}rem` }"
40
+ flex =" ~ gap-1"
41
+ px2 py1 rounded
42
+ hover =" bg-active "
34
43
>
35
- <div :class =" icon" inline-block vertical-text-bottom />
36
- {{ node.name }}
44
+ <div class =" i-ph:caret-right-duotone transition op50" :class =" open ? 'rotate-90' : ''" />
45
+ <div :class =" open ? iconOpen || icon : icon" inline-block vertical-text-bottom />
46
+ <div font-mono >
47
+ <DisplayHighlightedPath :path =" node.name || ''" />
48
+ </div >
37
49
</summary >
38
50
39
- <DisplayTreeNode v-for =" e of Object.entries(node.children)" :key =" e[0]" ml4 :node =" e[1]" :link =" link" />
40
- <div
41
- v-for =" i of node.items"
42
- :key =" i.full"
43
- ml4
44
- ws-nowrap
45
- >
46
- <component
47
- :is =" link ? NuxtLink : 'div'"
48
- :to =" link ? (typeof link === 'string' ? link : { path: route.path, query: { ...route.query, module: i.full }, hash: location.hash }) : undefined"
49
- block
50
- text-sm
51
- p =" x2 y1"
52
- ml1
53
- rounded
54
- @click =" select(i)"
55
- >
56
- <DisplayFileIcon :filename =" i.full" inline-block vertical-text-bottom />
57
- <span ml-1 >
58
- {{ i.path.split('/').pop() }}
59
- </span >
60
- </component >
61
- </div >
51
+ <template v-if =" open " >
52
+ <DisplayTreeNode
53
+ v-for =" e of Object.entries(node.children)"
54
+ :key =" e[0]" :node =" e[1]" :link =" link"
55
+ :padding =" padding + 1"
56
+ />
57
+ <template v-for =" i of node .items " :key =" i .full " >
58
+ <component
59
+ :is =" link ? NuxtLink : 'div'"
60
+ :to =" link ? (typeof link === 'string' ? link : { path: route.path, query: { ...route.query, module: i.full }, hash: location.hash }) : undefined"
61
+ text-sm
62
+ ws-nowrap
63
+ flex =" ~ gap-1"
64
+ px2 py1 rounded
65
+ hover =" bg-active"
66
+ :style =" { paddingLeft: `${padding + 2.7}rem` }"
67
+ @click =" select(i)"
68
+ >
69
+ <DisplayFileIcon :filename =" i.full" />
70
+ <div font-mono >
71
+ <DisplayHighlightedPath :path =" i.path.split('/').pop() || ''" />
72
+ </div >
73
+ </component >
74
+ </template >
75
+ </template >
62
76
</details >
63
77
</template >
0 commit comments