HomeCard.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <script setup lang="ts">
  2. import { toRefs, computed } from "vue";
  3. import _ from "lodash";
  4. const props = withDefaults(
  5. defineProps<{
  6. title?: string;
  7. color?: "info" | "skyblue" | "white";
  8. }>(),
  9. {
  10. color: "info",
  11. }
  12. );
  13. const { title, color } = toRefs(props);
  14. const styles = computed(() => {
  15. return _.get(
  16. {
  17. info: {
  18. backgroundColor: "#f5f9ff",
  19. borderColor: "#e2eeff",
  20. },
  21. skyblue: {
  22. backgroundColor: "#f6fdff",
  23. borderColor: "#e3f8f4",
  24. },
  25. white: {
  26. borderColor: "#e2eeff",
  27. backgroundColor: "#fff",
  28. },
  29. },
  30. color.value
  31. );
  32. });
  33. </script>
  34. <template>
  35. <div class="card" :style="styles">
  36. <slot name="title">
  37. <h2 v-if="title">
  38. {{ title }}
  39. </h2>
  40. </slot>
  41. <el-row :gutter="20" tag="section">
  42. <slot></slot>
  43. </el-row>
  44. </div>
  45. </template>
  46. <style lang="scss" scoped>
  47. h2 {
  48. border: none;
  49. margin: 0;
  50. padding: 0;
  51. }
  52. .card {
  53. display: flex;
  54. flex-direction: column;
  55. align-items: stretch;
  56. gap: 24px;
  57. border-radius: 20px;
  58. padding: 32px;
  59. background: #f5f9ff;
  60. border: 1px solid #e2eeff;
  61. min-height: 240px;
  62. :deep(.card) {
  63. min-height: 162px;
  64. }
  65. h2 {
  66. display: flex;
  67. align-items: center;
  68. .prefix {
  69. margin-right: 8px;
  70. }
  71. .suffix {
  72. width: 24px;
  73. height: 24px;
  74. margin-left: 8px;
  75. color: #00000042;
  76. }
  77. }
  78. .el-row {
  79. row-gap: 20px;
  80. align-items: stretch;
  81. }
  82. }
  83. </style>