Skip to content

Commit 2444c72

Browse files
committed
feat: expandable container for chunk details
1 parent 63c5bdd commit 2444c72

File tree

3 files changed

+74
-21
lines changed

3 files changed

+74
-21
lines changed

packages/vite/src/app/components/chunks/Imports.vue

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ defineProps<{
77
</script>
88

99
<template>
10-
<div flex="~ col gap-1" mt2 ws-nowrap>
11-
<ChunksImportItem
12-
v-for="(chunk, index) in imports"
13-
:key="index"
14-
:chunk="chunk"
15-
hover="bg-active"
16-
border="~ base rounded" px2 py1 w-full
17-
/>
18-
</div>
10+
<DisplayExpandableContainer flex="~ col gap-1" mt2 ws-nowrap :list="imports">
11+
<template #default="{ items }">
12+
<ChunksImportItem
13+
v-for="(chunk, index) in items"
14+
:key="index"
15+
:chunk="chunk"
16+
hover="bg-active"
17+
border="~ base rounded" px2 py1 w-full
18+
/>
19+
</template>
20+
</DisplayExpandableContainer>
1921
</template>

packages/vite/src/app/components/data/ChunkDetails.vue

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,20 @@ const importers = computed((): RolldownChunkImport[] => {
102102
<summary op50>
103103
<span>Modules ({{ chunk.modules.length }})</span>
104104
</summary>
105-
<div flex="~ col gap-1" mt2 ws-nowrap>
106-
<DisplayModuleId
107-
v-for="module of chunk.modules"
108-
:id="module"
109-
:key="module"
110-
:session
111-
:link="true"
112-
:minimal="true"
113-
hover="bg-active"
114-
border="~ base rounded" px2 py1 w-full
115-
/>
116-
</div>
105+
<DisplayExpandableContainer flex="~ col gap-1" mt2 ws-nowrap :list="chunk.modules">
106+
<template #default="{ items }">
107+
<DisplayModuleId
108+
v-for="module of items"
109+
:id="module"
110+
:key="module"
111+
:session
112+
:link="true"
113+
:minimal="true"
114+
hover="bg-active"
115+
border="~ base rounded" px2 py1 w-full
116+
/>
117+
</template>
118+
</DisplayExpandableContainer>
117119
</details>
118120

119121
<VisualLoading v-if="isLoading" />
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<script setup lang="ts" generic="T">
2+
import { computed } from 'vue'
3+
4+
const props = defineProps<{
5+
list: T[]
6+
}>()
7+
8+
const count = defineModel('count', {
9+
default: 20,
10+
})
11+
12+
const initialCount = count.value
13+
14+
const top = computed(() => props.list.slice(0, count.value))
15+
</script>
16+
17+
<template>
18+
<div relative>
19+
<slot :items="top" />
20+
<div
21+
v-if="list.length > count"
22+
pointer-events-none absolute left-0 right-0 bottom-0 bg-gradient-more h-30
23+
flex="~ justify-center"
24+
>
25+
<button
26+
op35 p2 pt4 mta
27+
pointer-events-auto
28+
hover:op100
29+
flex="~ items-center gap-1 justify-center"
30+
@click="count = Math.round(count + initialCount)"
31+
>
32+
<div i-ri:arrow-down-double-line />
33+
<span>More</span>
34+
<DisplayNumberBadge prefix="+" :number="Math.min(Math.round(initialCount), props.list.length - count)" rounded-full text-sm />
35+
</button>
36+
<button
37+
op35 p2 pt4 mta
38+
pointer-events-auto
39+
hover:op100
40+
flex="~ items-center gap-1 justify-center"
41+
@click="count = props.list.length"
42+
>
43+
<div i-ph-arrows-out-line-vertical-duotone />
44+
<span>All</span>
45+
<DisplayNumberBadge :number="props.list.length" rounded-full text-sm />
46+
</button>
47+
</div>
48+
</div>
49+
</template>

0 commit comments

Comments
 (0)