CommonPopoverMenuItem.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import type { ObjectLike } from '#shared/types/utils.ts'
  5. import type { Variant } from '#desktop/components/CommonPopover/types.ts'
  6. export interface Props {
  7. label?: string
  8. ariaLabel?: string | ((entity?: ObjectLike) => string)
  9. labelPlaceholder?: string[]
  10. link?: string
  11. linkExternal?: boolean
  12. variant?: Variant
  13. icon?: string
  14. labelClass?: string
  15. }
  16. const props = defineProps<Props>()
  17. const variantClass = computed(() => {
  18. if (props.variant === 'secondary') return 'text-blue-800'
  19. if (props.variant === 'danger') return 'text-red-500'
  20. return 'group-focus-within:text-white group-hover:text-black group-hover:group-focus-within:text-white dark:group-hover:text-white'
  21. })
  22. const iconColor = computed(() => {
  23. if (props.variant === 'secondary') return 'text-blue-800'
  24. if (props.variant === 'danger') return 'text-red-500'
  25. return 'text-stone-200 dark:text-neutral-500 group-hover:text-black dark:group-hover:text-white group-focus-within:text-white group-hover:group-focus-within:text-white'
  26. })
  27. </script>
  28. <template>
  29. <component
  30. :is="link ? 'CommonLink' : 'button'"
  31. :link="link"
  32. :external="link && linkExternal"
  33. class="block cursor-pointer leading-snug hover:no-underline focus-visible:!outline-none"
  34. data-test-id="popover-menu-item"
  35. >
  36. <CommonLabel
  37. class="gap-2"
  38. :class="[labelClass, variantClass]"
  39. :prefix-icon="icon"
  40. :icon-color="iconColor"
  41. >
  42. <slot>{{ i18n.t(label, ...(labelPlaceholder || [])) }}</slot>
  43. </CommonLabel>
  44. </component>
  45. </template>