CommonLoader.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. /* eslint-disable vue/no-v-html */
  4. import { markup } from '#shared/utils/markup.ts'
  5. interface Props {
  6. loading?: boolean
  7. error?: string | null
  8. position?: 'center' | 'right' | 'left'
  9. }
  10. withDefaults(defineProps<Props>(), {
  11. position: 'center',
  12. })
  13. </script>
  14. <script lang="ts">
  15. export default {
  16. inheritAttrs: false,
  17. }
  18. </script>
  19. <template>
  20. <div
  21. v-if="loading"
  22. v-bind="$attrs"
  23. class="flex"
  24. :class="{
  25. 'items-center justify-center': position === 'center',
  26. 'items-center justify-end': position === 'right',
  27. 'items-center justify-start': position === 'left',
  28. }"
  29. role="status"
  30. >
  31. <CommonIcon
  32. :label="__('Loading content')"
  33. name="loading"
  34. animation="spin"
  35. />
  36. </div>
  37. <div
  38. v-else-if="error"
  39. v-bind="$attrs"
  40. class="flex items-center justify-center gap-2 text-base text-red-bright"
  41. >
  42. <CommonIcon name="close-small" />
  43. <span v-html="markup($t(error))" />
  44. </div>
  45. <slot v-else />
  46. </template>