Skip to content

Commit c67a17c

Browse files
committed
fix: consistent folder styles
1 parent d8145fd commit c67a17c

File tree

2 files changed

+68
-43
lines changed

2 files changed

+68
-43
lines changed

packages/devtools/src/app/components/display/TreeNode.vue

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ import { NuxtLink } from '#components'
66
const props = withDefaults(defineProps<{
77
node: ModuleTreeNode
88
icon?: string
9+
iconOpen?: string
910
link?: string | boolean
11+
padding?: number
12+
open?: boolean
1013
}>(), {
11-
icon: 'i-carbon-folder',
14+
icon: 'i-catppuccin:folder catppuccin',
15+
iconOpen: 'i-catppuccin:folder-open catppuccin',
16+
padding: 0,
1217
})
1318
1419
const emit = defineEmits<{
1520
(e: 'select', node: ModuleDest): void
1621
}>()
22+
const open = defineModel<boolean>('open', { required: false, default: true })
1723
const route = useRoute()
1824
const location = window.location
1925
function select(node: ModuleDest) {
@@ -24,40 +30,48 @@ function select(node: ModuleDest) {
2430
</script>
2531

2632
<template>
27-
<details open>
33+
<details :open="open" @toggle="e => open = (e.target as HTMLDetailsElement)?.open">
2834
<summary
2935
cursor-default
3036
select-none
3137
text-sm
3238
truncate
33-
p="y1"
39+
:style="{ paddingLeft: `${padding + 0.5}rem` }"
40+
flex="~ gap-1"
41+
px2 py1 rounded
42+
hover="bg-active "
3443
>
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>
3749
</summary>
3850

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>
6276
</details>
6377
</template>

packages/devtools/src/app/components/modules/Folder.vue

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,34 @@ const moduleTree = computed(() => {
6363
v-if="Object.keys(moduleTree.workspace.children).length"
6464
:node="moduleTree.workspace"
6565
p="l3"
66-
icon="i-carbon-portfolio"
67-
:link="true"
68-
/>
69-
<DisplayTreeNode
70-
v-if="Object.keys(moduleTree.nodeModules.children).length"
71-
:node="moduleTree.nodeModules"
72-
p="l3"
73-
icon="i-carbon-categories"
74-
:link="true"
75-
/>
76-
<DisplayTreeNode
77-
v-if="Object.keys(moduleTree.virtual.children).length"
78-
:node="moduleTree.virtual"
79-
p="l3"
80-
icon="i-codicon:file-symlink-directory"
66+
icon="i-catppuccin:folder-dist catppuccin"
67+
icon-open="i-catppuccin:folder-dist-open catppuccin"
8168
:link="true"
8269
/>
70+
71+
<template v-if="Object.keys(moduleTree.nodeModules.children).length">
72+
<div w-full h-1px border="t base" />
73+
<DisplayTreeNode
74+
:node="moduleTree.nodeModules"
75+
p="l3"
76+
icon="i-catppuccin:folder-node catppuccin"
77+
icon-open="i-catppuccin:folder-node-open catppuccin"
78+
:link="true"
79+
:open="false"
80+
/>
81+
</template>
82+
83+
<template v-if="Object.keys(moduleTree.virtual.children).length">
84+
<div w-full h-1px border="t base" />
85+
<DisplayTreeNode
86+
:node="moduleTree.virtual"
87+
p="l3"
88+
icon="i-catppuccin:folder-components catppuccin"
89+
icon-open="i-catppuccin:folder-components-open catppuccin"
90+
:link="true"
91+
:open="false"
92+
/>
93+
</template>
8394
</div>
8495
</div>
8596
</template>

0 commit comments

Comments
 (0)