Message.vue 930 B

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