1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
<script>
import { GlDropdownItem } from '@gitlab/ui';
import { mapState, mapGetters } from 'vuex';
import { __, sprintf } from '~/locale';
export default {
name: 'HeaderSearchScopedItems',
components: {
GlDropdownItem,
},
props: {
currentFocusedOption: {
type: Object,
required: false,
default: () => null,
},
},
computed: {
...mapState(['search']),
...mapGetters(['scopedSearchOptions']),
},
methods: {
isOptionFocused(option) {
return this.currentFocusedOption?.html_id === option.html_id;
},
ariaLabel(option) {
return sprintf(__('%{search} %{description} %{scope}'), {
search: this.search,
description: option.description,
scope: option.scope || '',
});
},
},
};
</script>
<template>
<div>
<gl-dropdown-item
v-for="option in scopedSearchOptions"
:id="option.html_id"
:ref="option.html_id"
:key="option.html_id"
:class="{ 'gl-bg-gray-50': isOptionFocused(option) }"
:aria-selected="isOptionFocused(option)"
:aria-label="ariaLabel(option)"
tabindex="-1"
:href="option.url"
>
<span aria-hidden="true">
"<span class="gl-font-weight-bold">{{ search }}</span
>" {{ option.description }}
<span v-if="option.scope" class="gl-font-style-italic">{{ option.scope }}</span>
</span>
</gl-dropdown-item>
</div>
</template>
|