CommonSectionMenuLink.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!-- Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed, type HTMLAttributes } from 'vue'
  4. import { type Props as IconProps } from '@shared/components/CommonIcon/CommonIcon.vue'
  5. import useLocaleStore from '@shared/stores/locale'
  6. export interface Props {
  7. title?: string
  8. link?: string
  9. icon?: string | (IconProps & HTMLAttributes)
  10. iconBg?: string
  11. // TODO maybe change the name based on the usage
  12. information?: string
  13. }
  14. const props = defineProps<Props>()
  15. const locale = useLocaleStore()
  16. const iconProps = computed<IconProps | null>(() => {
  17. if (!props.icon) return null
  18. if (typeof props.icon === 'string') {
  19. return { name: props.icon }
  20. }
  21. return props.icon
  22. })
  23. </script>
  24. <template>
  25. <component
  26. :is="link ? 'CommonLink' : 'div'"
  27. :link="link"
  28. class="cursor-pointer border-b border-gray-300 last:border-0"
  29. data-test-id="section-menu-link"
  30. >
  31. <div
  32. data-test-id="section-menu-item"
  33. class="flex items-center justify-between border-b border-gray-300 last:border-0"
  34. >
  35. <div class="flex min-h-[54px] items-center">
  36. <div
  37. v-if="iconProps"
  38. class="flex h-8 w-8 items-center justify-center ltr:mr-2 rtl:ml-2"
  39. data-test-id="wrapper-icon"
  40. :class="{
  41. [`rounded-lg ${iconBg}`]: iconBg,
  42. }"
  43. >
  44. <CommonIcon v-bind="iconProps" />
  45. </div>
  46. <slot>{{ i18n.t(title) }}</slot>
  47. </div>
  48. <div class="mr-1 flex items-center">
  49. <slot name="right">{{ i18n.t(information) }}</slot>
  50. <CommonIcon
  51. class="text-gray-300 ltr:ml-2 rtl:mr-2"
  52. :name="`arrow-${locale.localeData?.dir === 'rtl' ? 'left' : 'right'}`"
  53. :fixed-size="{ width: 12, height: 12 }"
  54. />
  55. </div>
  56. </div>
  57. </component>
  58. </template>