CardIconMiniChart.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <q-card flat class="q-pa-lg" style="max-height: 184px; min-width: 305px;">
  3. <div class="column no-wrap full-width">
  4. <div class="flex justify-between items-center no-wrap">
  5. <span class="text-h5">{{ title }}</span>
  6. <div class="round background">
  7. <q-icon class="q-pa-sm" :name="icon" size="24px" :color="color" />
  8. </div>
  9. </div>
  10. <div class="flex no-wrap full-width justify-between q-pa-sm">
  11. <div class="column flex-center">
  12. <span :class="numberCard.length >= 7 ? 'text-h4' : 'text-h3'">
  13. {{ numberCard }}
  14. </span>
  15. <div
  16. v-if="numberPorcent !== null"
  17. class="flex no-wrap text-subtitle2"
  18. :class="numberPorcent > 0 ? 'text-positive' : 'text-negative'"
  19. >
  20. <q-icon
  21. :name="numberPorcent > 0 ? 'mdi-arrow-up' : 'mdi-arrow-down'"
  22. size="18px"
  23. class="q-mr-xs"
  24. />
  25. {{ numberPorcent + "%" }}
  26. </div>
  27. </div>
  28. <div class="flex justify-end" style="max-width: 120px; height: 80px">
  29. <slot name="chart" :color="color" :chart-data="chartData" />
  30. </div>
  31. </div>
  32. </div>
  33. </q-card>
  34. </template>
  35. <script setup>
  36. const { color, title, icon, chartData, numberCard, numberPorcent } =
  37. defineProps({
  38. color: {
  39. type: String,
  40. default: "primary",
  41. },
  42. title: {
  43. type: String,
  44. default: "Usuários",
  45. },
  46. icon: {
  47. type: String,
  48. default: "mdi-account",
  49. },
  50. chartData: {
  51. type: Array,
  52. default: () =>
  53. Array.from({ length: 7 }, () => Math.floor(Math.random() * 100)),
  54. },
  55. numberCard: {
  56. type: String,
  57. default: () => Math.floor(Math.random() * 100),
  58. },
  59. numberPorcent: {
  60. type: Number,
  61. default: () => Math.ceil(Math.random() * 200 - 100),
  62. },
  63. });
  64. </script>
  65. <style lang="scss" scoped>
  66. @use "sass:map";
  67. @use "src/css/quasar.variables.scss";
  68. body.body--light {
  69. .background {
  70. background: rgba(map.get($colors, "primary"), 0.2) !important;
  71. }
  72. }
  73. body.body--dark {
  74. .background {
  75. background: rgba(map.get($colors-dark, "primary"), 0.2) !important;
  76. }
  77. }
  78. </style>