index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div id="tabs-container">
  3. <div id="tab-selection">
  4. <button
  5. class="button is-default"
  6. :class="{ selected: tab === 'queue' }"
  7. @click="showTab('queue')"
  8. >
  9. Queue
  10. </button>
  11. <button
  12. class="button is-default"
  13. :class="{ selected: tab === 'users' }"
  14. @click="showTab('users')"
  15. >
  16. Users
  17. </button>
  18. <button
  19. v-if="loggedIn"
  20. class="button is-default"
  21. :class="{ selected: tab === 'my-playlists' }"
  22. @click="showTab('my-playlists')"
  23. >
  24. My Playlists
  25. </button>
  26. </div>
  27. <queue class="tab" v-show="tab === 'queue'" />
  28. <users class="tab" v-show="tab === 'users'" />
  29. <my-playlists class="tab" v-show="tab === 'my-playlists'" />
  30. </div>
  31. </template>
  32. <script>
  33. import { mapActions, mapState } from "vuex";
  34. import Queue from "./Queue/index.vue";
  35. import Users from "./Users.vue";
  36. import MyPlaylists from "./MyPlaylists.vue";
  37. export default {
  38. components: { Queue, Users, MyPlaylists },
  39. data() {
  40. return {
  41. tab: "queue"
  42. };
  43. },
  44. computed: mapState({
  45. users: state => state.station.users,
  46. userCount: state => state.station.userCount,
  47. loggedIn: state => state.user.auth.loggedIn
  48. }),
  49. mounted() {
  50. if (
  51. this.$route.query.tab === "queue" ||
  52. this.$route.query.tab === "users" ||
  53. this.$route.query.tab === "my-playlists"
  54. )
  55. this.tab = this.$route.query.tab;
  56. },
  57. methods: {
  58. ...mapActions("modalVisibility", ["openModal"]),
  59. showTab(tab) {
  60. const queries = this.$route.query.tab
  61. ? this.$route.query
  62. : { ...this.$route.query, tab };
  63. queries.tab = tab;
  64. this.$route.query.tab = tab;
  65. this.tab = this.$route.query.tab;
  66. // eslint-disable-next-line no-restricted-globals
  67. history.pushState(
  68. {},
  69. null,
  70. `${this.$route.path}?${Object.keys(queries)
  71. .map(key => {
  72. return `${encodeURIComponent(key)}=${encodeURIComponent(
  73. queries[key]
  74. )}`;
  75. })
  76. .join("&")}`
  77. );
  78. }
  79. }
  80. };
  81. </script>
  82. <style lang="scss" scoped>
  83. @import "../../../../styles/global.scss";
  84. .night-mode {
  85. #tab-selection .button {
  86. background: $dark-grey;
  87. color: #fff;
  88. }
  89. }
  90. #tabs-container .tab {
  91. width: 100%;
  92. height: calc(100% - 36px);
  93. position: absolute;
  94. border: 1px solid $light-grey-2;
  95. border-top: 0;
  96. }
  97. #tab-selection {
  98. display: flex;
  99. .button {
  100. border-radius: 5px 5px 0 0;
  101. border: 0;
  102. text-transform: uppercase;
  103. font-size: 17px;
  104. color: $night-mode-bg-secondary;
  105. background-color: $night-mode-text;
  106. flex-grow: 1;
  107. &:not(:first-of-type) {
  108. margin-left: 5px;
  109. }
  110. }
  111. .selected {
  112. background-color: $night-mode-bg-secondary !important;
  113. color: #fff !important;
  114. }
  115. }
  116. /deep/ .tab-actionable-button {
  117. width: calc(100% - 20px);
  118. height: 40px;
  119. border-radius: 5px;
  120. margin: 10px;
  121. position: absolute;
  122. bottom: 0;
  123. border: 0;
  124. &:active,
  125. &:focus {
  126. border: 0;
  127. }
  128. }
  129. /deep/ .scrollable-list {
  130. width: 100%;
  131. overflow: auto;
  132. max-height: calc(100% - 20px - 40px);
  133. padding: 10px;
  134. .queue-item:not(:last-of-type) {
  135. margin-bottom: 10px;
  136. }
  137. }
  138. /deep/ ::-webkit-scrollbar {
  139. width: 10px;
  140. }
  141. /deep/ ::-webkit-scrollbar-track {
  142. background-color: #fff;
  143. border: 1px solid $light-grey-2;
  144. }
  145. /deep/ ::-webkit-scrollbar-thumb {
  146. background-color: $dark-grey;
  147. &:hover {
  148. background-color: darken($dark-grey, 10%);
  149. }
  150. }
  151. </style>