|
| 1 | +<script setup lang="ts"> |
| 2 | +import type { GraphBase, GraphBaseOptions } from 'nanovis' |
| 3 | +import type { AssetChartInfo, AssetChartNode } from '~/types/assets' |
| 4 | +import { colorToCssBackground } from 'nanovis' |
| 5 | +import { useTemplateRef, watchEffect } from 'vue' |
| 6 | +
|
| 7 | +const props = defineProps<{ |
| 8 | + graph: GraphBase<AssetChartInfo | undefined, GraphBaseOptions<AssetChartInfo | undefined>> |
| 9 | + selected?: AssetChartNode | undefined |
| 10 | +}>() |
| 11 | +
|
| 12 | +const emit = defineEmits<{ |
| 13 | + (e: 'select', node: AssetChartNode | null): void |
| 14 | +}>() |
| 15 | +
|
| 16 | +const el = useTemplateRef<HTMLDivElement>('el') |
| 17 | +watchEffect(() => el.value?.append(props.graph.el)) |
| 18 | +</script> |
| 19 | + |
| 20 | +<template> |
| 21 | + <div grid="~ cols-[max-content_1fr] gap-2" p4> |
| 22 | + <div ref="el" w-500px /> |
| 23 | + <div flex="~ col gap-4"> |
| 24 | + <ChartAssetNavBreadcrumb |
| 25 | + border="b base" py2 |
| 26 | + :selected="selected" |
| 27 | + :options="graph.options" |
| 28 | + @select="emit('select', $event)" |
| 29 | + /> |
| 30 | + <div v-if="selected" grid="~ cols-[250px_1fr] gap-1"> |
| 31 | + <template v-for="child of selected.children" :key="child.id"> |
| 32 | + <button |
| 33 | + ws-nowrap text-nowrap text-left overflow-hidden text-ellipsis text-sm |
| 34 | + hover="bg-active" rounded px2 |
| 35 | + @click="emit('select', child)" |
| 36 | + > |
| 37 | + <span v-if="child.meta && child.meta === selected?.meta" text-primary>(self)</span> |
| 38 | + <span v-else>{{ child.id }}</span> |
| 39 | + </button> |
| 40 | + |
| 41 | + <button |
| 42 | + relative flex="~ gap-1 items-center" |
| 43 | + hover="bg-active" rounded |
| 44 | + @click="emit('select', child)" |
| 45 | + > |
| 46 | + <div |
| 47 | + h-5 rounded shadow border="~ base" |
| 48 | + :style="{ |
| 49 | + background: colorToCssBackground(graph.options.getColor?.(child) || '#000'), |
| 50 | + width: `${child.size / selected.size * 100}%`, |
| 51 | + }" |
| 52 | + /> |
| 53 | + <DisplayFileSizeBadge text-xs :bytes="child.size" :total="selected.size" :percent-ratio="3" /> |
| 54 | + <div |
| 55 | + v-if="child.children.length > 0" |
| 56 | + v-tooltip="`${child.children.length} dependencies`" |
| 57 | + :title="`${child.children.length} dependencies`" |
| 58 | + text-xs op-fade |
| 59 | + > |
| 60 | + ({{ child.children.length }}) |
| 61 | + </div> |
| 62 | + </button> |
| 63 | + </template> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + </div> |
| 67 | +</template> |
0 commit comments