|
| 1 | +<script setup lang="ts"> |
| 2 | +import { ref, type Ref } from 'vue'; |
| 3 | +import { useI18n } from 'vue-i18n'; |
| 4 | +
|
| 5 | +const { t } = useI18n(); |
| 6 | +
|
| 7 | +export interface QA { |
| 8 | + question: string; |
| 9 | + answer: string; |
| 10 | +} |
| 11 | +
|
| 12 | +const content: QA[] = [ |
| 13 | + { |
| 14 | + question: 'question_implication', |
| 15 | + answer: 'answer_implication', |
| 16 | + }, |
| 17 | + { |
| 18 | + question: 'question_skills', |
| 19 | + answer: 'answer_skills', |
| 20 | + }, |
| 21 | + { |
| 22 | + question: 'question_apply', |
| 23 | + answer: 'answer_apply', |
| 24 | + }, |
| 25 | + { |
| 26 | + question: 'question_recruitment_period', |
| 27 | + answer: 'answer_recruitment_period', |
| 28 | + }, |
| 29 | + { |
| 30 | + question: 'question_visit', |
| 31 | + answer: 'answer_visit', |
| 32 | + }, |
| 33 | +]; |
| 34 | +
|
| 35 | +const selected: Ref<number | null> = ref(null); |
| 36 | +const showAll = ref(false); |
| 37 | +const containers: Ref<HTMLElement[]> = ref([]); |
| 38 | +</script> |
| 39 | + |
| 40 | +<template> |
| 41 | + <section |
| 42 | + id="FAQ" |
| 43 | + class="container mx-auto mb-10 px-4 bg-gray-100 w-100 pt-10 rounded-2xl" |
| 44 | + > |
| 45 | + <h2 class="text-5xl md:text-6xl font-bold font-sans text-center pt-10"> |
| 46 | + {{ t('faq') }} |
| 47 | + </h2> |
| 48 | + <div class="flex justify-center px-4 py-20"> |
| 49 | + <div class="container mx-auto px-4"> |
| 50 | + <!-- Column 1 --> |
| 51 | + <div class="bg-white max-w-full mx-auto border border-gray-200"> |
| 52 | + <ul class="shadow-box"> |
| 53 | + <li |
| 54 | + v-for="(qa, index) in content" |
| 55 | + :key="index" |
| 56 | + class="relative border-b border-gray-200" |
| 57 | + > |
| 58 | + <button |
| 59 | + type="button" |
| 60 | + class="w-full px-6 py-5 text-left" |
| 61 | + @click=" |
| 62 | + selected !== index ? (selected = index) : (selected = null) |
| 63 | + " |
| 64 | + > |
| 65 | + <div class="flex items-center justify-between"> |
| 66 | + <div class="flex"> |
| 67 | + <p class="w-8 shrink-0 text-xl font-semibold"> |
| 68 | + {{ t('question') }} |
| 69 | + </p> |
| 70 | + <p class="pt-1">{{ t(qa.question) }}</p> |
| 71 | + </div> |
| 72 | + <svg |
| 73 | + :class="{ |
| 74 | + 'transform rotate-180': selected == index || showAll, |
| 75 | + }" |
| 76 | + class="w-5 h-5 text-gray-500" |
| 77 | + fill="none" |
| 78 | + stroke-linecap="round" |
| 79 | + stroke-linejoin="round" |
| 80 | + stroke-width="2" |
| 81 | + viewBox="0 0 24 24" |
| 82 | + stroke="currentColor" |
| 83 | + > |
| 84 | + <path d="M19 9l-7 7-7-7" /> |
| 85 | + </svg> |
| 86 | + </div> |
| 87 | + </button> |
| 88 | + <div |
| 89 | + ref="containers" |
| 90 | + class="relative overflow-hidden transition-all max-h-0 duration-700" |
| 91 | + style="" |
| 92 | + :style=" |
| 93 | + selected == index || showAll |
| 94 | + ? 'max-height: ' + containers[index]?.scrollHeight + 'px' |
| 95 | + : '' |
| 96 | + " |
| 97 | + > |
| 98 | + <div class="px-6 pb-5 flex"> |
| 99 | + <p class="w-8 shrink-0 text-xl font-semibold"> |
| 100 | + {{ t('answer') }} |
| 101 | + </p> |
| 102 | + <p class="pt-1">{{ t(qa.answer) }}</p> |
| 103 | + </div> |
| 104 | + </div> |
| 105 | + </li> |
| 106 | + </ul> |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + </section> |
| 111 | +</template> |
| 112 | + |
| 113 | +<style scoped> |
| 114 | +.max-h-0 { |
| 115 | + max-height: 0; |
| 116 | +} |
| 117 | +</style> |
0 commit comments