ProfilePicture.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <img
  3. class="profile-picture using-gravatar"
  4. v-if="avatar.type === 'gravatar'"
  5. :src="
  6. avatar.url ? `${avatar.url}?d=${notes}&s=250` : '/assets/notes.png'
  7. "
  8. onerror="this.src='/assets/notes.png'; this.onerror=''"
  9. />
  10. <div class="profile-picture using-initials" :class="avatar.color" v-else>
  11. {{ initials }}
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. props: {
  17. avatar: {
  18. type: Object,
  19. default: () => {}
  20. },
  21. name: {
  22. type: String,
  23. default: ": )"
  24. }
  25. },
  26. data() {
  27. return {
  28. notes: ""
  29. };
  30. },
  31. computed: {
  32. initials() {
  33. return this.name
  34. .split(" ")
  35. .map(word => word.charAt(0))
  36. .join("")
  37. .toUpperCase();
  38. }
  39. },
  40. async mounted() {
  41. const frontendDomain = await lofig.get("frontendDomain");
  42. this.notes = encodeURI(`${frontendDomain}/assets/notes.png`);
  43. }
  44. };
  45. </script>
  46. <style lang="scss" scoped>
  47. .profile-picture {
  48. width: 100px;
  49. height: 100px;
  50. border-radius: 100%;
  51. border: 0.5px solid var(--light-grey-3);
  52. &.using-initials {
  53. display: flex;
  54. align-items: center;
  55. justify-content: center;
  56. background-color: #ddd;
  57. font-family: "Inter", sans-serif;
  58. font-weight: 400;
  59. font-size: 50px;
  60. user-select: none;
  61. -webkit-user-select: none;
  62. &.blue {
  63. background-color: var(--primary-color);
  64. color: var(--white);
  65. }
  66. &.orange {
  67. background-color: var(--orange);
  68. color: var(--white);
  69. }
  70. &.green {
  71. background-color: var(--green);
  72. color: var(--white);
  73. }
  74. &.purple {
  75. background-color: var(--purple);
  76. color: var(--white);
  77. }
  78. &.teal {
  79. background-color: var(--teal);
  80. color: var(--white);
  81. }
  82. &.grey {
  83. background-color: var(--grey);
  84. color: var(--white);
  85. }
  86. }
  87. }
  88. </style>