Line data Source code
1 16 : <script setup lang="ts">
2 : import { useI18n } from 'vue-i18n'
3 :
4 : import type { ControlOptions } from '@/types/simplifiedWidget'
5 : import { cn } from '@comfyorg/tailwind-utils'
6 :
7 : const { mode } = defineProps<{
8 : mode: ControlOptions
9 : }>()
10 :
11 1335 : const { t } = useI18n()
12 :
13 1335 : const iconMap: Record<ControlOptions, string | null> = {
14 : fixed: 'icon-[lucide--pencil-off]',
15 : randomize: 'icon-[lucide--shuffle]',
16 : increment: null,
17 : decrement: null
18 : }
19 :
20 1335 : const textMap: Record<ControlOptions, string | null> = {
21 : increment: '+1',
22 : decrement: '-1',
23 : fixed: null,
24 : randomize: null
25 : }
26 1335 : </script>
27 :
28 : <template>
29 1341 : <button
30 : data-testid="value-control"
31 : type="button"
32 : :aria-label="t('widgets.valueControl.' + mode)"
33 : :class="
34 : cn(
35 : 'flex shrink-0 cursor-pointer items-center justify-center border-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:outline-none',
36 : 'h-5 w-9 rounded-full',
37 : mode !== 'fixed'
38 : ? 'bg-foreground/10 hover:bg-foreground/20'
39 : : 'bg-transparent'
40 : )
41 : "
42 : >
43 : <i
44 : v-if="iconMap[mode]"
45 : aria-hidden="true"
46 : :class="
47 : cn(
48 : iconMap[mode] ?? '',
49 : 'size-3.5',
50 : mode === 'fixed' ? 'text-muted-foreground' : 'text-foreground'
51 : )
52 : "
53 : />
54 : <span v-else-if="textMap[mode]" class="text-xs font-normal text-foreground">
55 : {{ textMap[mode] }}
56 : </span>
57 : </button>
58 : </template>
|