PageNavigation.vue 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useRouter } from 'vue-router'
  4. import CommonSectionCollapse from '#desktop/components/CommonSectionCollapse/CommonSectionCollapse.vue'
  5. import { sortedFirstLevelRoutes } from '#desktop/components/PageNavigation/firstLevelRoutes.ts'
  6. import CommonButton from '../CommonButton/CommonButton.vue'
  7. interface Props {
  8. collapsed?: boolean
  9. }
  10. //*
  11. // IMPORTANT: This is just a temporary implementations please replace and adapt it later
  12. // *//
  13. defineProps<Props>()
  14. const router = useRouter()
  15. </script>
  16. <template>
  17. <div class="py-2 pt-14">
  18. <CommonSectionCollapse
  19. id="page-navigation"
  20. :title="__('Navigation')"
  21. :no-header="collapsed"
  22. >
  23. <template #default="{ headerId }">
  24. <nav :aria-labelledby="headerId">
  25. <ul>
  26. <li
  27. v-for="route in sortedFirstLevelRoutes"
  28. :key="route.path"
  29. class="flex justify-center"
  30. >
  31. <CommonButton
  32. v-if="collapsed"
  33. class="text-neutral-400 hover:outline-blue-900"
  34. :class="{
  35. '!bg-blue-800 !text-white':
  36. router.currentRoute.value.path === route.path,
  37. }"
  38. size="medium"
  39. variant="neutral"
  40. :icon="route.meta.icon"
  41. @click="router.push(route.path)"
  42. />
  43. <CommonLink
  44. v-else
  45. class="flex grow gap-2 rounded-md px-2 py-3 text-neutral-400 hover:bg-blue-900 hover:text-white hover:no-underline"
  46. :link="route.path"
  47. exact-active-class="!bg-blue-800 w-full !text-white"
  48. internal
  49. >
  50. <CommonLabel
  51. class="gap-2 text-current"
  52. :prefix-icon="route.meta.icon"
  53. >
  54. {{ $t(route.meta.title) }}
  55. </CommonLabel>
  56. </CommonLink>
  57. </li>
  58. </ul>
  59. </nav>
  60. </template>
  61. </CommonSectionCollapse>
  62. </div>
  63. </template>