Badge.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <v-card @hover="onHover">
  3. <div class="frame">
  4. <v-img
  5. :src="img"
  6. :alt="title"
  7. />
  8. <div class="details">
  9. <v-card-title>{{ title }}</v-card-title>
  10. <v-card-subtitle v-if="subtitle">{{ subtitle }}</v-card-subtitle>
  11. <v-card-text v-if="details && expanded">{{ details }}</v-card-text>
  12. <v-card-actions v-if="details && !expanded">
  13. <v-btn icon="fas fa-plus" variant="flat" @click="onMoreClick" />
  14. </v-card-actions>
  15. </div>
  16. </div>
  17. </v-card>
  18. </template>
  19. <script setup lang="ts">
  20. import type { PropType } from '@vue/runtime-core'
  21. import type { Ref } from '@vue/reactivity'
  22. defineProps({
  23. title: {
  24. type: String,
  25. required: true
  26. },
  27. img: {
  28. type: String,
  29. required: true
  30. },
  31. subtitle: {
  32. type: String as PropType<string | null>,
  33. required: false,
  34. default: null
  35. },
  36. details: {
  37. type: String as PropType<string | null>,
  38. required: false,
  39. default: null
  40. },
  41. })
  42. const expanded: Ref<boolean> = ref(false)
  43. const onHover = () => {
  44. }
  45. const onMoreClick = () => {
  46. }
  47. </script>
  48. <style scoped lang="scss">
  49. .v-card {
  50. height: 54px;
  51. width: 196px;
  52. padding: 10px;
  53. .frame {
  54. display: flex;
  55. flex-direction: row;
  56. justify-content: space-between;
  57. align-items: center;
  58. flex-wrap: nowrap;
  59. max-height: 100%;
  60. }
  61. .details {
  62. flex: 1;
  63. }
  64. .v-img {
  65. max-width: 24px;
  66. height: 24px;
  67. margin: 0 12px;
  68. }
  69. .v-card-title {
  70. font-size: 16px;
  71. padding: 0 16px;
  72. font-weight: 300;
  73. }
  74. .v-card-subtitle {
  75. font-size: 14px;
  76. }
  77. }
  78. .v-card-actions {
  79. display: none;
  80. }
  81. //.v-card:hover {
  82. // .v-card-actions {
  83. // display: block;
  84. // }
  85. //}
  86. </style>