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

            Line data    Source code
       1           13 : <template>
       2           11 :   <div
       3              :     class="flex h-10 shrink-0 items-center gap-1 bg-popover px-2"
       4              :     data-testid="load3d-animation-strip"
       5              :     @wheel.stop
       6              :   >
       7              :     <Button
       8              :       variant="textonly"
       9              :       size="icon"
      10              :       :tooltip="playLabel"
      11              :       type="button"
      12              :       :aria-label="playLabel"
      13              :       @click="playing = !playing"
      14              :     >
      15              :       <i :class="playing ? 'icon-[lucide--pause]' : 'icon-[lucide--play]'" />
      16              :     </Button>
      17              : 
      18              :     <Slider
      19              :       :model-value="[animationProgress]"
      20              :       :min="0"
      21              :       :max="100"
      22              :       :step="0.1"
      23              :       class="min-w-12 flex-1"
      24              :       @update:model-value="handleSliderChange"
      25              :     />
      26              : 
      27              :     <span
      28              :       v-if="!compact"
      29              :       class="shrink-0 text-xs text-foreground tabular-nums"
      30              :       data-testid="load3d-animation-time"
      31              :     >
      32              :       {{ formatAnimationTime(currentTime) }} /
      33              :       {{ formatAnimationTime(animationDuration) }}
      34              :     </span>
      35              : 
      36              :     <PopoverRoot v-model:open="speedOpen">
      37              :       <PopoverTrigger as-child>
      38              :         <Button
      39              :           variant="textonly"
      40              :           size="unset"
      41              :           :tooltip="t('load3d.menuBar.playbackSpeed')"
      42              :           :class="chipClass"
      43              :           type="button"
      44              :           :aria-label="t('load3d.menuBar.playbackSpeed')"
      45              :         >
      46              :           {{ speedLabel }}
      47              :           <i class="icon-[lucide--chevron-down] opacity-70" />
      48              :         </Button>
      49              :       </PopoverTrigger>
      50              :       <PopoverContent
      51              :         side="top"
      52              :         align="end"
      53              :         :side-offset="8"
      54              :         :class="menuPanelClass"
      55              :       >
      56            0 :         <button
      57              :           v-for="speed in speedOptions"
      58              :           :key="speed"
      59              :           type="button"
      60              :           :class="
      61              :             cn(
      62              :               menuButtonClass,
      63              :               selectedSpeed === speed && selectedMenuButtonClass
      64              :             )
      65              :           "
      66              :           :aria-pressed="selectedSpeed === speed"
      67              :           @click="setSpeed(speed)"
      68              :         >
      69              :           {{ formatSpeed(speed) }}
      70              :         </button>
      71              :       </PopoverContent>
      72              :     </PopoverRoot>
      73              : 
      74              :     <PopoverRoot v-model:open="clipOpen">
      75              :       <PopoverTrigger as-child>
      76              :         <Button
      77              :           variant="textonly"
      78              :           size="unset"
      79              :           :tooltip="t('load3d.menuBar.animationClip')"
      80              :           :class="cn(chipClass, 'max-w-40')"
      81              :           type="button"
      82              :           :aria-label="t('load3d.menuBar.animationClip')"
      83              :         >
      84              :           <i class="icon-[lucide--clapperboard]" />
      85              :           <span v-if="!compact" class="truncate">{{ selectedClipName }}</span>
      86              :           <i class="icon-[lucide--chevron-down] opacity-70" />
      87              :         </Button>
      88              :       </PopoverTrigger>
      89              :       <PopoverContent
      90              :         side="top"
      91              :         align="end"
      92              :         :side-offset="8"
      93              :         :class="menuPanelClass"
      94              :       >
      95            6 :         <button
      96              :           v-for="clip in animations"
      97              :           :key="clip.index"
      98              :           type="button"
      99              :           :class="
     100              :             cn(
     101              :               menuButtonClass,
     102              :               selectedAnimation === clip.index && selectedMenuButtonClass
     103              :             )
     104              :           "
     105              :           :aria-pressed="selectedAnimation === clip.index"
     106              :           @click="setClip(clip.index)"
     107              :         >
     108              :           <span class="truncate">{{ clip.name }}</span>
     109              :         </button>
     110              :       </PopoverContent>
     111              :     </PopoverRoot>
     112              :   </div>
     113              : </template>
     114              : 
     115              : <script setup lang="ts">
     116              : import { PopoverRoot, PopoverTrigger } from 'reka-ui'
     117              : import { computed } from 'vue'
     118              : import { useI18n } from 'vue-i18n'
     119              : 
     120              : import { cn } from '@comfyorg/tailwind-utils'
     121              : 
     122              : import { formatAnimationTime } from '@/extensions/core/load3d/components/formatAnimationTime'
     123              : import {
     124              :   chipClass,
     125              :   menuPanelClass
     126              : } from '@/extensions/core/load3d/components/menubar/menuBarStyles'
     127              : import { usePopoverExclusivity } from '@/extensions/core/load3d/components/menubar/usePopoverExclusivity'
     128              : import Button from '@comfyorg/design-system/button/Button'
     129              : import PopoverContent from '@comfyorg/design-system/popover/PopoverContent'
     130              : import {
     131              :   menuButtonClass,
     132              :   selectedMenuButtonClass
     133              : } from '@comfyorg/design-system/lib/menu/menuStyles'
     134              : import Slider from '@comfyorg/design-system/slider/Slider'
     135              : import type { AnimationItem } from '@comfyorg/viewport3d/load3d/interfaces'
     136              : 
     137              : const {
     138              :   animations = [],
     139              :   animationDuration = 0,
     140              :   compact = false
     141              : } = defineProps<{
     142              :   animations?: AnimationItem[]
     143              :   animationDuration?: number
     144              :   compact?: boolean
     145              : }>()
     146              : 
     147            2 : const playing = defineModel<boolean>('playing', { default: false })
     148            2 : const selectedSpeed = defineModel<number>('selectedSpeed', { default: 1 })
     149            2 : const selectedAnimation = defineModel<number>('selectedAnimation', {
     150              :   default: 0
     151              : })
     152            2 : const animationProgress = defineModel<number>('animationProgress', {
     153              :   default: 0
     154              : })
     155              : 
     156            2 : const emit = defineEmits<{
     157              :   seek: [progress: number]
     158              : }>()
     159              : 
     160            2 : const { t } = useI18n()
     161              : 
     162            2 : const speedOptions = [0.1, 0.5, 1, 1.5, 2]
     163              : 
     164            2 : const exclusivePopover = usePopoverExclusivity()
     165            2 : const speedOpen = exclusivePopover('animation-speed')
     166            2 : const clipOpen = exclusivePopover('animation-clip')
     167              : 
     168            2 : const playLabel = computed(() => t(playing.value ? 'g.pause' : 'g.play'))
     169            2 : const speedLabel = computed(() => formatSpeed(selectedSpeed.value))
     170            2 : const selectedClipName = computed(
     171              :   () =>
     172              :     animations.find((clip) => clip.index === selectedAnimation.value)?.name ??
     173              :     ''
     174              : )
     175            2 : const currentTime = computed(
     176              :   () => (animationProgress.value / 100) * animationDuration
     177              : )
     178              : 
     179            2 : function formatSpeed(speed: number) {
     180            2 :   return `${speed}x`
     181              : }
     182              : 
     183            0 : function setSpeed(speed: number) {
     184            0 :   selectedSpeed.value = speed
     185            0 :   speedOpen.value = false
     186              : }
     187              : 
     188            1 : function setClip(index: number) {
     189            1 :   selectedAnimation.value = index
     190            1 :   clipOpen.value = false
     191              : }
     192              : 
     193            0 : function handleSliderChange(value: number[] | undefined) {
     194            0 :   if (!value) return
     195            0 :   const progress = value[0]
     196            0 :   animationProgress.value = progress
     197            0 :   emit('seek', progress)
     198              : }
     199              : </script>
        

Generated by: LCOV version 2.0-1