ReportInfoItem.vue 2.2 KB

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