Playlist.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. let _this = this;
  34. let socketInterval = setInterval(() => {
  35. if (!!_this.$parent.$parent.socket) {
  36. _this.socket = _this.$parent.$parent.socket;
  37. _this.socket.emit('playlists.indexForUser', _this.$parent.$parent.username, res => {
  38. if (res.status == 'success') _this.playlists = res.data;
  39. });
  40. clearInterval(socketInterval);
  41. }
  42. }, 100);
  43. }
  44. }
  45. </script>
  46. <style type='scss' scoped>
  47. .sidebar {
  48. position: fixed;
  49. top: 0;
  50. right: 0;
  51. width: 300px;
  52. height: 100vh;
  53. background-color: #fff;
  54. box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.16), 0 2px 10px 0 rgba(0, 0, 0, 0.12);
  55. }
  56. .inner-wrapper {
  57. top: 50px;
  58. position: relative;
  59. }
  60. .slide-transition {
  61. transition: transform 0.6s ease-in-out;
  62. transform: translateX(0);
  63. }
  64. .slide-enter, .slide-leave { transform: translateX(100%); }
  65. .title {
  66. background-color: rgb(3, 169, 244);
  67. text-align: center;
  68. padding: 10px;
  69. color: white;
  70. font-weight: 600;
  71. }
  72. .create-playlist {
  73. width: 100%;
  74. margin-top: 20px;
  75. height: 40px;
  76. border-radius: 0;
  77. background: rgb(3, 169, 244);
  78. color: #fff !important;
  79. border: 0;
  80. &:active, &:focus { border: 0; }
  81. }
  82. .menu { padding: 0 20px; }
  83. .menu-list li a:hover { color: #000 !important; }
  84. .menu-list li {
  85. display: flex;
  86. justify-content: space-between;
  87. }
  88. li a {
  89. display: flex;
  90. align-items: center;
  91. }
  92. .none-found { text-align: center; }
  93. </style>