ReportInfoItem.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <script setup lang="ts">
  2. import { useStore } from "vuex";
  3. import { defineAsyncComponent } from "vue";
  4. import { formatDistance } from "date-fns";
  5. const ProfilePicture = defineAsyncComponent(
  6. () => import("@/components/ProfilePicture.vue")
  7. );
  8. defineProps({
  9. createdBy: { type: Object, default: () => {} },
  10. createdAt: { type: String, default: "" }
  11. });
  12. const store = useStore();
  13. const closeModal = modal => store.dispatch("modalVisibility/closeModal", modal);
  14. </script>
  15. <template>
  16. <div class="universal-item report-info-item">
  17. <div class="item-icon">
  18. <profile-picture
  19. :avatar="createdBy.avatar"
  20. :name="createdBy.name ? createdBy.name : createdBy.username"
  21. v-if="createdBy.avatar"
  22. />
  23. <i class="material-icons" v-else>person_remove</i>
  24. </div>
  25. <div class="item-title-description">
  26. <h2
  27. class="item-title"
  28. :title="`Reported by ${
  29. createdBy.username ? createdBy.username : 'Deleted User'
  30. }`"
  31. >
  32. Reported by
  33. <router-link
  34. v-if="createdBy.username"
  35. :to="{
  36. path: `/u/${createdBy.username}`
  37. }"
  38. :title="createdBy._id"
  39. @click="closeModal('viewReport')"
  40. >
  41. {{ createdBy.username }}
  42. </router-link>
  43. <span v-else :title="createdBy._id">Deleted User</span>
  44. </h2>
  45. <h5 class="item-description">
  46. {{
  47. formatDistance(new Date(createdAt), new Date(), {
  48. addSuffix: true
  49. })
  50. }}
  51. </h5>
  52. </div>
  53. <div class="universal-item-actions">
  54. <slot name="actions" />
  55. </div>
  56. </div>
  57. </template>
  58. <style lang="less" scoped>
  59. .night-mode {
  60. .report-info-item {
  61. background-color: var(--dark-grey) !important;
  62. border: 0 !important;
  63. }
  64. }
  65. .report-info-item {
  66. .item-icon {
  67. min-width: 45px;
  68. max-width: 45px;
  69. height: 45px;
  70. margin-right: 10px;
  71. :deep(.profile-picture.using-initials span) {
  72. font-size: calc(
  73. 45px / 5 * 2
  74. ); // 2/5th of .profile-picture height/width
  75. }
  76. .profile-picture,
  77. i {
  78. width: 45px;
  79. height: 45px;
  80. }
  81. i {
  82. font-size: 30px;
  83. display: flex;
  84. align-items: center;
  85. justify-content: center;
  86. }
  87. }
  88. .item-title-description {
  89. min-width: 0;
  90. }
  91. .item-title {
  92. font-size: 14px;
  93. margin: 0;
  94. }
  95. .item-description {
  96. font-size: 12px;
  97. line-height: 14px;
  98. text-transform: capitalize;
  99. margin: 0;
  100. }
  101. }
  102. </style>