Message.vue 1012 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div
  3. class="px-6 flex gap-3 items-center rounded-xl duration-150"
  4. :class="color"
  5. >
  6. <ICheckAlt
  7. v-if="props.type === 'done'"
  8. class="h-[48px] w-[48px] fill-red-400"
  9. />
  10. <IAlert
  11. v-else-if="props.type === 'warn'"
  12. class="h-[48px] w-[48px] fill-red-400 stroke-red-400"
  13. />
  14. <IClose
  15. v-else-if="props.type === 'danger'"
  16. class="h-[48px] w-[48px] fill-red-400 stroke-red-400"
  17. />
  18. <p
  19. v-if="props.text"
  20. class="text-sm font-semibold"
  21. v-text="props.text"
  22. />
  23. <slot />
  24. </div>
  25. </template>
  26. <script setup lang="ts">
  27. const props = withDefaults(
  28. defineProps<{
  29. type?: 'done' | 'warn' | 'danger'
  30. icon?: boolean
  31. text?: string
  32. }>(),
  33. {
  34. type: 'done',
  35. icon: true,
  36. },
  37. )
  38. const color = computed(() => {
  39. if (props.type === 'done') return 'text-green-500'
  40. if (props.type === 'warn') return 'text-yellow-500'
  41. if (props.type === 'danger') return 'text-red-500'
  42. return 'text-green-500'
  43. })
  44. </script>