Line data Source code
1 13 : <template>
2 : <Button
3 55 : v-if="isRecording"
4 : variant="textonly"
5 : size="unset"
6 : :tooltip="t('load3d.menuBar.stopRecording')"
7 : :class="chipClass"
8 : type="button"
9 : :aria-label="t('load3d.menuBar.stopRecording')"
10 : @click="emit('stopRecording')"
11 : >
12 : <span class="size-2 animate-pulse rounded-full bg-destructive" />
13 : <span v-if="!compact">{{ t('load3d.menuBar.recording') }}</span>
14 : </Button>
15 :
16 : <div
17 : v-else-if="hasRecording"
18 : class="flex shrink-0 items-center gap-0.5 rounded-lg bg-muted py-0.5 pr-0.5 pl-1 text-sm text-foreground"
19 : >
20 : <PopoverRoot v-model:open="menuOpen">
21 : <PopoverTrigger as-child>
22 : <Button
23 : variant="textonly"
24 : size="unset"
25 : :tooltip="t('load3d.menuBar.videoRecordingTooltip')"
26 : class="gap-1.5 px-1 py-0.5"
27 : type="button"
28 : :aria-label="t('load3d.menuBar.videoRecordingTooltip')"
29 : data-testid="load3d-recording-duration"
30 : >
31 : <i class="icon-[lucide--film]" />
32 : {{ formatDuration(recordingDuration ?? 0) }}
33 : </Button>
34 : </PopoverTrigger>
35 : <PopoverContent align="start" :side-offset="8" :class="menuPanelClass">
36 : <button
37 : type="button"
38 : :class="menuButtonClass"
39 : @click="downloadRecording"
40 : >
41 : <i class="icon-[lucide--download]" />
42 : {{ t('load3d.menuBar.downloadRecording') }}
43 : </button>
44 : <button
45 : type="button"
46 : :class="menuButtonClass"
47 : @click="startNewRecording"
48 : >
49 : <i class="icon-[lucide--video]" />
50 : {{ t('load3d.menuBar.startNewRecording') }}
51 : </button>
52 : <button type="button" :class="menuButtonClass" @click="deleteRecording">
53 : <i class="icon-[lucide--trash-2]" />
54 : {{ t('load3d.menuBar.deleteRecording') }}
55 : </button>
56 : </PopoverContent>
57 : </PopoverRoot>
58 : <Button
59 : variant="textonly"
60 : size="unset"
61 : :tooltip="t('load3d.menuBar.deleteRecording')"
62 : class="size-6"
63 : type="button"
64 : :aria-label="t('load3d.menuBar.deleteRecording')"
65 : @click="emit('clearRecording')"
66 : >
67 : <i class="icon-[lucide--x] size-3.5" />
68 : </Button>
69 : </div>
70 :
71 : <Button
72 : v-else
73 : variant="textonly"
74 : size="unset"
75 : :tooltip="t('load3d.menuBar.record')"
76 : :class="chipClass"
77 : type="button"
78 : :aria-label="compact ? t('load3d.menuBar.record') : undefined"
79 : @click="emit('startRecording')"
80 : >
81 : <i class="icon-[lucide--video]" />
82 : <span v-if="!compact">{{ t('load3d.menuBar.record') }}</span>
83 : </Button>
84 : </template>
85 :
86 : <script setup lang="ts">
87 : import { PopoverRoot, PopoverTrigger } from 'reka-ui'
88 : import { useI18n } from 'vue-i18n'
89 :
90 : import {
91 : chipClass,
92 : menuPanelClass
93 : } from '@/extensions/core/load3d/components/menubar/menuBarStyles'
94 : import { usePopoverExclusivity } from '@/extensions/core/load3d/components/menubar/usePopoverExclusivity'
95 : import Button from '@comfyorg/design-system/button/Button'
96 : import PopoverContent from '@comfyorg/design-system/popover/PopoverContent'
97 : import { menuButtonClass } from '@comfyorg/design-system/lib/menu/menuStyles'
98 :
99 : const { compact = false } = defineProps<{
100 : compact?: boolean
101 : }>()
102 :
103 26 : const isRecording = defineModel<boolean>('isRecording')
104 26 : const hasRecording = defineModel<boolean>('hasRecording')
105 26 : const recordingDuration = defineModel<number>('recordingDuration')
106 :
107 26 : const emit = defineEmits<{
108 : (e: 'startRecording'): void
109 : (e: 'stopRecording'): void
110 : (e: 'exportRecording'): void
111 : (e: 'clearRecording'): void
112 : }>()
113 :
114 26 : const { t } = useI18n()
115 :
116 26 : const menuOpen = usePopoverExclusivity()('recording-menu')
117 :
118 0 : function downloadRecording() {
119 0 : menuOpen.value = false
120 0 : emit('exportRecording')
121 : }
122 :
123 0 : function startNewRecording() {
124 0 : menuOpen.value = false
125 0 : emit('startRecording')
126 : }
127 :
128 1 : function deleteRecording() {
129 1 : menuOpen.value = false
130 1 : emit('clearRecording')
131 : }
132 :
133 7 : function formatDuration(seconds: number) {
134 7 : const minutes = Math.floor(seconds / 60)
135 7 : const remainingSeconds = Math.floor(seconds % 60)
136 7 : return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`
137 : }
138 : </script>
|