LCOV - code coverage report
Current view: top level - src/extensions/core/load3d/components/menubar - GizmoMenuGroup.vue Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 81.8 % 33 27
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1           13 : <template>
       2              :   <Button
       3              :     variant="textonly"
       4              :     size="unset"
       5              :     :tooltip="t('load3d.gizmo.toggle')"
       6              :     tooltip-side="bottom"
       7              :     :class="actionClass(gizmoEnabled)"
       8              :     :aria-pressed="gizmoEnabled"
       9              :     type="button"
      10              :     :aria-label="compact ? t('load3d.gizmo.toggle') : undefined"
      11              :     @click="toggleGizmo"
      12              :   >
      13              :     <i class="icon-[lucide--axis-3d]" />
      14              :     <span v-if="!compact">{{ t('load3d.gizmo.toggle') }}</span>
      15              :   </Button>
      16              : 
      17              :   <template v-if="gizmoEnabled">
      18              :     <template v-if="!compact">
      19            0 :       <Button
      20              :         v-for="m in modeDefs"
      21              :         :key="m.mode"
      22              :         variant="textonly"
      23              :         size="unset"
      24              :         :tooltip="t(m.labelKey)"
      25              :         tooltip-side="bottom"
      26              :         :class="actionClass(gizmoMode === m.mode)"
      27              :         :aria-pressed="gizmoMode === m.mode"
      28              :         type="button"
      29              :         @click="setGizmoMode(m.mode)"
      30              :       >
      31              :         <i :class="m.icon" />
      32              :         <span>{{ t(m.labelKey) }}</span>
      33              :       </Button>
      34              :       <Button
      35              :         variant="textonly"
      36              :         size="unset"
      37              :         :tooltip="t('load3d.gizmo.reset')"
      38              :         tooltip-side="bottom"
      39              :         :class="actionClass(false)"
      40              :         type="button"
      41              :         @click="resetGizmoTransform"
      42              :       >
      43              :         <i class="icon-[lucide--rotate-ccw]" />
      44              :         <span>{{ t('load3d.gizmo.reset') }}</span>
      45              :       </Button>
      46              :     </template>
      47              :     <PopoverRoot v-else v-model:open="modeMenuOpen">
      48              :       <PopoverTrigger as-child>
      49              :         <Button
      50              :           variant="textonly"
      51              :           size="unset"
      52              :           :tooltip="activeModeLabel"
      53              :           tooltip-side="bottom"
      54              :           :class="actionClass(false)"
      55              :           type="button"
      56              :           :aria-label="activeModeLabel"
      57              :           data-testid="gizmo-mode-menu"
      58              :         >
      59              :           <i :class="activeModeDef.icon" />
      60              :           <i class="icon-[lucide--chevron-down] opacity-70" />
      61              :         </Button>
      62              :       </PopoverTrigger>
      63              :       <PopoverContent align="start" :side-offset="8" :class="menuPanelClass">
      64           54 :         <button
      65              :           v-for="m in modeDefs"
      66              :           :key="m.mode"
      67              :           type="button"
      68              :           :aria-pressed="gizmoMode === m.mode"
      69              :           :class="
      70              :             cn(menuButtonClass, gizmoMode === m.mode && selectedMenuButtonClass)
      71              :           "
      72              :           @click="selectMode(m.mode)"
      73              :         >
      74              :           <i :class="m.icon" />
      75              :           {{ t(m.labelKey) }}
      76              :         </button>
      77              :         <button type="button" :class="menuButtonClass" @click="selectReset">
      78              :           <i class="icon-[lucide--rotate-ccw]" />
      79              :           {{ t('load3d.gizmo.reset') }}
      80              :         </button>
      81              :       </PopoverContent>
      82              :     </PopoverRoot>
      83              :   </template>
      84              : </template>
      85              : 
      86              : <script setup lang="ts">
      87              : import { PopoverRoot, PopoverTrigger } from 'reka-ui'
      88              : import { computed, watch } from 'vue'
      89              : import { useI18n } from 'vue-i18n'
      90              : 
      91              : import { cn } from '@comfyorg/tailwind-utils'
      92              : 
      93              : import {
      94              :   actionClass,
      95              :   menuPanelClass
      96              : } from '@/extensions/core/load3d/components/menubar/menuBarStyles'
      97              : import { usePopoverExclusivity } from '@/extensions/core/load3d/components/menubar/usePopoverExclusivity'
      98              : import Button from '@comfyorg/design-system/button/Button'
      99              : import PopoverContent from '@comfyorg/design-system/popover/PopoverContent'
     100              : import {
     101              :   menuButtonClass,
     102              :   selectedMenuButtonClass
     103              : } from '@comfyorg/design-system/lib/menu/menuStyles'
     104              : import type {
     105              :   GizmoMode,
     106              :   ModelConfig
     107              : } from '@comfyorg/viewport3d/load3d/interfaces'
     108              : 
     109              : const { compact = false } = defineProps<{
     110              :   compact?: boolean
     111              : }>()
     112              : 
     113            3 : const config = defineModel<ModelConfig>('config')
     114              : 
     115            3 : const emit = defineEmits<{
     116              :   (e: 'toggleGizmo', enabled: boolean): void
     117              :   (e: 'setGizmoMode', mode: GizmoMode): void
     118              :   (e: 'resetGizmoTransform'): void
     119              : }>()
     120              : 
     121            3 : const { t } = useI18n()
     122              : 
     123            3 : const modeDefs = [
     124              :   {
     125              :     mode: 'translate' as GizmoMode,
     126              :     icon: 'icon-[lucide--move]',
     127              :     labelKey: 'load3d.gizmo.translate'
     128              :   },
     129              :   {
     130              :     mode: 'rotate' as GizmoMode,
     131              :     icon: 'icon-[lucide--rotate-3d]',
     132              :     labelKey: 'load3d.gizmo.rotate'
     133              :   },
     134              :   {
     135              :     mode: 'scale' as GizmoMode,
     136              :     icon: 'icon-[lucide--scale-3d]',
     137              :     labelKey: 'load3d.gizmo.scale'
     138              :   }
     139              : ]
     140              : 
     141            3 : const gizmoEnabled = computed(() => config.value?.gizmo?.enabled ?? false)
     142            3 : const gizmoMode = computed(() => config.value?.gizmo?.mode ?? 'translate')
     143            3 : const activeModeDef = computed(
     144              :   () => modeDefs.find((m) => m.mode === gizmoMode.value) ?? modeDefs[0]
     145              : )
     146            3 : const activeModeLabel = computed(() => t(activeModeDef.value.labelKey))
     147              : 
     148            3 : const modeMenuOpen = usePopoverExclusivity()('gizmo-mode')
     149            3 : const modeMenuAvailable = computed(() => compact && gizmoEnabled.value)
     150            3 : watch(modeMenuAvailable, (available) => {
     151            3 :   if (!available) modeMenuOpen.value = false
     152              : })
     153              : 
     154            3 : function toggleGizmo() {
     155            3 :   const gizmo = config.value?.gizmo
     156            3 :   if (!gizmo) return
     157            3 :   gizmo.enabled = !gizmo.enabled
     158            3 :   emit('toggleGizmo', gizmo.enabled)
     159              : }
     160              : 
     161            3 : function setGizmoMode(mode: GizmoMode) {
     162            3 :   const gizmo = config.value?.gizmo
     163            3 :   if (!gizmo) return
     164            3 :   gizmo.mode = mode
     165            3 :   emit('setGizmoMode', mode)
     166              : }
     167              : 
     168            3 : function selectMode(mode: GizmoMode) {
     169            3 :   setGizmoMode(mode)
     170            3 :   modeMenuOpen.value = false
     171              : }
     172              : 
     173            0 : function selectReset() {
     174            0 :   resetGizmoTransform()
     175            0 :   modeMenuOpen.value = false
     176              : }
     177              : 
     178            0 : function resetGizmoTransform() {
     179            0 :   emit('resetGizmoTransform')
     180              : }
     181              : </script>
        

Generated by: LCOV version 2.0-1