Line data Source code
1 16 : <template>
2 : <span
3 2429 : v-if="keybindings.length > 0"
4 : class="@container/keybindings flex w-full min-w-0 items-center gap-1 overflow-hidden"
5 : data-testid="keybinding-list"
6 : >
7 : <KeyComboDisplay
8 : :key-combo="keybindings[0].combo"
9 : :is-modified="isModified"
10 : />
11 : <template v-if="keybindings.length >= 2">
12 : <span
13 : class="hidden text-muted-foreground @[16rem]/keybindings:inline"
14 : aria-hidden="true"
15 : >
16 : ,
17 : </span>
18 : <KeyComboDisplay
19 : class="hidden @[16rem]/keybindings:inline-flex"
20 : :key-combo="keybindings[1].combo"
21 : :is-modified="isModified"
22 : />
23 : </template>
24 : <span
25 : v-if="keybindings.length > 2"
26 : class="hidden rounded-sm px-1.5 py-0.5 text-xs text-muted-foreground @[16rem]/keybindings:inline"
27 : data-testid="keybinding-list-more-wide"
28 : >
29 : {{ $t('g.nMoreKeybindings', { count: keybindings.length - 2 }) }}
30 : </span>
31 : <span
32 : v-if="keybindings.length >= 2"
33 : class="hidden rounded-sm px-1.5 py-0.5 text-xs text-muted-foreground @[12rem]/keybindings:inline @[16rem]/keybindings:hidden"
34 : data-testid="keybinding-list-more-medium"
35 : >
36 : {{ $t('g.nMoreKeybindings', { count: keybindings.length - 1 }) }}
37 : </span>
38 : <span
39 : v-if="keybindings.length >= 2"
40 : class="hidden rounded-sm px-1.5 py-0.5 text-xs text-muted-foreground @[8rem]/keybindings:inline @[12rem]/keybindings:hidden"
41 : data-testid="keybinding-list-more-compact"
42 : >
43 : {{ $t('g.nMoreKeybindingsCompact', { count: keybindings.length - 1 }) }}
44 : </span>
45 : <span class="sr-only" data-testid="keybinding-list-aria">
46 : {{ ariaLabel }}
47 : </span>
48 : </span>
49 : <span v-else>-</span>
50 : </template>
51 :
52 : <script setup lang="ts">
53 : import { computed } from 'vue'
54 : import { useI18n } from 'vue-i18n'
55 :
56 : import type { KeybindingImpl } from '@comfyorg/keybindings/keybinding'
57 :
58 : import KeyComboDisplay from './KeyComboDisplay.vue'
59 :
60 : const { keybindings, isModified = false } = defineProps<{
61 : keybindings: KeybindingImpl[]
62 : isModified?: boolean
63 : }>()
64 :
65 2012 : const { t } = useI18n()
66 :
67 2012 : const ariaLabel = computed(() => {
68 930 : if (keybindings.length === 0) return ''
69 930 : const combos = keybindings
70 : .map((binding) => binding.combo.toString())
71 : .join(', ')
72 930 : return t('g.keybindingListAriaLabel', { combos })
73 : })
74 : </script>
|