LCOV - code coverage report
Current view: top level - src/components/sidebar - SidebarIcon.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 8 8
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : <template>
       2        23119 :   <Button
       3              :     :tooltip="computedTooltip"
       4              :     tooltip-side="right"
       5              :     :class="
       6              :       cn(
       7              :         'side-bar-button h-(--sidebar-item-height) w-(--sidebar-width) shrink-0 rounded-none p-2 text-xs',
       8              :         selected && 'side-bar-button-selected'
       9              :       )
      10              :     "
      11              :     variant="muted-textonly"
      12              :     size="unset"
      13              :     :aria-label="accessibleName"
      14              :     @click="emit('click', $event)"
      15              :     @contextmenu="emit('contextmenu', $event)"
      16              :   >
      17              :     <div class="side-bar-button-content flex flex-col items-center gap-2">
      18              :       <slot name="icon">
      19              :         <div class="sidebar-icon-wrapper relative">
      20              :           <i
      21              :             v-if="typeof icon === 'string'"
      22              :             class="side-bar-button-icon size-5"
      23              :             :class="icon"
      24              :           />
      25              :           <component
      26              :             :is="icon"
      27              :             v-else-if="typeof icon === 'object'"
      28              :             class="side-bar-button-icon"
      29              :           />
      30              :           <span
      31              :             v-if="shouldShowBadge"
      32              :             :class="
      33              :               cn(
      34              :                 'sidebar-icon-badge absolute min-w-[16px] rounded-full bg-primary py-0.25 text-2xs leading-[14px] font-medium text-foreground',
      35              :                 badgeClass || '-top-1 -right-1'
      36              :               )
      37              :             "
      38              :           >
      39              :             {{ overlayValue }}
      40              :           </span>
      41              :           <span
      42              :             v-if="provenanceBadge"
      43              :             class="sidebar-icon-provenance-badge absolute -bottom-1 -left-1 min-w-[16px] rounded-full bg-secondary py-0.25 text-2xs leading-[14px] font-medium text-foreground"
      44              :           >
      45              :             {{ provenanceBadge }}
      46              :           </span>
      47              :         </div>
      48              :       </slot>
      49              :       <!-- w-max sizes the label to the rail instead of the padding-inset
      50              :            button content box, which is too narrow for one-line labels -->
      51              :       <span
      52              :         v-if="label && !isSmall"
      53              :         class="side-bar-button-label line-clamp-2 w-max max-w-[calc(var(--sidebar-width)-var(--sidebar-padding))] text-center text-2xs leading-none wrap-break-word whitespace-normal"
      54              :         >{{ st(label, label) }}</span
      55              :       >
      56              :     </div>
      57              :   </Button>
      58              : </template>
      59              : 
      60              : <script setup lang="ts">
      61              : import { computed } from 'vue'
      62              : import type { Component } from 'vue'
      63              : 
      64              : import Button from '@comfyorg/design-system/button/Button'
      65              : import { st } from '@/i18n'
      66              : import { cn } from '@comfyorg/tailwind-utils'
      67              : 
      68              : const {
      69              :   icon = '',
      70              :   selected = false,
      71              :   tooltip = '',
      72              :   tooltipSuffix = '',
      73              :   iconBadge = '',
      74              :   badgeClass = '',
      75              :   provenanceBadge = '',
      76              :   provenanceLabel = '',
      77              :   label = '',
      78              :   isSmall = false
      79              : } = defineProps<{
      80              :   icon?: string | Component
      81              :   selected?: boolean
      82              :   tooltip?: string
      83              :   tooltipSuffix?: string
      84              :   iconBadge?: string | (() => string | null)
      85              :   badgeClass?: string
      86              :   provenanceBadge?: string
      87              :   provenanceLabel?: string
      88              :   label?: string
      89              :   isSmall?: boolean
      90              : }>()
      91              : 
      92        22643 : const emit = defineEmits<{
      93              :   (e: 'click', event: MouseEvent): void
      94              :   (e: 'contextmenu', event: MouseEvent): void
      95              : }>()
      96        22643 : const overlayValue = computed(() =>
      97              :   typeof iconBadge === 'function' ? (iconBadge() ?? '') : iconBadge
      98              : )
      99        22643 : const shouldShowBadge = computed(() => !!overlayValue.value)
     100              : /**
     101              :  * Falls back to the label when no tooltip is provided, so labels clamped
     102              :  * to two lines can always be recovered in full on hover.
     103              :  */
     104        22643 : const computedTooltip = computed(() => {
     105        22698 :   const text = tooltip || label
     106        22698 :   return st(text, text) + tooltipSuffix
     107              : })
     108        22643 : const accessibleName = computed(() =>
     109              :   provenanceLabel
     110              :     ? `${computedTooltip.value} (${provenanceLabel})`
     111              :     : computedTooltip.value
     112              : )
     113              : </script>
     114              : 
     115              : <style>
     116              : .side-bar-button-icon {
     117              :   font-size: var(--sidebar-icon-size) !important;
     118              : }
     119              : 
     120              : .side-bar-button-selected {
     121              :   background-color: var(--muted);
     122              :   color: var(--foreground);
     123              : }
     124              : .side-bar-button:hover {
     125              :   background-color: var(--accent);
     126              :   color: var(--foreground);
     127              : }
     128              : </style>
        

Generated by: LCOV version 2.0-1