Show.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div v-if="isUser">
  3. <metadata v-bind:title="`Profile | ${user.username}`" />
  4. <main-header />
  5. <div class="info-section">
  6. <div class="picture-name-row">
  7. <img
  8. class="profile-picture"
  9. :src="
  10. user.avatar
  11. ? `${user.avatar}?d=${notes}&s=250`
  12. : '/assets/notes.png'
  13. "
  14. onerror="this.src='/assets/notes.png'; this.onerror=''"
  15. />
  16. <div>
  17. <div class="name-role-row">
  18. <p class="name">{{ user.name }}</p>
  19. <span class="role admin" v-if="user.role === 'admin'"
  20. >admin</span
  21. >
  22. </div>
  23. <p class="username">@{{ user.username }}</p>
  24. </div>
  25. </div>
  26. <div class="buttons" v-if="userId === user._id || role === 'admin'">
  27. <router-link
  28. :to="`/admin/users?userId=${user._id}`"
  29. class="button is-primary"
  30. v-if="role === 'admin'"
  31. >
  32. Edit
  33. </router-link>
  34. <router-link
  35. to="/settings"
  36. class="button is-primary"
  37. v-if="userId === user._id"
  38. >
  39. Settings
  40. </router-link>
  41. </div>
  42. <div class="bio-row" v-if="user.bio">
  43. <i class="material-icons">notes</i>
  44. <p>{{ user.bio }}</p>
  45. </div>
  46. <div
  47. class="date-location-row"
  48. v-if="user.createdAt || user.location"
  49. >
  50. <div class="date" v-if="user.createdAt">
  51. <i class="material-icons">calendar_today</i>
  52. <p>{{ user.createdAt }}</p>
  53. </div>
  54. <div class="location" v-if="user.location">
  55. <i class="material-icons">location_on</i>
  56. <p>{{ user.location }}</p>
  57. </div>
  58. </div>
  59. </div>
  60. <div class="bottom-section">
  61. <div class="buttons">
  62. <button class="active">Recent activity</button>
  63. <button>Playlists</button>
  64. </div>
  65. <div class="content">
  66. Content here
  67. </div>
  68. </div>
  69. <main-footer />
  70. </div>
  71. </template>
  72. <script>
  73. import { mapState } from "vuex";
  74. import { format, parseISO } from "date-fns";
  75. import MainHeader from "../MainHeader.vue";
  76. import MainFooter from "../MainFooter.vue";
  77. import io from "../../io";
  78. export default {
  79. components: { MainHeader, MainFooter },
  80. data() {
  81. return {
  82. user: {},
  83. notes: "",
  84. isUser: false
  85. };
  86. },
  87. computed: mapState({
  88. role: state => state.user.auth.role,
  89. userId: state => state.user.auth.userId
  90. }),
  91. mounted() {
  92. lofig.get("frontendDomain").then(frontendDomain => {
  93. this.frontendDomain = frontendDomain;
  94. this.notes = encodeURI(`${this.frontendDomain}/assets/notes.png`);
  95. });
  96. io.getSocket(socket => {
  97. this.socket = socket;
  98. this.socket.emit(
  99. "users.findByUsername",
  100. this.$route.params.username,
  101. res => {
  102. if (res.status === "error") this.$router.go("/404");
  103. else {
  104. this.user = res.data;
  105. this.user.createdAt = format(
  106. parseISO(this.user.createdAt),
  107. "MMMM do yyyy"
  108. );
  109. this.isUser = true;
  110. }
  111. }
  112. );
  113. });
  114. },
  115. methods: {}
  116. };
  117. </script>
  118. <style lang="scss" scoped>
  119. @import "styles/global.scss";
  120. .info-section {
  121. width: 912px;
  122. margin-left: auto;
  123. margin-right: auto;
  124. margin-top: 32px;
  125. padding: 24px;
  126. .picture-name-row {
  127. display: flex;
  128. flex-direction: row;
  129. align-items: center;
  130. column-gap: 32px;
  131. justify-content: center;
  132. margin-bottom: 24px;
  133. }
  134. .profile-picture {
  135. width: 100px;
  136. height: 100px;
  137. border-radius: 100%;
  138. }
  139. .name-role-row {
  140. display: flex;
  141. flex-direction: row;
  142. align-items: center;
  143. column-gap: 12px;
  144. }
  145. .name {
  146. font-size: 34px;
  147. line-height: 40px;
  148. color: $dark-grey-3;
  149. }
  150. .role {
  151. padding: 2px 24px;
  152. color: $white;
  153. text-transform: uppercase;
  154. font-size: 12px;
  155. line-height: 14px;
  156. height: 18px;
  157. border-radius: 5px;
  158. &.admin {
  159. background-color: $red;
  160. }
  161. }
  162. .username {
  163. font-size: 24px;
  164. line-height: 28px;
  165. color: $dark-grey;
  166. }
  167. .buttons {
  168. width: 388px;
  169. display: flex;
  170. flex-direction: row;
  171. column-gap: 20px;
  172. margin-left: auto;
  173. margin-right: auto;
  174. margin-bottom: 24px;
  175. .button {
  176. flex: 1;
  177. font-size: 17px;
  178. line-height: 20px;
  179. }
  180. }
  181. .bio-row,
  182. .date-location-row {
  183. i {
  184. font-size: 24px;
  185. color: $dark-grey-2;
  186. margin-right: 12px;
  187. }
  188. p {
  189. font-size: 17px;
  190. line-height: 20px;
  191. color: $dark-grey-2;
  192. word-break: break-word;
  193. }
  194. }
  195. .bio-row {
  196. max-width: 608px;
  197. margin-bottom: 24px;
  198. margin-left: auto;
  199. margin-right: auto;
  200. display: flex;
  201. width: max-content;
  202. }
  203. .date-location-row {
  204. max-width: 608px;
  205. margin-left: auto;
  206. margin-right: auto;
  207. margin-bottom: 24px;
  208. display: flex;
  209. width: max-content;
  210. margin-bottom: 24px;
  211. column-gap: 48px;
  212. }
  213. .date,
  214. .location {
  215. display: flex;
  216. }
  217. }
  218. .bottom-section {
  219. width: 960px;
  220. margin-left: auto;
  221. margin-right: auto;
  222. margin-top: 32px;
  223. padding: 24px;
  224. display: flex;
  225. column-gap: 64px;
  226. .buttons {
  227. height: 100%;
  228. width: 251px;
  229. button {
  230. outline: none;
  231. border: none;
  232. box-shadow: none;
  233. color: $musareBlue;
  234. font-size: 22px;
  235. line-height: 26px;
  236. padding: 7px 0 7px 12px;
  237. width: 100%;
  238. text-align: left;
  239. cursor: pointer;
  240. border-radius: 5px;
  241. background-color: transparent;
  242. &.active {
  243. color: $white;
  244. background-color: $musareBlue;
  245. }
  246. }
  247. }
  248. .content {
  249. outline: 1px solid black;
  250. width: 597px;
  251. }
  252. }
  253. .night-mode {
  254. .name,
  255. .username,
  256. .bio-row i,
  257. .bio-row p,
  258. .date-location-row i,
  259. .date-location-row p {
  260. color: $light-grey;
  261. }
  262. }
  263. </style>