-
Notifications
You must be signed in to change notification settings - Fork 7
/
slds-global-navigation-overflowed-sub-tabs.vue
132 lines (105 loc) · 3.69 KB
/
slds-global-navigation-overflowed-sub-tabs.vue
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
<li
class="slds-sub-tabs__item slds-tabs_default__overflow-button slds-context-bar__dropdown-trigger slds-dropdown-trigger slds-dropdown-trigger_click slds-is-open"
>
<!-- Identification -->
<a
role="tab"
:title="`More (${overflowedSubTabs.length})`"
class="slds-context-bar__label-action"
@click="toggleDropdown"
>
<!-- Indicator -->
<span class="slds-indicator-container"/>
<!-- Text -->
<span class="slds-truncate">
{{ `More (${overflowedSubTabs.length})` }}
</span>
</a>
<!-- Dropdown menu -->
<div class="slds-context-bar__icon-action slds-p-left_none slds-p-right_x-small">
<svg class="slds-button__icon slds-button__icon_small slds-button__icon_right">
<slds-svg icon="utility:chevrondown"/>
</svg>
</div>
<!-- More tabs dropdown -->
<transition name="dropdown">
<div v-if="isDropdownActive" v-click-outside="away" class="slds-dropdown slds-dropdown_right">
<ul class="slds-dropdown__list" role="menu">
<li
v-for="(subTab, index) in overflowedSubTabs"
:key="index"
class="slds-dropdown__item"
@click="handleClick(subTab)"
>
<a role="menuitem" tabindex="-1">
<span class="slds-truncate" :title="subTab.label">
<span class="slds-indicator-container"/>
<span class="slds-icon_container">
<slds-svg
:icon="subTab.iconName"
standard-format
class="slds-icon slds-icon_small slds-icon-text-default"
/>
</span>
<span>
{{ subTab.label }}
</span>
</span>
</a>
</li>
</ul>
</div>
</transition>
</li>
</template>
<script lang="ts">
import SldsSvg from "../slds-svg/slds-svg.vue"
import { vOnClickOutside } from "@vueuse/components"
import { defineComponent, type PropType } from "vue"
import { type GlobalNavigationSubTab } from "./global-navigation-sub-tab"
import { EVENTS } from "../../constants"
export default defineComponent({
name: "SldsGlobalNavigationOverflowedSubTabs",
components: { SldsSvg },
directives: {
ClickOutside: vOnClickOutside,
},
props: {
overflowedSubTabs: { type: Array as PropType<GlobalNavigationSubTab[]>, required: true },
},
data() {
return {
isDropdownActive: false,
}
},
methods: {
away() {
this.isDropdownActive = false
},
handleClick(subTab: GlobalNavigationSubTab) {
this.isDropdownActive = false
this.$emit(EVENTS.CLICK, subTab)
},
toggleDropdown() {
this.isDropdownActive = !this.isDropdownActive
},
},
})
</script>
<style scoped lang="scss">
.slds-sub-tabs__item {
width: 7.5rem;
max-width: 7.5rem;
background: white;
}
.dropdown-enter,
.dropdown-leave-to {
opacity: 0 !important;
transform: translateY(5%) !important;
}
.dropdown-enter-active,
.dropdown-leave-active {
transition: transform .3s, opacity .15s !important;
}
</style>