1
1
<script setup lang="ts">
2
2
import { ref , onMounted , onBeforeUnmount , type PropType } from ' vue' ;
3
+ import { useI18n } from ' vue-i18n' ;
4
+
3
5
import OdsButton from ' ./OdsButton.vue' ;
4
6
import SvgIcon from ' ./SvgIcon.vue' ;
5
7
import type { OdsNavTabItem } from ' ./headers/model/ods-nav-tab-item' ;
@@ -13,45 +15,36 @@ const props = defineProps({
13
15
type: Object as PropType <OdsNavTabItem >,
14
16
required: true
15
17
},
16
- active: {
17
- type: Boolean ,
18
- required: true
19
- },
20
- index: {
21
- type: Number ,
22
- required: true
18
+ class: {
19
+ type: String ,
20
+ required: false ,
21
+ default: ' '
23
22
},
24
- t: {
25
- type: Function ,
26
- required: true
27
- },
28
- onTabClick: {
29
- type: Function ,
30
- required: true
31
- }
23
+
32
24
});
33
25
34
- const isOpen = ref (false );
26
+ const { t } = useI18n ()
27
+ const isOpen = ref (false )
35
28
36
- const dropdownRef = ref <HTMLElement | null >(null );
29
+ const dropdownRef = ref <HTMLElement | null >(null )
37
30
38
31
function toggleDropdown() {
39
32
isOpen .value = ! isOpen .value ;
40
33
}
41
34
42
35
43
- const parentLabelStack = ref <string []>([props .menu .label ]);
36
+ const parentLabelStack = ref <string []>([props .menu .label ])
44
37
45
38
const menuStack = ref <OdsNavTabItem [][]>([]);
46
39
47
- const menuKey = computed (() => menuStack .value .length );
40
+ const menuKey = computed (() => menuStack .value .length )
48
41
49
42
const currentMenu = computed (() => {
50
43
51
44
if (menuStack .value .length === 0 ) {
52
45
return props .menu .subMenu ?? []
53
- };
54
- return menuStack .value [menuStack .value .length - 1 ];
46
+ }
47
+ return menuStack .value [menuStack .value .length - 1 ]
55
48
});
56
49
57
50
const direction = ref <' forward' | ' backward' >(' forward' );
@@ -95,23 +88,14 @@ onBeforeUnmount(() => {
95
88
</script >
96
89
97
90
<template >
91
+ <a href =" #" :class =" props.class" @click.prevent =" toggleDropdown" >
92
+ <span class =" activate-btn" >{{ t(props.label) }}</span >
93
+ </a >
98
94
<div ref =" dropdownRef" class =" ods-dropdown" >
99
- <a href =" #" :class =" { active: props.active }" @click.prevent =" toggleDropdown" >
100
- <span >{{ props.t(props.label) }} bs</span >
101
- <span class =" ods-dropdown__arrow" >▼</span >
102
- </a >
103
95
<div v-if =" isOpen" id =" desktop-menu__drawer" class =" desktop-menu__drawer ods-drop-down-panel" >
104
96
<div class =" close-button-container" >
105
97
<SvgIcon v-if =" menuStack.length > 0" icon =" ArrowLeft" size =" lg" @click.prevent =" goBack" />
106
-
107
98
<div v-else />
108
- <!-- <li v-if="menuStack.length > 0" style="border-bottom: none;" @click="goBack">
109
- <a style="padding-top: 12px; padding-bottom: 12px;">
110
- <span>
111
- <SvgIcon icon="ArrowLeft" size="lg"/>
112
- </span>
113
- </a>
114
- </li>-->
115
99
<OdsButton
116
100
icon =" Cancel"
117
101
title =" close menu"
@@ -121,7 +105,7 @@ onBeforeUnmount(() => {
121
105
class =" ods-close"
122
106
@click =" isOpen = false"
123
107
>
124
- <span class =" ods-close" >Schliessen </span >
108
+ <span class =" ods-close" >{{t('message.header.navigation.close')}} </span >
125
109
</OdsButton >
126
110
</div >
127
111
<Transition :name =" transitionName" mode =" out-in" >
@@ -160,14 +144,20 @@ onBeforeUnmount(() => {
160
144
161
145
<style lang="scss" scoped>
162
146
147
+ .activate-btn {
148
+ color : var (--color-primary-600 );
149
+ }
150
+
163
151
.close-button-container {
164
152
display : flex ;
165
153
justify-content : space-between ;
166
154
}
155
+
167
156
.ods-close {
168
157
white-space : nowrap ;
169
158
color : rgb (107 114 128 / var (--tw-text-opacity , 1 ));
170
159
}
160
+
171
161
.ods-hover :hover {
172
162
background-color : var (--color-secondary-50 );
173
163
color : rgb (75 85 99 / var (--tw-text-opacity , 1 ));
@@ -184,19 +174,23 @@ onBeforeUnmount(() => {
184
174
padding-top : 24px ;
185
175
z-index : 100 ;
186
176
}
177
+
187
178
.ods-dropdown {
188
179
position : relative ;
189
180
display : inline-block ;
190
181
}
182
+
191
183
.ods-dropdown > a {
192
184
cursor : pointer ;
193
185
display : flex ;
194
186
align-items : center ;
195
187
}
188
+
196
189
.ods-dropdown__arrow {
197
190
margin-left : 0.5em ;
198
191
font-size : 0.8em ;
199
192
}
193
+
200
194
.ods-dropdown__menu {
201
195
position : absolute ;
202
196
top : 100% ;
@@ -208,22 +202,22 @@ onBeforeUnmount(() => {
208
202
box-shadow : 0 2px 8px rgba (0 ,0 ,0 ,0.1 );
209
203
padding : 0.5em 0 ;
210
204
}
205
+
211
206
.ods-dropdown__menu li {
212
207
list-style : none ;
213
208
}
209
+
214
210
.ods-dropdown__menu a {
215
211
display : block ;
216
212
padding : 0.5em 1em ;
217
213
color : inherit ;
218
214
text-decoration : none ;
219
215
}
216
+
220
217
.ods-dropdown__menu a :hover {
221
218
background : #f5f5f5 ;
222
219
}
223
220
224
- .holly {
225
- margin-top : -40px ;
226
- }
227
221
// list styles
228
222
.navy {
229
223
position : unset !important ;
0 commit comments