PlaylistItem.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <template>
  2. <div class="playlist-item universal-item">
  3. <slot name="item-icon">
  4. <span></span>
  5. </slot>
  6. <div class="item-title-description">
  7. <p class="item-title">
  8. {{ playlist.displayName }}
  9. <i
  10. v-if="playlist.privacy === 'private'"
  11. class="private-playlist-icon material-icons"
  12. content="This playlist is not visible to other users."
  13. v-tippy="{ theme: 'info' }"
  14. >lock</i
  15. >
  16. </p>
  17. <p class="item-description">
  18. <span v-if="showOwner"
  19. ><a v-if="playlist.createdBy === 'Musare'" title="Musare"
  20. >Musare</a
  21. ><user-id-to-username
  22. v-else
  23. :user-id="playlist.createdBy"
  24. :link="true"
  25. />
  26. •</span
  27. >
  28. <span :title="playlistLength">
  29. {{ playlistLength }}
  30. </span>
  31. </p>
  32. </div>
  33. <div class="universal-item-actions">
  34. <div class="icons-group">
  35. <slot name="actions" />
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import UserIdToUsername from "@/components/UserIdToUsername.vue";
  42. import utils from "../../js/utils";
  43. export default {
  44. components: { UserIdToUsername },
  45. props: {
  46. playlist: { type: Object, default: () => {} },
  47. showOwner: { type: Boolean, default: false }
  48. },
  49. data() {
  50. return {
  51. utils
  52. };
  53. },
  54. computed: {
  55. playlistLength() {
  56. return `${this.totalLength(this.playlist)} • ${
  57. this.playlist.songs.length
  58. } ${this.playlist.songs.length === 1 ? "song" : "songs"}`;
  59. }
  60. },
  61. methods: {
  62. totalLength(playlist) {
  63. let length = 0;
  64. playlist.songs.forEach(song => {
  65. length += song.duration;
  66. });
  67. return this.utils.formatTimeLong(length);
  68. }
  69. }
  70. };
  71. </script>
  72. <style lang="scss" scoped>
  73. .night-mode {
  74. .playlist-item {
  75. background-color: var(--dark-grey-2) !important;
  76. border: 0 !important;
  77. p {
  78. color: var(--light-grey-2) !important;
  79. }
  80. }
  81. }
  82. .playlist-item {
  83. width: 100%;
  84. height: 72px;
  85. column-gap: 7.5px;
  86. .item-title-description {
  87. flex: 1;
  88. overflow: hidden;
  89. .item-title {
  90. color: var(--dark-grey-2);
  91. font-size: 20px;
  92. line-height: 23px;
  93. margin-bottom: 0;
  94. display: flex;
  95. align-items: center;
  96. .private-playlist-icon {
  97. color: var(--dark-pink);
  98. font-size: 18px;
  99. margin-left: 5px;
  100. }
  101. }
  102. }
  103. .universal-item-actions {
  104. margin-left: none;
  105. div {
  106. display: flex;
  107. align-items: center;
  108. line-height: 1;
  109. button,
  110. .button {
  111. width: 100%;
  112. font-size: 17px;
  113. height: 36px;
  114. }
  115. }
  116. }
  117. }
  118. </style>