PageNavigation.vue 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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">
  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="flex-shrink-0 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="large"
  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-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>