ReportInfoItem.vue 2.0 KB

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