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.

135 lines
2.9 KiB

2 years ago
  1. <template>
  2. <div class="faq tw-z-[9999]">
  3. <div
  4. v-show="index <= 2 || seeMore"
  5. class="tw-mb-[16px] md:tw-mb-[20px] tw-head-body tw-font-normal"
  6. v-for="(item, index) in faq"
  7. :key="index"
  8. >
  9. <faqItem :item="item"></faqItem>
  10. </div>
  11. <button
  12. v-show="length !== undefined && length > 3"
  13. :class="[
  14. 'seeMore tw-transition tw-btn-md tw-text-primary-1 tw-border tw-border-solid tw-border-primary-1 tw-px-[30px] tw-py-[8.5px] tw-mt-[20px] tw-w-full tw-rounded-xl hover:tw-bg-primary-3 xl:hover:tw-bg-transparent xl:tw-border-none',
  15. seeMore ? 'open' : '',
  16. ]"
  17. @click="opendFaq"
  18. >
  19. {{ $t(seeMoreText) }}
  20. </button>
  21. <faqModal :faq="faq" class="tw-z-[9999]"></faqModal>
  22. </div>
  23. </template>
  24. <script>
  25. import faqModal from "@/components/service/contentModal/faqModal.vue";
  26. import faqItem from "@/components/service/content/faqItem.vue";
  27. export default {
  28. props: {
  29. faq: {
  30. type: Array,
  31. },
  32. },
  33. components: {
  34. faqModal,
  35. faqItem,
  36. },
  37. data() {
  38. return {
  39. seeMore: false,
  40. window: {
  41. width: 0,
  42. },
  43. };
  44. },
  45. created() {
  46. if (process.browser) {
  47. window.addEventListener("resize", this.handleResize);
  48. }
  49. this.handleResize();
  50. },
  51. computed: {
  52. seeMoreText() {
  53. if (this.seeMore == false) {
  54. return "See more";
  55. } else {
  56. return "See less";
  57. }
  58. },
  59. length() {
  60. if (this.faq) {
  61. return this.faq.length;
  62. } else {
  63. return undefined;
  64. }
  65. },
  66. },
  67. methods: {
  68. handleResize() {
  69. if (process.browser) {
  70. this.window.width = window.innerWidth;
  71. }
  72. },
  73. opendFaq() {
  74. if (this.window.width >= 1366) {
  75. this.seeMore = !this.seeMore;
  76. } else {
  77. this.$modal.show("faq");
  78. }
  79. },
  80. },
  81. };
  82. </script>
  83. <style lang="scss" scoped>
  84. .seeMore {
  85. &-hide {
  86. position: relative;
  87. max-height: 295px;
  88. overflow: hidden;
  89. &::after {
  90. content: "";
  91. display: block;
  92. position: absolute;
  93. background: url("~/assets/img/gradient_white.png") repeat-x left bottom;
  94. width: 100%;
  95. height: 130px;
  96. left: 0;
  97. bottom: 0;
  98. z-index: 1;
  99. transition: bottom 0.5s;
  100. }
  101. }
  102. &-show {
  103. position: relative;
  104. max-height: 100%;
  105. overflow: initial;
  106. &::after {
  107. display: none;
  108. }
  109. }
  110. @media screen and (min-width: 1366px) {
  111. position: relative;
  112. display: flex;
  113. align-items: center;
  114. justify-content: center;
  115. &::after {
  116. content: "";
  117. display: inline-block;
  118. position: relative;
  119. background-image: url("~/assets/svg/arrow-down-primary.svg");
  120. background-position: center center;
  121. background-repeat: no-repeat;
  122. background-size: 100%;
  123. width: 9px;
  124. height: 6px;
  125. margin-left: 16px;
  126. transition: all 0.2s linear;
  127. }
  128. &.open {
  129. &::after {
  130. transform: rotate(180deg);
  131. }
  132. }
  133. }
  134. }
  135. </style>