ProfilePicture.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. @import "../../styles/global.scss";
  48. .profile-picture {
  49. width: 100px;
  50. height: 100px;
  51. border-radius: 100%;
  52. border: 0.5px solid var(--light-grey-3);
  53. &.using-initials {
  54. display: flex;
  55. align-items: center;
  56. justify-content: center;
  57. background-color: #ddd;
  58. font-family: "Inter", sans-serif;
  59. font-weight: 400;
  60. font-size: 50px;
  61. user-select: none;
  62. -webkit-user-select: none;
  63. &.blue {
  64. background-color: var(--primary-color);
  65. color: var(--white);
  66. }
  67. &.orange {
  68. background-color: var(--light-orange);
  69. color: var(--white);
  70. }
  71. &.green {
  72. background-color: var(--green);
  73. color: var(--white);
  74. }
  75. &.purple {
  76. background-color: var(--purple);
  77. color: var(--white);
  78. }
  79. &.teal {
  80. background-color: var(--teal);
  81. color: var(--white);
  82. }
  83. }
  84. }
  85. </style>