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.

141 lines
3.7 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div
  3. class="sort xl:tw-px-[35px] xl:tw-py-[30px] xl:tw-border-solid xl:tw-border xl:tw-border-neutrals-200 xl:tw-rounded-[30px]">
  4. <!-- tw-mb-[26px] xl:tw-mb-[30px] -->
  5. <div class="">
  6. <span class="t20 tw-text-primary-1">{{ results
  7. }}<span class="tw-body-3 tw-ml-[10px] tw-text-[#757575]">{{
  8. $t("Results")
  9. }}</span></span>
  10. </div>
  11. <!-- xl:tw-flex -->
  12. <!-- <div class="tw-items-center">
  13. <div class="rightBorder tw-pr-[50px] tw-body-3">{{ $t("Sort By") }}</div>
  14. <div class="tw-flex tw-items-center">
  15. <div class="tw-px-[25px]" v-for="(item, index) in sortType" :key="index">
  16. <input :id="item.value" :value="item.value" type="radio" v-model="sort" class="tw-invisible" />
  17. <label :for="item.value" class="tw-body-3 tw-text-base-secondary">
  18. {{ $t(item.name) }}
  19. </label>
  20. </div>
  21. </div>
  22. </div> -->
  23. <div class="tw-hidden xl:tw-block">
  24. <div class="tw-flex tw-justify-items-start tw-gap-[50px] tw-pt-[20px]">
  25. <div class="tw-body-3">
  26. {{ $t("Sort By") }}
  27. </div>
  28. <div class="tw-body-3">
  29. |
  30. </div>
  31. <div class="" v-for="(item, index) in sortType" :key="index">
  32. <!-- <button :for="item.value" class="tw-body-3 tw-text-base-secondary focus:tw-text-primary-1" @click="onChnage(item)">
  33. {{ $t(item.name) }}
  34. </button> -->
  35. <button :for="item.value" class="tw-body-3 tw-text-base-secondary focus:tw-text-primary-1" @click="onClick(item)">
  36. {{ $t(item.value) }}
  37. </button>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="element tw-flex tw-justify-between tw-items-cente xl:tw-hidden">
  42. <button class="btn-filter tw-text-transparent" @click="$emit('filter', true)">
  43. filter
  44. </button>
  45. <select class="tw-py-[9px] tw-rounded-[10px]" name="sort_by" v-model="sort" @change="onChnage()">
  46. <option value="0">{{ $t("Select option") }}</option>
  47. <!-- <option v-for="(item, index) in sortType" :key="index" :value="item.value" :selected="sort = item.value"> -->
  48. <option v-for="(item, index) in sortType" :key=item.name :value="item.name">
  49. {{ $t(item.value) }}
  50. </option>
  51. </select>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. export default {
  57. props: {
  58. results: {
  59. type: Number,
  60. },
  61. sortType: {
  62. type: Array,
  63. },
  64. sortBy: {
  65. type: String,
  66. },
  67. },
  68. data() {
  69. return {
  70. sort: this.sortBy ? this.sortBy : "0",
  71. options: {}
  72. };
  73. },
  74. watch: {
  75. sortBy: {
  76. handler: function () {
  77. this.sort = this.sortBy;
  78. },
  79. },
  80. sort: {
  81. handler: function () {
  82. // this.$emit("change", this.sort);
  83. this.$emit("sort", this.sort);
  84. },
  85. },
  86. },
  87. methods: {
  88. onClick(item) {
  89. this.sort = item.name;
  90. // console.log(this.sort);
  91. // this.$emit("sort", this.sort);
  92. },
  93. onChnage() {
  94. this.$emit("sort", this.sort);
  95. }
  96. },
  97. };
  98. </script>
  99. <style lang="scss" scoped>
  100. label {
  101. cursor: pointer;
  102. transition: all 0.2s linear;
  103. }
  104. // input:checked+label {
  105. // color: #f48800 !important;
  106. // }
  107. select {
  108. background-image: url("~/assets/svg/down-arrow.svg");
  109. background-size: 9px 6px;
  110. background-position: right 20px center;
  111. background-repeat: no-repeat;
  112. }
  113. .rightBorder {
  114. position: relative;
  115. color: #757575;
  116. &::after {
  117. position: absolute;
  118. display: block;
  119. content: " ";
  120. width: 1px;
  121. height: 13px;
  122. right: 0;
  123. top: 50%;
  124. transform: translate(0, -50%);
  125. background-color: #e5e5e5;
  126. }
  127. }
  128. .btn-filter {
  129. background-image: url("~/assets/svg/filter.svg");
  130. background-position: center;
  131. background-repeat: no-repeat;
  132. background-size: 40px;
  133. }
  134. </style>