index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. #tabs-container .tab {
  85. width: 100%;
  86. height: calc(100% - 36px);
  87. position: absolute;
  88. border: 1px solid $light-grey-2;
  89. border-top: 0;
  90. }
  91. #tab-selection {
  92. display: flex;
  93. .button {
  94. border-radius: 5px 5px 0 0;
  95. border: 0;
  96. text-transform: uppercase;
  97. font-size: 17px;
  98. color: $night-mode-bg-secondary;
  99. background-color: $night-mode-text;
  100. flex-grow: 1;
  101. &:not(:first-of-type) {
  102. margin-left: 5px;
  103. }
  104. }
  105. .selected {
  106. background-color: $night-mode-bg-secondary;
  107. color: #fff;
  108. }
  109. }
  110. /deep/ .tab-actionable-button {
  111. width: calc(100% - 20px);
  112. height: 40px;
  113. border-radius: 5px;
  114. margin: 10px;
  115. position: absolute;
  116. bottom: 0;
  117. border: 0;
  118. &:active,
  119. &:focus {
  120. border: 0;
  121. }
  122. }
  123. /deep/ .scrollable-list {
  124. width: 100%;
  125. overflow: auto;
  126. max-height: calc(100% - 20px - 40px);
  127. padding: 10px;
  128. .queue-item:not(:last-of-type) {
  129. margin-bottom: 10px;
  130. }
  131. }
  132. /deep/ ::-webkit-scrollbar {
  133. width: 10px;
  134. }
  135. /deep/ ::-webkit-scrollbar-track {
  136. background-color: #fff;
  137. border: 1px solid $light-grey-2;
  138. }
  139. /deep/ ::-webkit-scrollbar-thumb {
  140. background-color: $dark-grey;
  141. &:hover {
  142. background-color: darken($dark-grey, 10%);
  143. }
  144. }
  145. </style>