|
|
@@ -12,14 +12,18 @@ Menu de navigation entre les sections d'une page, accrochée au haut de l'écran
|
|
|
density="compact"
|
|
|
:class="{ 'sticky-menu': isSticky }"
|
|
|
>
|
|
|
- <nuxt-link :to="{ path: '', hash: '#top' }" class="px-3 py-1">
|
|
|
+ <nuxt-link
|
|
|
+ v-if="isSticky"
|
|
|
+ :to="{ path: '', hash: '#top' }"
|
|
|
+ class="px-3 py-1"
|
|
|
+ >
|
|
|
<v-icon icon="fa fa-angle-up" />
|
|
|
</nuxt-link>
|
|
|
|
|
|
<div v-for="menu in menus" :key="menu.anchor">
|
|
|
<nuxt-link :to="{ path: '', hash: '#' + menu.anchor }">
|
|
|
<v-list-item
|
|
|
- :class="{ active : isSticky && layoutStore.isAnchoredSectionOnScreen[menu.anchor] }"
|
|
|
+ :class="{ active : isSticky && menu.anchor === activeMenuItem }"
|
|
|
>
|
|
|
{{ menu.label }}
|
|
|
</v-list-item>
|
|
|
@@ -36,7 +40,7 @@ import type { PropType } from "@vue/runtime-core";
|
|
|
import type { MenuScroll } from "~/types/interface";
|
|
|
import { useLayoutStore } from "~/stores/layoutStore";
|
|
|
|
|
|
-const props = defineProps({
|
|
|
+defineProps({
|
|
|
menus: {
|
|
|
type: Array as PropType<Array < MenuScroll >>,
|
|
|
required: true
|
|
|
@@ -47,6 +51,14 @@ const layoutStore = useLayoutStore()
|
|
|
|
|
|
const isSticky: Ref<boolean> = ref(false);
|
|
|
|
|
|
+const activeMenuItem: ComputedRef<string | null> = computed(() => {
|
|
|
+ return Object.entries(
|
|
|
+ layoutStore.isAnchoredSectionOnScreen
|
|
|
+ ).find(
|
|
|
+ ([key, value]) => value === true
|
|
|
+ )?.[0] ?? null
|
|
|
+})
|
|
|
+
|
|
|
const handleScroll = () => {
|
|
|
isSticky.value = window.scrollY > 800;
|
|
|
}
|