ReportInfoItem.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <template>
  2. <div class="universal-item report-info-item">
  3. <div class="item-icon">
  4. <profile-picture
  5. :avatar="createdBy.avatar"
  6. :name="createdBy.name ? createdBy.name : createdBy.username"
  7. v-if="createdBy.avatar"
  8. />
  9. <i class="material-icons" v-else>person_remove</i>
  10. </div>
  11. <div class="item-title-description">
  12. <p class="item-title">
  13. Reported by
  14. <router-link
  15. v-if="createdBy.username"
  16. :to="{
  17. path: `/u/${createdBy.username}`
  18. }"
  19. :title="createdBy._id"
  20. >
  21. {{ createdBy.username }}
  22. </router-link>
  23. <span v-else :title="createdBy._id">Deleted User</span>
  24. </p>
  25. <p class="item-description">
  26. {{
  27. formatDistance(new Date(createdAt), new Date(), {
  28. addSuffix: true
  29. })
  30. }}
  31. </p>
  32. </div>
  33. <div class="universal-item-actions">
  34. <slot name="actions" />
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import { formatDistance } from "date-fns";
  40. import ProfilePicture from "@/components/ProfilePicture.vue";
  41. export default {
  42. components: { ProfilePicture },
  43. props: {
  44. createdBy: { type: Object, default: () => {} },
  45. createdAt: { type: String, default: "" }
  46. },
  47. methods: {
  48. formatDistance
  49. }
  50. };
  51. </script>
  52. <style lang="scss" scoped>
  53. .report-info-item {
  54. .item-icon {
  55. min-width: 45px;
  56. max-width: 45px;
  57. height: 45px;
  58. margin-right: 10px;
  59. .profile-picture,
  60. i {
  61. width: 45px;
  62. height: 45px;
  63. }
  64. i {
  65. font-size: 30px;
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. }
  70. }
  71. .item-title {
  72. font-size: 14px;
  73. }
  74. .item-description {
  75. font-size: 12px;
  76. }
  77. }
  78. </style>