LayoutBottomNavigation.vue 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { storeToRefs } from 'pinia'
  4. import { computed } from 'vue'
  5. import CommonUserAvatar from '#shared/components/CommonUserAvatar/CommonUserAvatar.vue'
  6. import { useOnlineNotificationCount } from '#shared/entities/online-notification/composables/useOnlineNotificationCount.ts'
  7. import { useSessionStore } from '#shared/stores/session.ts'
  8. import { useCustomLayout } from './useCustomLayout.ts'
  9. const { user } = storeToRefs(useSessionStore())
  10. const { isCustomLayout } = useCustomLayout()
  11. const { unseenCount } = useOnlineNotificationCount()
  12. const notificationCount = computed(() => {
  13. if (!unseenCount.value) return ''
  14. if (unseenCount.value > 99) return '99+'
  15. return unseenCount.value.toString()
  16. })
  17. </script>
  18. <template>
  19. <footer
  20. class="bottom-navigation bg-gray-light fixed bottom-0 z-10 w-full backdrop-blur-lg"
  21. :class="{ 'px-4': isCustomLayout }"
  22. data-bottom-navigation
  23. >
  24. <div
  25. v-if="!isCustomLayout"
  26. class="flex h-14 w-full items-center text-center"
  27. >
  28. <CommonLink
  29. link="/"
  30. class="flex flex-1 justify-center"
  31. exact-active-class="text-blue"
  32. >
  33. <CommonIcon name="home" />
  34. </CommonLink>
  35. <CommonLink
  36. link="/notifications"
  37. exact-active-class="text-blue"
  38. class="relative flex flex-1 justify-center"
  39. >
  40. <div
  41. v-if="notificationCount"
  42. role="status"
  43. :aria-label="$t('Unread notifications')"
  44. class="bg-blue absolute h-4 min-w-[1rem] rounded-full px-1 text-center text-xs text-black ltr:ml-4 rtl:mr-4"
  45. >
  46. {{ notificationCount }}
  47. </div>
  48. <CommonIcon name="notification-subscribed" decorative />
  49. </CommonLink>
  50. <CommonLink
  51. link="/account"
  52. class="group flex-1"
  53. exact-active-class="user-active"
  54. >
  55. <CommonUserAvatar
  56. v-if="user"
  57. :entity="user"
  58. class="group-[.user-active]:ring-blue group-[.user-active]:ring-2"
  59. size="small"
  60. personal
  61. />
  62. </CommonLink>
  63. </div>
  64. </footer>
  65. </template>
  66. <style scoped>
  67. .bottom-navigation {
  68. padding-bottom: env(safe-area-inset-bottom);
  69. }
  70. </style>