LCOV - code coverage report
Current view: top level - packages/design-system/src/components/navigation - NavItem.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 7 7
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2         2509 :   <Tooltip :disabled="!isOverflowing">
       3              :     <TooltipTrigger as-child>
       4              :       <div
       5              :         v-bind="$attrs"
       6              :         :class="
       7              :           cn(
       8              :             'flex cursor-pointer items-center-safe gap-2 rounded-md p-3 text-sm text-foreground transition-colors select-none',
       9              :             active ? 'bg-muted' : 'hover:bg-accent'
      10              :           )
      11              :         "
      12              :         role="button"
      13              :         @mouseenter="checkOverflow"
      14              :         @click="onClick"
      15              :       >
      16              :         <NavIcon v-if="icon" :icon="icon" />
      17              :         <i v-else class="icon-[lucide--folder] text-foreground" />
      18              :         <span ref="textRef" class="min-w-0 truncate">
      19              :           <slot />
      20              :         </span>
      21              :         <Badge
      22              :           v-if="badge !== undefined"
      23              :           severity="contrast"
      24              :           variant="circle"
      25              :           class="ml-auto min-h-5 min-w-5 px-1"
      26              :         >
      27              :           {{ badge }}
      28              :         </Badge>
      29              :         <i
      30              :           v-else-if="suffixIcon"
      31              :           :class="cn('ml-auto shrink-0', suffixIcon)"
      32              :           aria-hidden="true"
      33              :         />
      34              :       </div>
      35              :     </TooltipTrigger>
      36              :     <TooltipContent side="right" class="w-max whitespace-nowrap">{{
      37              :       tooltipText
      38              :     }}</TooltipContent>
      39              :   </Tooltip>
      40              : </template>
      41              : 
      42              : <script setup lang="ts">
      43              : import { computed, ref } from 'vue'
      44              : 
      45              : import Badge from '@comfyorg/design-system/badge/Badge'
      46              : import Tooltip from '@comfyorg/design-system/tooltip/Tooltip'
      47              : import TooltipContent from '@comfyorg/design-system/tooltip/TooltipContent'
      48              : import TooltipTrigger from '@comfyorg/design-system/tooltip/TooltipTrigger'
      49              : import type { NavItemData } from '@comfyorg/design-system/lib/navigation/types'
      50              : import { cn } from '@comfyorg/tailwind-utils'
      51              : 
      52              : import NavIcon from './NavIcon.vue'
      53              : 
      54              : defineOptions({ inheritAttrs: false })
      55              : 
      56              : const { icon, badge, suffixIcon, active, onClick } = defineProps<{
      57              :   icon: NavItemData['icon']
      58              :   badge?: NavItemData['badge']
      59              :   suffixIcon?: NavItemData['suffixIcon']
      60              :   active?: boolean
      61              :   onClick: () => void
      62              : }>()
      63              : 
      64         1426 : const textRef = ref<HTMLElement | null>(null)
      65         1426 : const isOverflowing = ref(false)
      66              : 
      67         1426 : const checkOverflow = () => {
      68           79 :   if (!textRef.value) return
      69           79 :   isOverflowing.value =
      70              :     textRef.value.scrollWidth > textRef.value.clientWidth + 1
      71              : }
      72              : 
      73         1426 : const tooltipText = computed(() => textRef.value?.textContent ?? '')
      74              : </script>
        

Generated by: LCOV version 2.0-1