Message.vue 1.1 KB

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