Skip to content

Commit af8d38d

Browse files
authored
Merge pull request #27 from jdev-org/mobile
Use configuration file for mobile view as well
2 parents 381da58 + e3726f6 commit af8d38d

File tree

2 files changed

+87
-6
lines changed

2 files changed

+87
-6
lines changed

public/sample-config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"logoUrl": "/public/logo-mel.jpg",
55
"hideLogin": false,
66
"iconsUrl": "https://cdn.jsdelivr.net/gh/iconoir-icons/iconoir@main/css/iconoir.css",
7-
"lang": "es"
7+
"lang": "fr"
88
},
99
"menu": [
1010
{

src/header.ce.vue

+86-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const state = reactive({
2929
loaded: false,
3030
matchedRouteScore: 0,
3131
activeAppUrl: '' as string | undefined,
32+
activeDropdown: null as null | number,
3233
})
3334
3435
const isAnonymous = computed(() => !state.user || state.user.anonymous)
@@ -120,6 +121,10 @@ function setI18nAndActiveApp(i18n?: any) {
120121
state.loaded = true
121122
}
122123
124+
function toggleDropdown(index: number) {
125+
state.activeDropdown = state.activeDropdown === index ? null : index
126+
}
127+
123128
onMounted(() => {
124129
getUserDetails().then(user => {
125130
state.user = user
@@ -254,7 +259,9 @@ onMounted(() => {
254259
>
255260
<li
256261
v-if="checkCondition(subitem)"
257-
@click="state.activeAppUrl = (item as Link).activeAppUrl"
262+
@click="
263+
state.activeAppUrl = (subitem as Link).activeAppUrl
264+
"
258265
:class="{
259266
active: (subitem as Link).activeAppUrl == state.activeAppUrl,
260267
}"
@@ -376,10 +383,82 @@ onMounted(() => {
376383
class="absolute z-[1000] bg-white w-full duration-300 transition-opacity ease-in-out"
377384
>
378385
<nav class="flex flex-col font-semibold" v-if="state.mobileMenuOpen">
379-
<a class="nav-item-mobile" href="/datahub/">{{ t('catalogue') }}</a>
380-
<a class="nav-item-mobile" href="/mapstore/">{{ t('viewer') }}</a>
381-
<a class="nav-item-mobile" href="/mapstore/#/home">{{ t('maps') }}</a>
382-
<a class="nav-item-mobile" href="/geoserver/">{{ t('services') }}</a>
386+
<template v-for="(item, index) in state.menu" :key="index">
387+
<template v-if="!item.type && checkCondition(item)">
388+
<a
389+
:href="(item as Link).url"
390+
class="nav-item-mobile"
391+
@click="state.activeAppUrl = (item as Link).activeAppUrl"
392+
:class="{
393+
active: (item as Link).activeAppUrl == state.activeAppUrl,
394+
}"
395+
>
396+
<div class="flex items-center">
397+
<span class="ml-1 first-letter:capitalize">
398+
{{
399+
(item as Link).i18n
400+
? t((item as Link).i18n)
401+
: (item as Link).label
402+
}}
403+
</span>
404+
</div>
405+
</a>
406+
</template>
407+
<template
408+
v-else-if="item.type === 'dropdown' && checkCondition(item)"
409+
>
410+
<div class="group inline-block relative">
411+
<button
412+
class="nav-item-mobile after:hover:scale-x-0 flex items-center"
413+
@click="toggleDropdown(index)"
414+
>
415+
<span class="lg:mr-2 md:mr-1 first-letter:capitalize">{{
416+
(item as Dropdown).i18n
417+
? t((item as Dropdown).i18n)
418+
: (item as Dropdown).label
419+
}}</span>
420+
<ChevronDownIcon
421+
class="w-4 h-4"
422+
stroke-width="4"
423+
></ChevronDownIcon>
424+
</button>
425+
<ul
426+
class="absolute border rounded w-full admin-dropdown z-[1002] bg-white"
427+
v-show="state.activeDropdown === index"
428+
>
429+
<template
430+
v-for="(subitem, subindex) in (item as Dropdown).items"
431+
:key="subindex"
432+
>
433+
<li
434+
v-if="checkCondition(subitem)"
435+
@click="
436+
state.activeAppUrl = (subitem as Link).activeAppUrl
437+
"
438+
:class="{
439+
active: (subitem as Link).activeAppUrl == state.activeAppUrl,
440+
}"
441+
>
442+
<a
443+
:href="replaceUrlsVariables(subitem.url)"
444+
class="capitalize !flex justify-center items-center"
445+
>
446+
<i
447+
v-if="subitem.icon"
448+
:class="subitem.icon"
449+
class="pr-1 block pb-[2px] subitem-icon"
450+
style="font-size: 1rem"
451+
></i>
452+
<span class="block">{{
453+
subitem.i18n ? t(subitem.i18n) : subitem.label
454+
}}</span>
455+
</a>
456+
</li>
457+
</template>
458+
</ul>
459+
</div>
460+
</template>
461+
</template>
383462
<a v-if="!isAnonymous" class="nav-item-mobile" href="/import/">{{
384463
t('datafeeder')
385464
}}</a>
@@ -405,6 +484,8 @@ onMounted(() => {
405484
@layer components {
406485
.nav-item-mobile {
407486
@apply text-xl block text-center py-3 w-full border-b border-b-slate-300 first-letter:capitalize;
487+
display: flex;
488+
justify-content: center;
408489
}
409490
410491
.nav-item {

0 commit comments

Comments
 (0)