CommonStepperStep.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { computed } from 'vue'
  4. const props = defineProps<{
  5. label: string
  6. selected: boolean
  7. completed: boolean
  8. valid: boolean
  9. disabled: boolean
  10. errorCount: number
  11. }>()
  12. const classes = computed(() => {
  13. if (props.selected) return 'bg-white text-black'
  14. if (props.completed && !props.valid) return 'bg-red-dark'
  15. if (props.completed) return 'bg-gray-400'
  16. return 'text-white/70'
  17. })
  18. </script>
  19. <template>
  20. <button
  21. class="flex h-6 w-6 grow-0 items-center justify-center rounded-full"
  22. :disabled="disabled"
  23. :class="classes"
  24. type="button"
  25. >
  26. <div
  27. v-if="completed && errorCount"
  28. role="status"
  29. :aria-label="$t('Invalid values in step %s', label)"
  30. aria-live="assertive"
  31. class="bg-red absolute mb-3 h-4 min-w-[1rem] rounded-full px-1 text-center text-xs text-black ltr:ml-6 rtl:mr-6"
  32. >
  33. {{ errorCount }}
  34. </div>
  35. <template v-if="selected">{{ label }}</template>
  36. <CommonIcon
  37. v-else-if="completed && !valid"
  38. decorative
  39. name="close"
  40. size="tiny"
  41. class="text-red-bright"
  42. />
  43. <CommonIcon
  44. v-else-if="completed"
  45. :aria-label="$t('Step %s is completed', label)"
  46. name="check"
  47. size="tiny"
  48. class="text-blue"
  49. />
  50. <template v-else>{{ label }}</template>
  51. </button>
  52. </template>