CommonBreadcrumb.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { useLocaleStore } from '#shared/stores/locale.ts'
  4. import type { BreadcrumbItem } from './types.ts'
  5. defineProps<{
  6. items: BreadcrumbItem[]
  7. }>()
  8. const locale = useLocaleStore()
  9. // TODO: Missing handling when there is not enough space for the breadcrumb
  10. </script>
  11. <template>
  12. <nav :aria-label="$t('Breadcrumb navigation')" class="max-w-full">
  13. <ol class="flex">
  14. <li v-for="(item, idx) in items" :key="item.label">
  15. <CommonIcon
  16. v-if="item.icon"
  17. :name="item.icon"
  18. size="xs"
  19. class="ltr:mr-1 rtl:ml-1"
  20. />
  21. <CommonLink v-if="item.route" :link="item.route" internal>
  22. <CommonLabel size="large" class="hover:underline">{{
  23. $t(item.label)
  24. }}</CommonLabel>
  25. </CommonLink>
  26. <h1 v-else aria-current="page">
  27. {{ $t(item.label) }}
  28. </h1>
  29. <CommonIcon
  30. v-if="idx !== items.length - 1"
  31. :name="
  32. locale.localeData?.dir === 'rtl' ? 'chevron-left' : 'chevron-right'
  33. "
  34. size="xs"
  35. class="mx-1 inline-flex"
  36. />
  37. </li>
  38. </ol>
  39. </nav>
  40. </template>