PlaylistItem.vue 2.1 KB

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