|
1 | 1 | <template>
|
2 | 2 | <div class="relative">
|
3 |
| - <div |
4 |
| - v-if="!firstRender" |
5 |
| - class="fixed top-0 left-0 h-[580px] w-screen mt-4 z-0 bg-white animate__animated" |
6 |
| - :class="{ |
7 |
| - animate__fadeInLeft: expandedMenu, |
8 |
| - animate__fadeOutRight: !expandedMenu && !firstRender, |
9 |
| - }" |
| 3 | + <Transition |
| 4 | + enter-active-class="animate__animated animate__fadeInLeft" |
| 5 | + leave-active-class="animate__animated animate__fadeOutRight" |
10 | 6 | >
|
11 |
| - <ul> |
12 |
| - <li class="text-xl linkStyle"> |
13 |
| - <NuxtLink to="/" @click="displayMobileMenu"> Home </NuxtLink> |
14 |
| - </li> |
15 |
| - <li class="text-xl linkStyle"> |
16 |
| - <NuxtLink to="/products" @click="displayMobileMenu"> |
17 |
| - Products |
18 |
| - </NuxtLink> |
19 |
| - </li> |
20 |
| - <li class="text-xl linkStyle"> |
21 |
| - <NuxtLink to="/categories" @click="displayMobileMenu"> |
22 |
| - Categories |
23 |
| - </NuxtLink> |
24 |
| - </li> |
25 |
| - <li class="text-xl linkStyle"> |
26 |
| - <NuxtLink to="/search" @click="displayMobileMenu"> Search </NuxtLink> |
27 |
| - </li> |
28 |
| - </ul> |
29 |
| - </div> |
| 7 | + <div |
| 8 | + v-if="expandedMenu" |
| 9 | + ref="mobileMenu" |
| 10 | + class="fixed left-0 w-screen z-10 bg-white overflow-y-auto mobile-menu" |
| 11 | + > |
| 12 | + <ul> |
| 13 | + <li class="text-xl linkStyle"> |
| 14 | + <NuxtLink to="/" @click="displayMobileMenu"> Home </NuxtLink> |
| 15 | + </li> |
| 16 | + <li class="text-xl linkStyle"> |
| 17 | + <NuxtLink to="/products" @click="displayMobileMenu"> |
| 18 | + Products |
| 19 | + </NuxtLink> |
| 20 | + </li> |
| 21 | + <li class="text-xl linkStyle"> |
| 22 | + <NuxtLink to="/categories" @click="displayMobileMenu"> |
| 23 | + Categories |
| 24 | + </NuxtLink> |
| 25 | + </li> |
| 26 | + <li class="text-xl linkStyle"> |
| 27 | + <NuxtLink to="/search" @click="displayMobileMenu"> Search </NuxtLink> |
| 28 | + </li> |
| 29 | + </ul> |
| 30 | + </div> |
| 31 | + </Transition> |
30 | 32 | <div class="w-5/12 lg:hidden" />
|
31 | 33 | <div class="flex flex-row w-2/12 px-2 my-2 lg:hidden">
|
32 | 34 | <div class="self-center block w-full mr-4">
|
|
48 | 50 | </template>
|
49 | 51 |
|
50 | 52 | <script setup>
|
| 53 | +import { ref } from 'vue' |
| 54 | +
|
51 | 55 | const expandedMenu = useState("expandedMenu", () => false);
|
52 |
| -const firstRender = useState("firstRender", () => true); |
| 56 | +const mobileMenu = ref(null); |
53 | 57 |
|
54 | 58 | const displayMobileMenu = () => {
|
55 | 59 | expandedMenu.value = !expandedMenu.value;
|
56 |
| - firstRender.value = false; |
57 | 60 | };
|
58 | 61 | </script>
|
59 | 62 |
|
60 | 63 | <style scoped>
|
| 64 | +/* Mobile menu positioning */ |
| 65 | +.mobile-menu { |
| 66 | + top: 0; |
| 67 | + bottom: 80px; /* Adjust this value to match your footer height */ |
| 68 | + max-height: calc(100vh - 80px); /* Adjust this value to match your footer height */ |
| 69 | +} |
| 70 | +
|
61 | 71 | /* Style for mobile menu links */
|
62 | 72 | .linkStyle {
|
63 | 73 | @apply w-auto p-4 m-4 font-bold text-center border border-gray-300 border-opacity-50 shadow-md rounded;
|
|
0 commit comments