CommonSectionMenu.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import type { MenuItem } from './types'
  4. import CommonSectionMenuLink from './CommonSectionMenuLink.vue'
  5. // TODO: Do not output anything, when no items are given via prop or slot?
  6. export interface Props {
  7. actionTitle?: string
  8. headerTitle?: string
  9. items?: MenuItem[]
  10. }
  11. defineProps<Props>()
  12. const emit = defineEmits<{
  13. (e: 'action-click', event: MouseEvent): void
  14. }>()
  15. const clickOnAction = (event: MouseEvent) => {
  16. emit('action-click', event)
  17. }
  18. </script>
  19. <template>
  20. <div class="mb-2 flex flex-row justify-between">
  21. <div class="text-white/80 ltr:pl-4 rtl:pr-4">
  22. <slot name="header">{{ i18n.t(headerTitle) }}</slot>
  23. </div>
  24. <div
  25. v-if="actionTitle"
  26. class="cursor-pointer text-blue ltr:pr-4 rtl:pl-4"
  27. @click="clickOnAction"
  28. >
  29. {{ i18n.t(actionTitle) }}
  30. </div>
  31. </div>
  32. <div
  33. class="w-fill mb-6 flex flex-col rounded-xl bg-gray-500 px-2 py-1 text-white"
  34. >
  35. <slot>
  36. <template v-for="(item, idx) in items" :key="idx">
  37. <CommonSectionMenuLink v-if="item.type === 'link'" v-bind="item" />
  38. </template>
  39. </slot>
  40. </div>
  41. </template>