CommonLoader.vue 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 type { Sizes } from '#shared/components/CommonIcon/types.ts'
  5. import { markup } from '#shared/utils/markup.ts'
  6. interface Props {
  7. loading?: boolean
  8. error?: string | null
  9. size?: Sizes
  10. noTransition?: boolean
  11. }
  12. withDefaults(defineProps<Props>(), {
  13. size: 'medium',
  14. })
  15. </script>
  16. <script lang="ts">
  17. export default {
  18. inheritAttrs: false,
  19. }
  20. </script>
  21. <template>
  22. <Transition :name="noTransition ? 'none' : 'fade'" mode="out-in">
  23. <div
  24. v-if="loading"
  25. v-bind="$attrs"
  26. class="flex items-center justify-center"
  27. role="status"
  28. >
  29. <CommonIcon
  30. class="fill-yellow-300"
  31. name="spinner"
  32. :size="size"
  33. animation="spin"
  34. :label="__('Loading…')"
  35. />
  36. </div>
  37. <CommonAlert v-else-if="error" v-bind="$attrs" variant="danger">
  38. <span v-html="markup($t(error))" />
  39. </CommonAlert>
  40. <slot v-else />
  41. </Transition>
  42. </template>