Playlist.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <div class='sidebar' transition='slide' v-if='$parent.sidebars.playlist'>
  3. <div class='inner-wrapper'>
  4. <div class='title'>Playlists</div>
  5. <aside class='menu' v-if='playlists.length > 0'>
  6. <ul class='menu-list'>
  7. <li v-for='playlist in playlists'>
  8. <a href='#'>{{ playlist.displayName }}</a>
  9. <a href='#' @click='editPlaylist(playlist._id)'>
  10. <i class='material-icons'>edit</i>
  11. </a>
  12. </li>
  13. </ul>
  14. </aside>
  15. <div class='none-found' v-else>No Playlists found</div>
  16. <a class='button create-playlist' @click='$parent.toggleModal("createPlaylist")'>Create Playlist</a>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. playlists: []
  25. }
  26. },
  27. methods: {
  28. editPlaylist: function (id) {
  29. this.$parent.editPlaylist(id);
  30. }
  31. },
  32. ready: function () {
  33. // TODO: Update when playlist is removed/created
  34. let _this = this;
  35. let socketInterval = setInterval(() => {
  36. if (!!_this.$parent.$parent.socket) {
  37. _this.socket = _this.$parent.$parent.socket;
  38. _this.socket.emit('playlists.indexForUser', _this.$parent.$parent.username, res => {
  39. if (res.status == 'success') _this.playlists = res.data;
  40. });
  41. clearInterval(socketInterval);
  42. }
  43. }, 100);
  44. }
  45. }
  46. </script>
  47. <style type='scss' scoped>
  48. .sidebar {
  49. position: fixed;
  50. top: 0;
  51. right: 0;
  52. width: 300px;
  53. height: 100vh;
  54. background-color: #fff;
  55. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  56. }
  57. .inner-wrapper {
  58. top: 50px;
  59. position: relative;
  60. }
  61. .slide-transition {
  62. transition: transform 0.6s ease-in-out;
  63. transform: translateX(0);
  64. }
  65. .slide-enter, .slide-leave { transform: translateX(100%); }
  66. .title {
  67. background-color: rgb(3, 169, 244);
  68. text-align: center;
  69. padding: 10px;
  70. color: white;
  71. font-weight: 600;
  72. }
  73. .create-playlist {
  74. width: 100%;
  75. margin-top: 20px;
  76. height: 40px;
  77. border-radius: 0;
  78. background: rgb(3, 169, 244);
  79. color: #fff !important;
  80. border: 0;
  81. &:active, &:focus { border: 0; }
  82. }
  83. .menu { padding: 0 20px; }
  84. .menu-list li a:hover { color: #000 !important; }
  85. .menu-list li {
  86. display: flex;
  87. justify-content: space-between;
  88. }
  89. li a {
  90. display: flex;
  91. align-items: center;
  92. }
  93. .none-found { text-align: center; }
  94. </style>