diff --git a/src/components/Question.vue b/src/components/Question.vue new file mode 100644 index 0000000..4749353 --- /dev/null +++ b/src/components/Question.vue @@ -0,0 +1,99 @@ + + + + + + {{ question.title }} + + + + + {{ answer.title }} + + + + + + + + + + + + + + + + + diff --git a/src/components/Score.vue b/src/components/Score.vue index c7768c3..bd722ae 100644 --- a/src/components/Score.vue +++ b/src/components/Score.vue @@ -6,6 +6,7 @@ import { ref, computed } from "vue"; import { useStore } from "@/stores"; import { Splide, SplideSlide } from "@splidejs/vue-splide"; +import Question from "./Question.vue"; import "@splidejs/splide/dist/css/splide.min.css"; import ScoreHeader from "./ScoreHeader.vue"; @@ -60,9 +61,6 @@ function formatScore(score) { const title = score ? score.title : ""; const questions = ref(formatScore(score)); -function nextQuestion() { - setTimeout(() => slides.value.go(">"), 100); -} const scoreSum = computed(() => { return questions.value .map((question) => question.weight) @@ -97,21 +95,16 @@ const result = computed(() => .filter((r) => !r.max || r.max >= scoreSum.value)[0] : null ); -function selectImage(event, question, answer) { - const input = document.querySelector( - `input[name='question_${question.id}'][value='${answer.weight}']` - ); - if (input) { - input.checked = true; - input.dispatchEvent(new Event("change")); - } - nextQuestion(); -} -function geQuestionSlide(question) { +function goQuestionSlide(question) { + console.log(slides.value); slides.value.go( questions.value.findIndex((element) => element.id === question.id) ); } +function answerSelected(question, answerWeight) { + questions.value.find((q) => q.id === question.id).weight = answerWeight; + setTimeout(() => slides.value.go(">"), 100); +} @@ -131,57 +124,7 @@ function geQuestionSlide(question) { }" > - - - {{ question.title }} - - - - { - question.weight = parseFloat(event.target.value); - } - " - @click="nextQuestion" - /> - {{ answer.title }} - - - - - - - - selectImage(event, { ...question }, { ...answer }) - " - > - - - - - - + @@ -216,7 +159,7 @@ function geQuestionSlide(question) { { - geQuestionSlide(question); + goQuestionSlide(question); return false; } " @@ -254,9 +197,6 @@ function geQuestionSlide(question) { bottom: 0 background: transparent - input[type=radio] - margin-right: .5rem - .splide__slide background: transparent @@ -313,29 +253,6 @@ label top: 0 line-height: .7rem -.main - height: 100% - max-width: 100% - display: flex - flex-direction: column - justify-content: space-around - align-items: center - - .bottom - width: 400px - max-width: 100% - min-width: 280px - -.answers - text-align: center - .splide__arrows position: inherit - -@media only screen and (orientation : landscape) - .main - flex-direction: row - - .bottom - max-width: 50%