PlaylistItem.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. <slot name="actions" />
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import UserIdToUsername from "@/components/UserIdToUsername.vue";
  40. import utils from "../../js/utils";
  41. export default {
  42. components: { UserIdToUsername },
  43. props: {
  44. playlist: { type: Object, default: () => {} },
  45. showOwner: { type: Boolean, default: false }
  46. },
  47. data() {
  48. return {
  49. utils
  50. };
  51. },
  52. computed: {
  53. playlistLength() {
  54. return `${this.totalLength(this.playlist)} • ${
  55. this.playlist.songs.length
  56. } ${this.playlist.songs.length === 1 ? "song" : "songs"}`;
  57. }
  58. },
  59. methods: {
  60. totalLength(playlist) {
  61. let length = 0;
  62. playlist.songs.forEach(song => {
  63. length += song.duration;
  64. });
  65. return this.utils.formatTimeLong(length);
  66. }
  67. }
  68. };
  69. </script>
  70. <style lang="scss" scoped>
  71. .night-mode {
  72. .playlist-item {
  73. background-color: var(--dark-grey-2) !important;
  74. border: 0 !important;
  75. p {
  76. color: var(--light-grey-2) !important;
  77. }
  78. }
  79. }
  80. .playlist-item {
  81. width: 100%;
  82. height: 72px;
  83. column-gap: 7.5px;
  84. .item-title-description {
  85. flex: 1;
  86. overflow: hidden;
  87. .item-title {
  88. color: var(--dark-grey-2);
  89. font-size: 20px;
  90. line-height: 23px;
  91. margin-bottom: 0;
  92. display: flex;
  93. align-items: center;
  94. .private-playlist-icon {
  95. color: var(--dark-pink);
  96. font-size: 18px;
  97. margin-left: 5px;
  98. }
  99. }
  100. }
  101. .universal-item-actions {
  102. margin-left: none;
  103. div {
  104. display: flex;
  105. align-items: center;
  106. line-height: 1;
  107. button,
  108. .button {
  109. width: 100%;
  110. font-size: 17px;
  111. height: 36px;
  112. }
  113. }
  114. }
  115. }
  116. </style>