You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
1.9 KiB

2 years ago
  1. <template>
  2. <div>
  3. <v-btn-toggle tile group v-model="activeIndex">
  4. <v-btn
  5. v-for="(sortBy, i) in sortByList"
  6. :key="`sort_by_${i}`"
  7. class="sort-by-item text-center remove-upper"
  8. plain
  9. height="auto"
  10. :ripple="false"
  11. :class="width > 1264 ? '' : 'px-1'"
  12. :style="width > 1264 ? 'font-size: 16px' : 'font-size: 12px'"
  13. >
  14. {{ $t(sortBy.text) }}
  15. </v-btn>
  16. </v-btn-toggle>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: "SortByGroup",
  22. data: () => ({
  23. activeIndex: -1,
  24. sortByList: [
  25. /*{
  26. text: "Ratings",
  27. sort: "sortByRate",
  28. },
  29. {
  30. text: "ShowEasy Recommended",
  31. sort: "sortByRecommend",
  32. },*/
  33. {
  34. text: "Show Dates",
  35. sort: "sortByNewest",
  36. },
  37. {
  38. text: "Exhibitor Numbers",
  39. sort: "sortByExhibitNumber",
  40. },
  41. {
  42. text: "Visitor Numbers",
  43. sort: "sortByVisitorNumber",
  44. },
  45. ],
  46. width: undefined,
  47. }),
  48. created() {
  49. if (process.client) {
  50. this.width = window.innerWidth;
  51. }
  52. },
  53. methods: {
  54. onResize() {
  55. if (process.client) {
  56. this.width = window.innerWidth;
  57. }
  58. },
  59. },
  60. computed: {
  61. windowWidth() {
  62. if (process.client) {
  63. this.width = window.innerWidth;
  64. }
  65. return this.width;
  66. },
  67. },
  68. mounted() {
  69. this.$nextTick(() => {
  70. window.addEventListener("resize", this.onResize);
  71. });
  72. },
  73. beforeDestroy() {
  74. window.removeEventListener("resize", this.onResize);
  75. },
  76. watch: {
  77. activeIndex(newIdx, oldIdx) {
  78. if (newIdx === undefined || newIdx === oldIdx) return;
  79. this.$emit("change", this.sortByList[newIdx].sort);
  80. },
  81. },
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .sort-by-item {
  86. user-select: none;
  87. cursor: pointer;
  88. &:hover {
  89. color: #ee9546;
  90. }
  91. &.v-btn--active {
  92. color: #ee9546;
  93. }
  94. }
  95. </style>