NavBar.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <template>
  2. <nav class="relative w-full h-20 flex items-end animate__animated animate__fadeInUp animate__faster">
  3. <div class="w-full rounded-t-xl bg-stone-800 h-14" />
  4. <div
  5. class="top-0 left-0 absolute w-full h-full grid grid-cols-3 grid-rows-1 items-end"
  6. >
  7. <NuxtLink
  8. v-for="(item, idx) in items"
  9. :key="idx"
  10. :to="item.link"
  11. class="h-full flex justify-center items-end text-center"
  12. >
  13. <div
  14. @click="selectedIdx = idx"
  15. class="flex flex-col items-center justify-center bg-stone-800 px-4 cursor-pointer duration-300"
  16. :class="{
  17. 'h-20 rounded-t-full': idx === selectedIdx,
  18. 'h-14': idx !== selectedIdx,
  19. }"
  20. >
  21. <Icon :name="item.icon" class="w-10 h-10 duration-300" />
  22. <p :class="selectedIdx === idx ? 'opacity-100 mt-1 text-sm' : 'opacity-0 text-[0px] mt-0'" class="duration-300" v-text="item.name" />
  23. </div>
  24. </NuxtLink>
  25. </div>
  26. </nav>
  27. </template>
  28. <script setup lang="ts">
  29. const items = ref([
  30. {
  31. name: "Новости",
  32. icon: "hugeicons:news",
  33. link: "/news"
  34. },
  35. {
  36. name: "Расписание",
  37. icon: "mdi:timetable",
  38. link: "/timetable"
  39. },
  40. {
  41. name: "Профиль",
  42. icon: "ph:student-bold",
  43. link: "/profile"
  44. },
  45. ]);
  46. const route = useRoute();
  47. const selectedIdx = ref(null);
  48. watch(() => route.fullPath, () => {
  49. selectedIdx.value = items.value.findIndex(el => el.link === route.fullPath)
  50. })
  51. </script>