LCOV - code coverage report
Current view: top level - src/platform/assets/components - AssetGrid.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 64.3 % 14 9
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2            2 :   <div
       3              :     data-component-id="AssetGrid"
       4              :     class="h-full"
       5              :     role="grid"
       6              :     :aria-label="$t('assetBrowser.assetCollection')"
       7              :     :aria-rowcount="-1"
       8              :     :aria-colcount="-1"
       9              :     :aria-setsize="assets.length"
      10              :   >
      11              :     <div v-if="loading" class="flex h-full items-center justify-center py-20">
      12              :       <i
      13              :         class="icon-[lucide--loader] size-12 animate-spin text-muted-foreground"
      14              :       />
      15              :     </div>
      16              :     <div
      17              :       v-else-if="assets.length === 0"
      18              :       class="flex h-full flex-col items-center justify-center py-16 text-muted-foreground select-none"
      19              :     >
      20              :       <i class="mb-4 icon-[lucide--search] size-10" />
      21              :       <h3 class="mb-2 text-lg font-medium">
      22              :         {{ emptyTitle ?? $t('assetBrowser.noAssetsFound') }}
      23              :       </h3>
      24              :       <p class="text-center text-sm whitespace-pre-wrap">
      25              :         {{ emptyMessage ?? $t('assetBrowser.tryAdjustingFilters') }}
      26              :       </p>
      27              :     </div>
      28              :     <VirtualGrid
      29              :       v-else
      30              :       :items="assetsWithKey"
      31              :       :grid-style
      32              :       :default-item-height="320"
      33              :       :default-item-width="240"
      34              :       :max-columns
      35              :     >
      36              :       <template #item="{ item }">
      37              :         <AssetCard
      38              :           :asset="item"
      39              :           :interactive="true"
      40              :           :focused="item.id === focusedAssetId"
      41              :           @focus="$emit('assetFocus', $event)"
      42              :           @select="$emit('assetSelect', $event)"
      43              :           @deleted="$emit('assetDeleted', $event)"
      44              :           @show-info="$emit('assetShowInfo', $event)"
      45              :         />
      46              :       </template>
      47              :     </VirtualGrid>
      48              :   </div>
      49              : </template>
      50              : 
      51              : <script setup lang="ts">
      52              : import { breakpointsTailwind, useBreakpoints } from '@vueuse/core'
      53              : import type { CSSProperties } from 'vue'
      54              : import { computed } from 'vue'
      55              : 
      56              : import VirtualGrid from '@comfyorg/design-system/common/VirtualGrid'
      57              : import AssetCard from '@/platform/assets/components/AssetCard.vue'
      58              : import type { AssetDisplayItem } from '@/platform/assets/composables/useAssetBrowser'
      59              : 
      60              : const { assets, focusedAssetId, emptyTitle, emptyMessage } = defineProps<{
      61              :   assets: AssetDisplayItem[]
      62              :   loading?: boolean
      63              :   focusedAssetId?: string | null
      64              :   emptyTitle?: string
      65              :   emptyMessage?: string
      66              : }>()
      67              : 
      68              : defineEmits<{
      69              :   assetFocus: [asset: AssetDisplayItem]
      70              :   assetSelect: [asset: AssetDisplayItem]
      71              :   assetDeleted: [asset: AssetDisplayItem]
      72              :   assetShowInfo: [asset: AssetDisplayItem]
      73              : }>()
      74              : 
      75            1 : const assetsWithKey = computed(() =>
      76              :   assets.map((asset) => ({ ...asset, key: asset.id }))
      77              : )
      78              : 
      79            1 : const breakpoints = useBreakpoints(breakpointsTailwind)
      80            1 : const is2Xl = breakpoints.greaterOrEqual('2xl')
      81            1 : const isXl = breakpoints.greaterOrEqual('xl')
      82            1 : const isLg = breakpoints.greaterOrEqual('lg')
      83            1 : const isMd = breakpoints.greaterOrEqual('md')
      84            1 : const maxColumns = computed(() => {
      85            0 :   if (is2Xl.value) return 5
      86            0 :   if (isXl.value) return 3
      87            0 :   if (isLg.value) return 3
      88            0 :   if (isMd.value) return 2
      89            0 :   return 1
      90              : })
      91              : 
      92            1 : const gridStyle: CSSProperties = {
      93              :   display: 'grid',
      94              :   gridTemplateColumns: 'repeat(auto-fill, minmax(15rem, 1fr))',
      95              :   gap: '1rem',
      96              :   padding: '0.5rem'
      97              : }
      98              : </script>
        

Generated by: LCOV version 2.0-1