Skip to content

Commit 123a4da

Browse files
author
Hofstetter Benjamin
committed
detect subMenu active
1 parent 32ae6db commit 123a4da

File tree

8 files changed

+57
-260
lines changed

8 files changed

+57
-260
lines changed

opendata.swiss/ui/app/components/OdsDesktopNavigationPanel.vue

Lines changed: 0 additions & 208 deletions
This file was deleted.

opendata.swiss/ui/app/components/OdsDropdownMenu.vue

Lines changed: 31 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<script setup lang="ts">
22
import { ref, onMounted, onBeforeUnmount, type PropType } from 'vue';
3+
import { useI18n } from 'vue-i18n';
4+
35
import OdsButton from './OdsButton.vue';
46
import SvgIcon from './SvgIcon.vue';
57
import type { OdsNavTabItem } from './headers/model/ods-nav-tab-item';
@@ -13,45 +15,36 @@ const props = defineProps({
1315
type: Object as PropType<OdsNavTabItem>,
1416
required: true
1517
},
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: ''
2322
},
24-
t: {
25-
type: Function,
26-
required: true
27-
},
28-
onTabClick: {
29-
type: Function,
30-
required: true
31-
}
23+
3224
});
3325
34-
const isOpen = ref(false);
26+
const { t } = useI18n()
27+
const isOpen = ref(false)
3528
36-
const dropdownRef = ref<HTMLElement | null>(null);
29+
const dropdownRef = ref<HTMLElement | null>(null)
3730
3831
function toggleDropdown() {
3932
isOpen.value = !isOpen.value;
4033
}
4134
4235
43-
const parentLabelStack = ref<string[]>([props.menu.label]);
36+
const parentLabelStack = ref<string[]>([props.menu.label])
4437
4538
const menuStack = ref<OdsNavTabItem[][]>([]);
4639
47-
const menuKey = computed(() => menuStack.value.length);
40+
const menuKey = computed(() => menuStack.value.length)
4841
4942
const currentMenu = computed(() => {
5043
5144
if (menuStack.value.length === 0) {
5245
return props.menu.subMenu ?? []
53-
};
54-
return menuStack.value[menuStack.value.length - 1];
46+
}
47+
return menuStack.value[menuStack.value.length - 1]
5548
});
5649
5750
const direction = ref<'forward' | 'backward'>('forward');
@@ -95,23 +88,14 @@ onBeforeUnmount(() => {
9588
</script>
9689

9790
<template>
91+
<a href="#" :class="props.class" @click.prevent="toggleDropdown">
92+
<span class="activate-btn">{{ t(props.label) }}</span>
93+
</a>
9894
<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>
10395
<div v-if="isOpen" id="desktop-menu__drawer" class="desktop-menu__drawer ods-drop-down-panel" >
10496
<div class="close-button-container">
10597
<SvgIcon v-if="menuStack.length > 0" icon="ArrowLeft" size="lg" @click.prevent="goBack"/>
106-
10798
<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>-->
11599
<OdsButton
116100
icon="Cancel"
117101
title="close menu"
@@ -121,7 +105,7 @@ onBeforeUnmount(() => {
121105
class="ods-close"
122106
@click="isOpen = false"
123107
>
124-
<span class="ods-close">Schliessen</span>
108+
<span class="ods-close">{{t('message.header.navigation.close')}}</span>
125109
</OdsButton>
126110
</div>
127111
<Transition :name="transitionName" mode="out-in">
@@ -160,14 +144,20 @@ onBeforeUnmount(() => {
160144

161145
<style lang="scss" scoped>
162146
147+
.activate-btn {
148+
color: var(--color-primary-600);
149+
}
150+
163151
.close-button-container {
164152
display: flex;
165153
justify-content: space-between;
166154
}
155+
167156
.ods-close {
168157
white-space: nowrap;
169158
color: rgb(107 114 128 / var(--tw-text-opacity, 1));
170159
}
160+
171161
.ods-hover:hover {
172162
background-color: var(--color-secondary-50);
173163
color: rgb(75 85 99 / var(--tw-text-opacity, 1));
@@ -184,19 +174,23 @@ onBeforeUnmount(() => {
184174
padding-top: 24px;
185175
z-index: 100;
186176
}
177+
187178
.ods-dropdown {
188179
position: relative;
189180
display: inline-block;
190181
}
182+
191183
.ods-dropdown > a {
192184
cursor: pointer;
193185
display: flex;
194186
align-items: center;
195187
}
188+
196189
.ods-dropdown__arrow {
197190
margin-left: 0.5em;
198191
font-size: 0.8em;
199192
}
193+
200194
.ods-dropdown__menu {
201195
position: absolute;
202196
top: 100%;
@@ -208,22 +202,22 @@ onBeforeUnmount(() => {
208202
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
209203
padding: 0.5em 0;
210204
}
205+
211206
.ods-dropdown__menu li {
212207
list-style: none;
213208
}
209+
214210
.ods-dropdown__menu a {
215211
display: block;
216212
padding: 0.5em 1em;
217213
color: inherit;
218214
text-decoration: none;
219215
}
216+
220217
.ods-dropdown__menu a:hover {
221218
background: #f5f5f5;
222219
}
223220
224-
.holly {
225-
margin-top: -40px;
226-
}
227221
// list styles
228222
.navy {
229223
position: unset !important;

0 commit comments

Comments
 (0)