PageNavigation.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <!-- Copyright (C) 2012-2025 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">
  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 class="m-0 flex basis-full flex-col gap-1 p-0">
  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="flex-shrink-0 text-neutral-400 hover:outline-blue-900"
  34. size="large"
  35. variant="neutral"
  36. :icon="route.meta.icon"
  37. @click="router.push(route.path.replace(/:\w+/, ''))"
  38. />
  39. <CommonLink
  40. v-else
  41. class="flex grow gap-2 rounded-md px-2 py-3 text-neutral-400 hover:bg-blue-900 hover:text-white hover:no-underline"
  42. :class="{
  43. '!bg-blue-800 !text-white':
  44. router.currentRoute.value.name === route.name, // $route.name is not detected by ts
  45. }"
  46. :link="route.path.replace(/\/:\w+/, '')"
  47. exact-active-class="!bg-blue-800 w-full !text-white"
  48. internal
  49. >
  50. <CommonLabel
  51. class="gap-2 !text-sm text-current"
  52. size="large"
  53. :prefix-icon="route.meta.icon"
  54. >
  55. {{ $t(route.meta.title) }}
  56. </CommonLabel>
  57. </CommonLink>
  58. </li>
  59. </ul>
  60. </nav>
  61. </template>
  62. </CommonSectionCollapse>
  63. </div>
  64. </template>