CommonTicketStateIndicatorIcon.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. import type { Sizes } from '#shared/components/CommonIcon/types.ts'
  5. import { EnumTicketStateColorCode } from '#shared/graphql/types.ts'
  6. export interface Props {
  7. colorCode: EnumTicketStateColorCode
  8. label: string
  9. iconSize?: Sizes
  10. }
  11. const props = withDefaults(defineProps<Props>(), {
  12. iconSize: 'xs',
  13. })
  14. const iconName = computed(() => {
  15. switch (props.colorCode) {
  16. case EnumTicketStateColorCode.Closed:
  17. return 'check-circle-outline'
  18. case EnumTicketStateColorCode.Pending:
  19. return 'check-circle-outline-dashed'
  20. case EnumTicketStateColorCode.Escalating:
  21. return 'warning-triangle'
  22. case EnumTicketStateColorCode.Open:
  23. default:
  24. return 'check-circle-no'
  25. }
  26. })
  27. const iconColor = computed(() => {
  28. switch (props.colorCode) {
  29. case EnumTicketStateColorCode.Closed:
  30. return 'text-green-400'
  31. case EnumTicketStateColorCode.Pending:
  32. return 'text-stone-400'
  33. case EnumTicketStateColorCode.Escalating:
  34. return 'text-red-300'
  35. case EnumTicketStateColorCode.Open:
  36. default:
  37. return 'text-yellow-500'
  38. }
  39. })
  40. const isEscalating = computed(
  41. () => props.colorCode === EnumTicketStateColorCode.Escalating,
  42. // assertive is used for screen readers to announce the change immediately only for escalating state
  43. // polite is used for screen readers to announce the change after the current announcement
  44. )
  45. </script>
  46. <template>
  47. <CommonIcon
  48. role="status"
  49. :aria-live="isEscalating ? 'assertive' : 'polite'"
  50. :aria-roledescription="$t('(ticket status: %s)', $t(colorCode))"
  51. :class="iconColor"
  52. :name="iconName"
  53. :size="iconSize"
  54. />
  55. </template>