CommonTicketStateIndicator.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import { EnumTicketStateColorCode } from '#shared/graphql/types.ts'
  5. export interface Props {
  6. colorCode: EnumTicketStateColorCode
  7. label: string
  8. pill?: boolean
  9. }
  10. const props = withDefaults(defineProps<Props>(), {
  11. pill: false,
  12. })
  13. const textClass = computed(() => {
  14. switch (props.colorCode) {
  15. case EnumTicketStateColorCode.Closed:
  16. return 'text-green'
  17. case EnumTicketStateColorCode.Pending:
  18. return 'text-gray'
  19. case EnumTicketStateColorCode.Escalating:
  20. return 'text-red-bright'
  21. case EnumTicketStateColorCode.Open:
  22. default:
  23. return 'text-yellow'
  24. }
  25. })
  26. const backgroundClass = computed(() => {
  27. if (!props.pill) return
  28. switch (props.colorCode) {
  29. case EnumTicketStateColorCode.Closed:
  30. return 'bg-green-highlight'
  31. case EnumTicketStateColorCode.Pending:
  32. return 'bg-gray-highlight'
  33. case EnumTicketStateColorCode.Escalating:
  34. return 'bg-red-dark'
  35. case EnumTicketStateColorCode.Open:
  36. default:
  37. return 'bg-yellow-highlight'
  38. }
  39. })
  40. </script>
  41. <template>
  42. <div
  43. :class="[
  44. textClass,
  45. backgroundClass,
  46. {
  47. 'rounded py-1 ltr:pl-1 ltr:pr-1.5 rtl:pl-1.5 rtl:pr-1': pill,
  48. },
  49. ]"
  50. class="flex select-none items-center"
  51. role="group"
  52. >
  53. <CommonIcon
  54. :size="pill ? 'tiny' : 'base'"
  55. :label="$t('(state: %s)', $t(label))"
  56. name="ticket-state-circle"
  57. />
  58. <div
  59. v-if="pill"
  60. class="text-xs uppercase leading-[14px] ltr:ml-[2px] rtl:mr-[2px]"
  61. aria-hidden="true"
  62. >
  63. {{ $t(label) }}
  64. </div>
  65. </div>
  66. </template>